|
| 1 | +# Playwright end-to-end tests for the BOxCrete website. |
| 2 | +# Runs on PRs that touch the website or the test specs themselves. |
| 3 | +# See test/e2e/README.md for the catalogue of invariants and how to add new tests. |
| 4 | + |
| 5 | +name: E2E (Playwright) |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: [main] |
| 10 | + paths: |
| 11 | + - 'docs/**' |
| 12 | + - 'test/e2e/**' |
| 13 | + - 'playwright.config.ts' |
| 14 | + - 'package.json' |
| 15 | + - '.github/workflows/e2e.yml' |
| 16 | + pull_request: |
| 17 | + branches: [main] |
| 18 | + paths: |
| 19 | + - 'docs/**' |
| 20 | + - 'test/e2e/**' |
| 21 | + - 'playwright.config.ts' |
| 22 | + - 'package.json' |
| 23 | + - '.github/workflows/e2e.yml' |
| 24 | + workflow_dispatch: |
| 25 | + inputs: |
| 26 | + update_snapshots: |
| 27 | + description: 'Regenerate visual snapshots and upload as an artifact' |
| 28 | + required: false |
| 29 | + default: 'false' |
| 30 | + |
| 31 | +# Restrict GITHUB_TOKEN to read-only on repo contents. |
| 32 | +permissions: |
| 33 | + contents: read |
| 34 | + |
| 35 | +env: |
| 36 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 37 | + |
| 38 | +jobs: |
| 39 | + e2e: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + timeout-minutes: 20 |
| 42 | + |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + project: [desktop, mobile] |
| 47 | + |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - uses: actions/setup-node@v4 |
| 52 | + with: |
| 53 | + node-version: '20' |
| 54 | + cache: 'npm' |
| 55 | + |
| 56 | + - name: Install dependencies |
| 57 | + run: npm ci |
| 58 | + |
| 59 | + - name: Cache Playwright browsers |
| 60 | + id: pw-cache |
| 61 | + uses: actions/cache@v4 |
| 62 | + with: |
| 63 | + path: ~/.cache/ms-playwright |
| 64 | + key: playwright-${{ runner.os }}-${{ hashFiles('package-lock.json') }} |
| 65 | + |
| 66 | + - name: Install Playwright browsers |
| 67 | + if: steps.pw-cache.outputs.cache-hit != 'true' |
| 68 | + run: npx playwright install --with-deps chromium |
| 69 | + |
| 70 | + - name: Install Chromium system deps (cached browsers path) |
| 71 | + if: steps.pw-cache.outputs.cache-hit == 'true' |
| 72 | + run: npx playwright install-deps chromium |
| 73 | + |
| 74 | + - name: Run Playwright tests |
| 75 | + run: npx playwright test --project=${{ matrix.project }} |
| 76 | + env: |
| 77 | + CI: true |
| 78 | + |
| 79 | + - name: Update snapshots (manual dispatch only) |
| 80 | + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.update_snapshots == 'true' }} |
| 81 | + run: npx playwright test --project=${{ matrix.project }} --update-snapshots |
| 82 | + env: |
| 83 | + CI: true |
| 84 | + |
| 85 | + - name: Upload Playwright report on failure |
| 86 | + if: failure() |
| 87 | + uses: actions/upload-artifact@v4 |
| 88 | + with: |
| 89 | + name: playwright-report-${{ matrix.project }} |
| 90 | + path: | |
| 91 | + playwright-report/ |
| 92 | + test-results/ |
| 93 | + retention-days: 14 |
| 94 | + |
| 95 | + - name: Upload regenerated snapshots |
| 96 | + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.update_snapshots == 'true' }} |
| 97 | + uses: actions/upload-artifact@v4 |
| 98 | + with: |
| 99 | + name: snapshots-${{ matrix.project }} |
| 100 | + path: test/e2e/**/*-snapshots/** |
| 101 | + retention-days: 30 |
0 commit comments