playwright base setup [WIP] #13
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: πΎ Cache Playwright browsers | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-playwright- | |
| - name: π E2E Setup | |
| uses: ./.github/actions/e2e-setup | |
| with: | |
| browsers: 'chromium' | |
| - name: ποΈ Build Frontend App | |
| run: pnpm --filter @infinum/frontend build | |
| shell: bash | |
| - name: π Start Frontend App (Background) | |
| run: | | |
| echo "π§ Environment variables:" | |
| echo "NODE_ENV: $NODE_ENV" | |
| echo "NEXTAUTH_SECRET: ${NEXTAUTH_SECRET:0:10}..." | |
| echo "" | |
| echo "π Starting server..." | |
| node apps/frontend/.next/standalone/apps/frontend/server.js & | |
| SERVER_PID=$! | |
| echo "FRONTEND_PID=$SERVER_PID" >> $GITHUB_ENV | |
| echo "β Server started with PID: $SERVER_PID" | |
| sleep 2 | |
| echo "π Server process status:" | |
| ps aux | grep $SERVER_PID || echo "β Server process not found" | |
| shell: bash | |
| env: | |
| NODE_ENV: production | |
| NEXTAUTH_SECRET: 'test-secret-for-ci-only' | |
| NEXT_PUBLIC_EXAMPLE_VARIABLE: 'CI Test Variable' | |
| PRIVATE_EXAMPLE_VARIABLE: 'Private CI Test Variable' | |
| - name: β³ Wait for Frontend to be Ready | |
| run: | | |
| echo "β³ Waiting for frontend to start on http://localhost:3000..." | |
| ATTEMPT=0 | |
| MAX_ATTEMPTS=20 | |
| until curl -f http://localhost:3000 > /dev/null 2>&1; do | |
| ATTEMPT=$((ATTEMPT + 1)) | |
| echo "π Attempt $ATTEMPT/$MAX_ATTEMPTS - waiting for frontend..." | |
| if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then | |
| echo "β Frontend failed to start after $MAX_ATTEMPTS attempts" | |
| echo "π Current processes:" | |
| ps aux | grep -E "(node|next)" | grep -v grep | |
| echo "π Checking port 3000:" | |
| netstat -tulpn | grep 3000 || echo "No process on port 3000" | |
| exit 1 | |
| fi | |
| sleep 3 | |
| done | |
| echo "β Frontend is ready!" | |
| shell: bash | |
| - name: π Detailed Health Check | |
| run: | | |
| echo "π₯ Running detailed health check..." | |
| echo "π‘ HTTP response:" | |
| curl -f http://localhost:3000 -I | head -10 | |
| echo "" | |
| echo "π Basic page content:" | |
| curl -s http://localhost:3000 | head -20 | |
| echo "" | |
| echo "π Testing login page:" | |
| curl -s http://localhost:3000/login | head -10 || echo "β Login page not accessible" | |
| echo "" | |
| echo "β Health check completed!" | |
| shell: bash | |
| - name: π§ͺ Run Playwright E2E Tests | |
| run: | | |
| echo "π¬ Starting Playwright E2E Tests..." | |
| echo "================================================" | |
| pnpm e2e | |
| echo "================================================" | |
| echo "β E2E Tests completed!" | |
| - name: π Stop Frontend App | |
| shell: bash | |
| if: always() | |
| run: | | |
| if [ ! -z "$FRONTEND_PID" ]; then | |
| kill $FRONTEND_PID || true | |
| fi |