Playwright setup + E2E Testing #11
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: Run E2e Tests | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| env: | |
| PROJECT_ID: 'benefit-decision-toolkit-play' | |
| WORKLOAD_IDENTITY_PROVIDER: 'projects/1034049717668/locations/global/workloadIdentityPools/github-actions-google-cloud/providers/github' | |
| jobs: | |
| run-e2e-tests: | |
| runs-on: 'ubuntu-latest' | |
| # Add these permissions for Workload Identity Federation | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| # Devbox Setup # | |
| - name: 'Create .env file' # Devbox needs a .env file to exist, even if it's empty | |
| run: touch .env | |
| - name: Rename env files | |
| run: | | |
| mv builder-frontend/.env.example builder-frontend/.env | |
| mv builder-api/.env.example e2e/.env | |
| - name: 'Install devbox' # Setup devbox which includes Node.js, Firebase CLI, and Google Cloud SDK | |
| uses: 'jetify-com/[email protected]' | |
| with: | |
| enable-cache: true | |
| - id: 'auth' # Configure Workload Identity Federation and generate an access token | |
| name: 'Authenticate to Google Cloud' | |
| uses: 'google-github-actions/auth@v2' | |
| with: | |
| workload_identity_provider: '${{ env.WORKLOAD_IDENTITY_PROVIDER }}' | |
| service_account: cicd-build-deploy-api@benefit-decision-toolkit-play.iam.gserviceaccount.com | |
| project_id: ${{ env.PROJECT_ID }} | |
| - name: Install Devbox Stuff | |
| run: | | |
| devbox install | |
| devbox add process-compose | |
| continue-on-error: true | |
| - name: Cache node modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: builder-frontend/node_modules | |
| key: ${{ runner.os }}-node-${{ hashFiles('builder-frontend/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| - name: Install frontend dependencies | |
| working-directory: builder-frontend | |
| run: devbox run install-builder-frontend-ci | |
| - name: Run all Devbox services | |
| run: devbox run devbox services up -b | |
| continue-on-error: true | |
| - uses: nev7n/wait_for_response@v1 | |
| with: | |
| url: 'http://localhost:5173/' | |
| responseCode: 200 | |
| timeout: 180000 | |
| interval: 1000 | |
| # E2E Testing # | |
| - name: Install dependencies | |
| run: npm ci | |
| working-directory: e2e | |
| - name: Install Playwright Browsers | |
| run: npx playwright install --with-deps | |
| working-directory: e2e | |
| - name: Run Playwright tests | |
| run: npx playwright test | |
| working-directory: e2e | |
| - uses: actions/upload-artifact@v4 | |
| if: ${{ !cancelled() }} | |
| with: | |
| name: playwright-report | |
| path: e2e/playwright-report/ | |
| retention-days: 30 | |
| # Devbox Cleanup # | |
| - name: Stop all Devbox services | |
| run: devbox services stop | |
| continue-on-error: true |