Implement parallel CI workflows for backend and frontend testing #5
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 E2E Tests | |
| on: | |
| push: | |
| branches: [main, develop] | |
| paths: | |
| - 'frontend/**' | |
| - 'backend/**' | |
| - '.github/workflows/frontend-e2e.yml' | |
| pull_request: | |
| branches: [main, develop] | |
| paths: | |
| - 'frontend/**' | |
| - 'backend/**' | |
| - '.github/workflows/frontend-e2e.yml' | |
| # Cancel in-progress runs for the same workflow and branch | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| e2e-tests: | |
| name: Playwright E2E | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v1 | |
| with: | |
| bun-version: latest | |
| - name: Cache Bun dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.bun/install/cache | |
| key: ${{ runner.os }}-bun-${{ hashFiles('frontend/bun.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-bun- | |
| - name: Install dependencies | |
| working-directory: ./frontend | |
| run: bun install --frozen-lockfile | |
| - name: Cache Playwright browsers | |
| uses: actions/cache@v4 | |
| id: playwright-cache | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: ${{ runner.os }}-playwright-${{ hashFiles('frontend/bun.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-playwright- | |
| - name: Install Playwright browsers | |
| working-directory: ./frontend | |
| run: bunx playwright install --with-deps chromium | |
| if: steps.playwright-cache.outputs.cache-hit != 'true' | |
| - name: Install Playwright system dependencies | |
| working-directory: ./frontend | |
| run: bunx playwright install-deps chromium | |
| if: steps.playwright-cache.outputs.cache-hit == 'true' | |
| - name: Install Encore CLI | |
| run: | | |
| curl -L https://encore.dev/install.sh | bash | |
| echo "${HOME}/.encore/bin" >> "${GITHUB_PATH}" | |
| - name: Install backend dependencies | |
| working-directory: ./backend | |
| run: bun install --frozen-lockfile | |
| - name: Start backend service | |
| working-directory: ./backend | |
| run: | | |
| encore run --port=4000 > /tmp/backend.log 2>&1 & | |
| echo $! > /tmp/backend.pid | |
| # Wait for backend to be ready | |
| for i in {1..30}; do | |
| if curl -f http://localhost:4000/health >/dev/null 2>&1; then | |
| echo "✅ Backend is ready" | |
| break | |
| fi | |
| echo "⏳ Waiting for backend (attempt $i/30)..." | |
| sleep 2 | |
| done | |
| env: | |
| BACKEND_PORT: 4000 | |
| - name: Build frontend | |
| working-directory: ./frontend | |
| run: bun run build | |
| env: | |
| PUBLIC_API_BASE: http://localhost:4000 | |
| VITE_BACKEND_BASE_URL: http://localhost:4000 | |
| - name: Run E2E tests | |
| working-directory: ./frontend | |
| run: bun run test:e2e:ci | |
| env: | |
| CI: true | |
| HEADLESS: true | |
| VITE_BACKEND_BASE_URL: http://localhost:4000 | |
| FRONTEND_URL: http://localhost:5173 | |
| - name: Stop backend service | |
| if: always() | |
| run: | | |
| if [ -f /tmp/backend.pid ]; then | |
| kill "$(cat /tmp/backend.pid)" || true | |
| rm /tmp/backend.pid | |
| fi | |
| - name: Upload backend logs | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: backend-logs | |
| path: /tmp/backend.log | |
| retention-days: 7 | |
| if-no-files-found: ignore | |
| - name: Upload Playwright report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: frontend/playwright-report/ | |
| retention-days: 7 | |
| if-no-files-found: ignore | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: frontend-test-results | |
| path: frontend/test-results/ | |
| retention-days: 7 | |
| if-no-files-found: ignore |