Merge pull request #254 from streamspace-dev/fix/ui-vitest-setup #216
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI - StreamSpace v2.0 | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| - develop | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| env: | |
| GO_VERSION: '1.21' | |
| NODE_VERSION: '18' | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Download K8s Agent dependencies | |
| working-directory: ./agents/k8s-agent | |
| run: | | |
| go mod tidy | |
| go mod download | |
| - name: Lint K8s Agent | |
| working-directory: ./agents/k8s-agent | |
| run: | | |
| go fmt ./... | |
| go vet ./... | |
| # Install golangci-lint | |
| curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 | |
| golangci-lint run | |
| - name: Download API dependencies | |
| working-directory: ./api | |
| run: | | |
| go mod tidy | |
| go mod download | |
| - name: Lint API (Control Plane) | |
| working-directory: ./api | |
| run: | | |
| go fmt ./... | |
| go vet ./... | |
| golangci-lint run | |
| - name: Lint UI | |
| working-directory: ./ui | |
| run: | | |
| npm ci | |
| npm run lint | |
| test-k8s-agent: | |
| name: Test K8s Agent | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('agents/k8s-agent/go.sum', 'agents/k8s-agent/go.mod') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Download dependencies | |
| working-directory: ./agents/k8s-agent | |
| run: | | |
| go mod download | |
| go mod tidy | |
| - name: Run tests | |
| working-directory: ./agents/k8s-agent | |
| run: | | |
| go test -v -race -coverprofile=coverage.out -covermode=atomic ./... | |
| go tool cover -func=coverage.out | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./agents/k8s-agent/coverage.out | |
| flags: k8s-agent | |
| name: k8s-agent-coverage | |
| test-api: | |
| name: Test Control Plane API | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15-alpine | |
| env: | |
| POSTGRES_USER: streamspace | |
| POSTGRES_PASSWORD: testpassword | |
| POSTGRES_DB: streamspace_test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('api/go.sum', 'api/go.mod') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Download dependencies | |
| working-directory: ./api | |
| run: | | |
| go mod tidy | |
| go mod download | |
| - name: Run tests | |
| working-directory: ./api | |
| env: | |
| DB_HOST: localhost | |
| DB_PORT: 5432 | |
| DB_NAME: streamspace_test | |
| DB_USER: streamspace | |
| DB_PASSWORD: testpassword | |
| DB_SSLMODE: disable | |
| run: | | |
| # Check if there are any test files | |
| if find . -name "*_test.go" | grep -q .; then | |
| go test -v -race -coverprofile=coverage.out -covermode=atomic ./... | |
| go tool cover -func=coverage.out | |
| else | |
| echo "No test files found, skipping tests" | |
| exit 0 | |
| fi | |
| - name: Upload coverage to Codecov | |
| if: hashFiles('api/coverage.out') != '' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./api/coverage.out | |
| flags: api | |
| name: api-coverage | |
| test-ui: | |
| name: Test UI | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Cache node modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-node-${{ hashFiles('ui/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| - name: Install dependencies | |
| working-directory: ./ui | |
| run: npm ci | |
| - name: Run tests | |
| working-directory: ./ui | |
| run: npm test | |
| - name: Upload coverage to Codecov | |
| if: hashFiles('ui/coverage/lcov.info') != '' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./ui/coverage/lcov.info | |
| flags: ui | |
| name: ui-coverage | |
| build: | |
| name: Build v2.0 Components | |
| runs-on: ubuntu-latest | |
| needs: [lint, test-k8s-agent, test-api, test-ui] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Download K8s Agent dependencies | |
| working-directory: ./agents/k8s-agent | |
| run: | | |
| go mod tidy | |
| go mod download | |
| - name: Build K8s Agent | |
| working-directory: ./agents/k8s-agent | |
| run: | | |
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/k8s-agent . | |
| echo "K8s Agent binary size: $(ls -lh bin/k8s-agent | awk '{print $5}')" | |
| - name: Download Control Plane API dependencies | |
| working-directory: ./api | |
| run: | | |
| go mod tidy | |
| go mod download | |
| - name: Build Control Plane API | |
| working-directory: ./api | |
| run: | | |
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/api cmd/main.go | |
| echo "Control Plane API binary size: $(ls -lh bin/api | awk '{print $5}')" | |
| - name: Build UI | |
| working-directory: ./ui | |
| run: | | |
| npm ci | |
| npm run build | |
| echo "UI build size: $(du -sh build | awk '{print $1}')" | |
| - name: Upload K8s Agent artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: k8s-agent-binary | |
| path: agents/k8s-agent/bin/k8s-agent | |
| - name: Upload Control Plane API artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: api-binary | |
| path: api/bin/api | |
| - name: Upload UI artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ui-build | |
| path: ui/build/ | |
| helm-lint: | |
| name: Helm Lint (v2.0) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4 | |
| with: | |
| version: 'v3.14.0' | |
| - name: Lint Helm chart | |
| run: | | |
| helm lint chart/ | |
| helm template streamspace chart/ --namespace streamspace > /dev/null | |
| summary: | |
| name: CI Summary (v2.0) | |
| runs-on: ubuntu-latest | |
| needs: [build, helm-lint] | |
| if: always() | |
| steps: | |
| - name: Check status | |
| run: | | |
| echo "## StreamSpace v2.0 CI Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Architecture: Multi-Platform Agent-Based" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ All checks passed!" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Components Built" >> $GITHUB_STEP_SUMMARY | |
| echo "- **K8s Agent**: Built successfully ✅" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Control Plane API**: Built successfully ✅" >> $GITHUB_STEP_SUMMARY | |
| echo "- **UI**: Built successfully ✅" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Helm Chart**: Validated ✅" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### v2.0 Features" >> $GITHUB_STEP_SUMMARY | |
| echo "- Agent-based architecture (K8s, Docker, VMs)" >> $GITHUB_STEP_SUMMARY | |
| echo "- Centralized Control Plane" >> $GITHUB_STEP_SUMMARY | |
| echo "- WebSocket agent communication" >> $GITHUB_STEP_SUMMARY | |
| echo "- VNC proxy tunneling" >> $GITHUB_STEP_SUMMARY |