chore: speed-up of CI tests #81
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: Frontend CI | |
| on: | |
| push: | |
| branches: [main, dev] | |
| paths: | |
| - 'frontend/**' | |
| - '.github/workflows/frontend-ci.yml' | |
| - 'docker-compose.ci.yaml' | |
| pull_request: | |
| branches: [main, dev] | |
| paths: | |
| - 'frontend/**' | |
| - '.github/workflows/frontend-ci.yml' | |
| - 'docker-compose.ci.yaml' | |
| workflow_dispatch: | |
| jobs: | |
| unit: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| 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 | |
| name: frontend-coverage | |
| fail_ci_if_error: false | |
| verbose: true | |
| e2e: | |
| name: E2E Tests | |
| needs: unit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install dependencies | |
| working-directory: frontend | |
| run: npm ci | |
| - name: Install Playwright browsers | |
| working-directory: frontend | |
| run: npx playwright install chromium | |
| - name: Setup Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Setup Kubernetes (k3s) | |
| run: | | |
| curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=traefik --tls-san host.docker.internal" sh - | |
| mkdir -p /home/runner/.kube | |
| sudo k3s kubectl config view --raw > /home/runner/.kube/config | |
| sudo chmod 600 /home/runner/.kube/config | |
| export KUBECONFIG=/home/runner/.kube/config | |
| timeout 90 bash -c 'until sudo k3s kubectl cluster-info; do sleep 5; done' | |
| - name: Create kubeconfig for Docker containers | |
| run: | | |
| # Copy k3s kubeconfig with host.docker.internal for container networking | |
| sed 's|https://127.0.0.1:6443|https://host.docker.internal:6443|g' \ | |
| /home/runner/.kube/config > backend/kubeconfig.yaml | |
| chmod 644 backend/kubeconfig.yaml | |
| - name: Build and start full stack | |
| run: | | |
| docker compose -f docker-compose.ci.yaml --profile full up -d --build --wait --wait-timeout 300 | |
| docker compose -f docker-compose.ci.yaml ps | |
| - name: Seed test users | |
| run: | | |
| docker compose -f docker-compose.ci.yaml exec -T backend uv run python scripts/seed_users.py | |
| - name: Run E2E tests | |
| working-directory: frontend | |
| env: | |
| CI: true | |
| run: npx playwright test --reporter=html | |
| - name: Upload Playwright report | |
| uses: actions/upload-artifact@v6 | |
| if: always() | |
| with: | |
| name: playwright-report | |
| path: frontend/playwright-report/ | |
| - name: Collect logs | |
| if: failure() | |
| run: | | |
| mkdir -p logs | |
| docker compose -f docker-compose.ci.yaml logs > logs/docker-compose.log 2>&1 | |
| docker compose -f docker-compose.ci.yaml logs backend > logs/backend.log 2>&1 | |
| docker compose -f docker-compose.ci.yaml logs frontend > logs/frontend.log 2>&1 | |
| docker compose -f docker-compose.ci.yaml logs kafka > logs/kafka.log 2>&1 | |
| 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: frontend-e2e-logs | |
| path: logs/ |