fix: frontend tests added #165
Workflow file for this run
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: Stack Tests | |
| on: | |
| push: | |
| branches: [main, dev] | |
| paths: | |
| - 'backend/**' | |
| - 'frontend/**' | |
| - 'docker-compose.yaml' | |
| - 'deploy.sh' | |
| - '.github/workflows/stack-tests.yml' | |
| - '.github/actions/**' | |
| pull_request: | |
| branches: [main, dev] | |
| paths: | |
| - 'backend/**' | |
| - 'frontend/**' | |
| - 'docker-compose.yaml' | |
| - 'deploy.sh' | |
| - '.github/workflows/stack-tests.yml' | |
| - '.github/actions/**' | |
| workflow_dispatch: | |
| env: | |
| MONGO_IMAGE: mongo:8.0 | |
| REDIS_IMAGE: redis:7-alpine | |
| KAFKA_IMAGE: confluentinc/cp-kafka:7.8.2 | |
| ZOOKEEPER_IMAGE: confluentinc/cp-zookeeper:7.8.2 | |
| SCHEMA_REGISTRY_IMAGE: confluentinc/cp-schema-registry:7.8.2 | |
| jobs: | |
| # Fast unit tests (no infrastructure needed) | |
| backend-unit: | |
| name: Backend Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: "backend/uv.lock" | |
| - name: Install Python dependencies | |
| run: | | |
| cd backend | |
| uv python install 3.12 | |
| uv sync --frozen | |
| - name: Set up config | |
| run: cp backend/secrets.example.toml backend/secrets.toml | |
| - name: Run unit tests | |
| timeout-minutes: 5 | |
| run: | | |
| cd backend | |
| uv run pytest tests/unit -v -rs \ | |
| --durations=0 \ | |
| --cov=app \ | |
| --cov-report=xml --cov-report=term | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| if: always() | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: backend/coverage.xml | |
| flags: backend-unit | |
| name: backend-unit-coverage | |
| fail_ci_if_error: false | |
| verbose: true | |
| frontend-unit: | |
| name: Frontend Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install dependencies | |
| working-directory: frontend | |
| run: npm ci | |
| - name: Run unit tests with coverage | |
| working-directory: frontend | |
| run: npm run test:coverage | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: frontend/coverage/lcov.info | |
| flags: frontend-unit | |
| name: frontend-unit-coverage | |
| fail_ci_if_error: false | |
| verbose: true | |
| # Build all images once, cache for test jobs | |
| build-images: | |
| name: Build Images | |
| needs: [backend-unit, frontend-unit] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Cache base image | |
| uses: actions/cache@v5 | |
| id: base-cache | |
| with: | |
| path: /tmp/base-image.tar.zst | |
| key: base-image-${{ runner.os }}-${{ hashFiles('backend/Dockerfile.base', 'backend/pyproject.toml', 'backend/uv.lock') }} | |
| - name: Load base image from cache | |
| if: steps.base-cache.outputs.cache-hit == 'true' | |
| run: zstd -d -c /tmp/base-image.tar.zst | docker load | |
| - name: Build base image | |
| if: steps.base-cache.outputs.cache-hit != 'true' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./backend | |
| file: ./backend/Dockerfile.base | |
| load: true | |
| tags: integr8scode-base:latest | |
| cache-from: type=gha,scope=backend-base | |
| cache-to: type=gha,mode=max,scope=backend-base | |
| - name: Save base image to cache | |
| if: steps.base-cache.outputs.cache-hit != 'true' | |
| run: docker save integr8scode-base:latest | zstd -T0 -3 > /tmp/base-image.tar.zst | |
| - name: Build all images | |
| run: | | |
| docker build -t integr8scode-backend:latest --build-context base=docker-image://integr8scode-base:latest -f ./backend/Dockerfile ./backend | |
| docker build -t integr8scode-coordinator:latest -f backend/workers/Dockerfile.coordinator --build-context base=docker-image://integr8scode-base:latest ./backend | |
| docker build -t integr8scode-k8s-worker:latest -f backend/workers/Dockerfile.k8s_worker --build-context base=docker-image://integr8scode-base:latest ./backend | |
| docker build -t integr8scode-pod-monitor:latest -f backend/workers/Dockerfile.pod_monitor --build-context base=docker-image://integr8scode-base:latest ./backend | |
| docker build -t integr8scode-result-processor:latest -f backend/workers/Dockerfile.result_processor --build-context base=docker-image://integr8scode-base:latest ./backend | |
| docker build -t integr8scode-saga-orchestrator:latest -f backend/workers/Dockerfile.saga_orchestrator --build-context base=docker-image://integr8scode-base:latest ./backend | |
| - name: Build cert-generator image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./cert-generator | |
| file: ./cert-generator/Dockerfile | |
| load: true | |
| tags: integr8scode-cert-generator:latest | |
| cache-from: type=gha,scope=cert-generator | |
| cache-to: type=gha,mode=max,scope=cert-generator | |
| - name: Build frontend image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./frontend | |
| file: ./frontend/Dockerfile | |
| load: true | |
| tags: integr8scode-frontend:latest | |
| cache-from: type=gha,scope=frontend | |
| cache-to: type=gha,mode=max,scope=frontend | |
| - name: Save all images | |
| run: | | |
| docker save \ | |
| integr8scode-backend:latest \ | |
| integr8scode-coordinator:latest \ | |
| integr8scode-k8s-worker:latest \ | |
| integr8scode-pod-monitor:latest \ | |
| integr8scode-result-processor:latest \ | |
| integr8scode-saga-orchestrator:latest \ | |
| integr8scode-cert-generator:latest \ | |
| integr8scode-frontend:latest \ | |
| | zstd -T0 -3 > /tmp/all-images.tar.zst | |
| - name: Upload images artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: docker-images | |
| path: /tmp/all-images.tar.zst | |
| retention-days: 1 | |
| # Parallel test jobs (backend-e2e, frontend-e2e) | |
| backend-e2e: | |
| name: Backend E2E Tests | |
| needs: [build-images] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Cache and load Docker images | |
| uses: ./.github/actions/docker-cache | |
| with: | |
| images: ${{ env.MONGO_IMAGE }} ${{ env.REDIS_IMAGE }} ${{ env.KAFKA_IMAGE }} ${{ env.ZOOKEEPER_IMAGE }} ${{ env.SCHEMA_REGISTRY_IMAGE }} | |
| - name: Download built images | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: docker-images | |
| path: /tmp | |
| - name: Load built images | |
| run: zstd -d -c /tmp/all-images.tar.zst | docker load | |
| - name: Setup k3s | |
| uses: ./.github/actions/k3s-setup | |
| - name: Use test environment config | |
| run: | | |
| cp backend/config.test.toml backend/config.toml | |
| cp backend/secrets.example.toml backend/secrets.toml | |
| - name: Start stack | |
| run: ./deploy.sh dev --wait | |
| - name: Seed test users | |
| run: docker compose exec -T backend uv run python scripts/seed_users.py | |
| - name: Run E2E tests | |
| timeout-minutes: 15 | |
| run: | | |
| docker compose exec -T backend \ | |
| uv run pytest tests/e2e -v -rs \ | |
| --durations=0 \ | |
| --cov=app \ | |
| --cov-report=xml:coverage-e2e.xml \ | |
| --cov-report=term | |
| - name: Copy coverage | |
| if: always() | |
| run: docker compose cp backend:/app/coverage-e2e.xml backend/coverage-e2e.xml || true | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| if: always() | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: backend/coverage-e2e.xml | |
| flags: backend-e2e | |
| name: backend-e2e-coverage | |
| fail_ci_if_error: false | |
| - name: Collect logs on failure | |
| if: failure() | |
| run: | | |
| mkdir -p logs | |
| docker compose logs --timestamps > logs/docker-compose.log 2>&1 | |
| docker compose logs --timestamps backend > logs/backend.log 2>&1 | |
| docker compose logs --timestamps mongo > logs/mongo.log 2>&1 || true | |
| docker compose logs --timestamps redis > logs/redis.log 2>&1 || true | |
| docker compose logs --timestamps kafka > logs/kafka.log 2>&1 || true | |
| docker compose logs --timestamps zookeeper > logs/zookeeper.log 2>&1 || true | |
| docker compose logs --timestamps schema-registry > logs/schema-registry.log 2>&1 || true | |
| docker compose logs --timestamps coordinator > logs/coordinator.log 2>&1 || true | |
| docker compose logs --timestamps k8s-worker > logs/k8s-worker.log 2>&1 || true | |
| docker compose logs --timestamps pod-monitor > logs/pod-monitor.log 2>&1 || true | |
| docker compose logs --timestamps result-processor > logs/result-processor.log 2>&1 || true | |
| docker compose logs --timestamps saga-orchestrator > logs/saga-orchestrator.log 2>&1 || true | |
| docker compose logs --timestamps event-replay > logs/event-replay.log 2>&1 || true | |
| docker compose logs --timestamps dlq-processor > logs/dlq-processor.log 2>&1 || true | |
| kubectl get events --sort-by='.metadata.creationTimestamp' -A > logs/k8s-events.log 2>&1 || true | |
| - name: Upload logs | |
| if: failure() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: backend-e2e-logs | |
| path: logs/ | |
| frontend-e2e: | |
| name: Frontend E2E Tests | |
| needs: [build-images] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install frontend dependencies | |
| working-directory: frontend | |
| run: npm ci | |
| - name: Cache Playwright browsers | |
| uses: actions/cache@v5 | |
| id: playwright-cache | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: playwright-${{ runner.os }}-${{ hashFiles('frontend/package-lock.json') }} | |
| - name: Install Playwright system dependencies | |
| working-directory: frontend | |
| run: npx playwright install-deps chromium | |
| - name: Install Playwright browsers | |
| if: steps.playwright-cache.outputs.cache-hit != 'true' | |
| working-directory: frontend | |
| run: npx playwright install chromium | |
| - name: Cache and load Docker images | |
| uses: ./.github/actions/docker-cache | |
| with: | |
| images: ${{ env.MONGO_IMAGE }} ${{ env.REDIS_IMAGE }} ${{ env.KAFKA_IMAGE }} ${{ env.ZOOKEEPER_IMAGE }} ${{ env.SCHEMA_REGISTRY_IMAGE }} | |
| - name: Download built images | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: docker-images | |
| path: /tmp | |
| - name: Load built images | |
| run: zstd -d -c /tmp/all-images.tar.zst | docker load | |
| - name: Setup k3s | |
| uses: ./.github/actions/k3s-setup | |
| - name: Use test environment config | |
| run: | | |
| cp backend/config.test.toml backend/config.toml | |
| cp backend/secrets.example.toml backend/secrets.toml | |
| - name: Start stack | |
| run: ./deploy.sh dev --wait | |
| - name: Seed test users | |
| run: docker compose exec -T backend uv run python scripts/seed_users.py | |
| - name: Run Playwright tests | |
| timeout-minutes: 10 | |
| working-directory: frontend | |
| run: CI=true npx playwright test | |
| - name: Upload Playwright report | |
| uses: actions/upload-artifact@v6 | |
| if: always() | |
| with: | |
| name: playwright-report | |
| path: frontend/playwright-report/ | |
| - name: Collect logs on failure | |
| if: failure() | |
| run: | | |
| mkdir -p logs | |
| docker compose logs > logs/docker-compose.log 2>&1 | |
| docker compose logs backend > logs/backend.log 2>&1 | |
| docker compose logs frontend > logs/frontend.log 2>&1 | |
| - name: Upload logs | |
| if: failure() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: frontend-e2e-logs | |
| path: logs/ |