playwright base setup [WIP] #9
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: π Playwright E2E Tests | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| workflow_dispatch: | |
| jobs: | |
| e2e-tests: | |
| name: π§ͺ E2E Tests | |
| timeout-minutes: 60 | |
| runs-on: ubuntu-22.04 | |
| env: | |
| NODE_ENV: test | |
| NEXTAUTH_SECRET: 'test-secret-for-ci-only' | |
| NEXT_PUBLIC_EXAMPLE_VARIABLE: 'CI Test Variable' | |
| PRIVATE_EXAMPLE_VARIABLE: 'Private CI Test Variable' | |
| CI: true | |
| steps: | |
| - name: π₯ Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: π» Node setup | |
| uses: ./.github/actions/node-setup | |
| - name: β»οΈ Restore Turbo Cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: .turbo | |
| key: turbo-${{ github.ref }}-${{ github.sha }} | |
| restore-keys: | | |
| turbo-${{ github.ref }}- | |
| turbo- | |
| - name: π E2E Setup | |
| uses: ./.github/actions/e2e-setup | |
| with: | |
| browsers: 'chromium' | |
| - name: ποΈ Build Frontend App | |
| run: pnpm --filter @infinum/frontend build | |
| shell: bash | |
| - name: π Debug Build Output | |
| run: | | |
| echo "π Current working directory:" | |
| pwd | |
| echo "" | |
| echo "π Contents of apps/frontend:" | |
| ls -la apps/frontend/ | head -10 | |
| echo "" | |
| echo "ποΈ Contents of apps/frontend/.next:" | |
| ls -la apps/frontend/.next/ || echo "β No .next directory found" | |
| echo "" | |
| echo "π¦ Checking for standalone server:" | |
| if [ -f "apps/frontend/.next/standalone/apps/frontend/server.js" ]; then | |
| echo "β Found: apps/frontend/.next/standalone/apps/frontend/server.js" | |
| else | |
| echo "β NOT found: apps/frontend/.next/standalone/apps/frontend/server.js" | |
| fi | |
| echo "" | |
| echo "π Looking for any server.js files:" | |
| find apps/frontend/.next -name "server.js" -type f 2>/dev/null || echo "β No server.js files found" | |
| shell: bash | |
| - name: π Start Frontend App (Background) | |
| run: | | |
| node .next/standalone/apps/frontend/server.js & | |
| echo "FRONTEND_PID=$!" >> $GITHUB_ENV | |
| shell: bash | |
| - name: β³ Wait for Frontend to be Ready | |
| run: | | |
| echo "Waiting for frontend to start on http://localhost:3000..." | |
| timeout 60s bash -c 'until curl -f http://localhost:3000 > /dev/null 2>&1; do | |
| echo "Waiting for frontend..." | |
| sleep 3 | |
| done' | |
| echo "Frontend is ready!" | |
| shell: bash | |
| - name: π Health Check | |
| run: | | |
| echo "Running health check..." | |
| curl -f http://localhost:3000 -I | head -5 | |
| echo "Health check passed!" | |
| shell: bash | |
| - name: π§ͺ Run Playwright E2E Tests | |
| run: pnpm e2e | |
| shell: bash | |
| env: | |
| PLAYWRIGHT_JUNIT_OUTPUT_NAME: test-results.xml | |
| - name: π Stop Frontend App | |
| if: always() | |
| run: | | |
| if [ ! -z "$FRONTEND_PID" ]; then | |
| kill $FRONTEND_PID || true | |
| fi | |
| shell: bash | |
| - name: π Upload Playwright Report | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ !cancelled() }} | |
| with: | |
| name: playwright-report-${{ github.run_id }} | |
| path: | | |
| packages/e2e-frontend/playwright-report/ | |
| packages/e2e-frontend/test-results/ | |
| retention-days: 30 | |
| - name: π Upload Coverage Reports | |
| uses: actions/upload-artifact@v4 | |
| if: success() | |
| with: | |
| name: e2e-coverage-${{ github.run_id }} | |
| path: | | |
| reports/a11y/ | |
| retention-days: 7 |