chore: frontend updates #62
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: 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 CI | |
| run: | | |
| cat > backend/kubeconfig.yaml <<EOF | |
| apiVersion: v1 | |
| kind: Config | |
| clusters: | |
| - name: ci-cluster | |
| cluster: | |
| server: https://host.docker.internal:6443 | |
| insecure-skip-tls-verify: true | |
| users: | |
| - name: ci-user | |
| user: | |
| token: "ci-token" | |
| contexts: | |
| - name: ci | |
| context: | |
| cluster: ci-cluster | |
| user: ci-user | |
| current-context: ci | |
| EOF | |
| - name: Setup CI Compose | |
| uses: ./.github/actions/setup-ci-compose | |
| with: | |
| kubeconfig-path: /home/runner/.kube/config | |
| - name: Build services | |
| uses: docker/bake-action@v6 | |
| with: | |
| source: . | |
| files: docker-compose.ci.yaml | |
| load: true | |
| set: | | |
| *.cache-from=type=gha,scope=buildkit-${{ github.repository }}-${{ github.ref_name }} | |
| *.cache-from=type=gha,scope=buildkit-${{ github.repository }}-main | |
| *.cache-to=type=gha,mode=max,scope=buildkit-${{ github.repository }}-${{ github.ref_name }} | |
| *.pull=true | |
| env: | |
| BUILDKIT_PROGRESS: plain | |
| - name: Start services | |
| run: | | |
| docker compose -f docker-compose.ci.yaml up -d --remove-orphans | |
| docker compose -f docker-compose.ci.yaml ps | |
| - name: Wait for services | |
| run: | | |
| echo "Waiting for backend..." | |
| curl --retry 60 --retry-delay 5 --retry-all-errors -ksf https://127.0.0.1:443/api/v1/health/live | |
| echo "Waiting for frontend..." | |
| curl --retry 60 --retry-delay 5 --retry-all-errors -ksf https://127.0.0.1:5001/ | |
| - 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 | |
| docker compose -f docker-compose.ci.yaml logs backend > logs/backend.log | |
| docker compose -f docker-compose.ci.yaml logs frontend > logs/frontend.log | |
| - name: Upload logs | |
| if: failure() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: frontend-e2e-logs | |
| path: logs/ |