|
1 | 1 | --- |
2 | 2 | name: E2E |
3 | 3 |
|
4 | | -# Runs the Playwright end-to-end + mobile/responsive suite across Chromium, |
| 4 | +# Runs the Playwright end-to-end + mobile/responsive suite. To keep PR feedback |
| 5 | +# fast, pull requests run only the Chromium engine (desktop + emulated mobile); |
| 6 | +# pushes to main and manual runs exercise the full matrix across Chromium, |
5 | 7 | # Firefox and WebKit (desktop) plus emulated mobile devices. Unit/component |
6 | 8 | # tests (Vitest) run in the Pages workflow; this workflow focuses on real |
7 | 9 | # browser flows. See playwright.config.js for projects and the dev web server. |
@@ -49,20 +51,66 @@ jobs: |
49 | 51 | - name: Install dependencies |
50 | 52 | run: npm ci |
51 | 53 |
|
| 54 | + - name: Determine browser scope |
| 55 | + id: scope |
| 56 | + # PRs validate against the Chromium engine only (desktop + mobile-chrome) |
| 57 | + # for fast feedback; main / manual runs cover the full browser matrix. |
| 58 | + run: |- |
| 59 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 60 | + { |
| 61 | + echo "browsers=chromium" |
| 62 | + echo "projects=--project=chromium --project=mobile-chrome" |
| 63 | + echo "label=chromium" |
| 64 | + } >> "$GITHUB_OUTPUT" |
| 65 | + else |
| 66 | + { |
| 67 | + echo "browsers=chromium firefox webkit" |
| 68 | + echo "projects=" |
| 69 | + echo "label=all" |
| 70 | + } >> "$GITHUB_OUTPUT" |
| 71 | + fi |
| 72 | +
|
| 73 | + - name: Resolve Playwright version |
| 74 | + id: playwright-version |
| 75 | + # Key the cache on the resolved Playwright version (stable across |
| 76 | + # lockfile churn) rather than hashFiles(package-lock.json). |
| 77 | + run: |- |
| 78 | + version=$(node -p "require('./package-lock.json').packages['node_modules/@playwright/test'].version") |
| 79 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
| 80 | +
|
52 | 81 | - name: Cache Playwright browsers |
53 | 82 | id: playwright-cache |
54 | 83 | uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
55 | 84 | with: |
56 | 85 | path: ~/.cache/ms-playwright |
57 | | - key: playwright-${{ runner.os }}-${{ hashFiles('package-lock.json') }} |
58 | | - restore-keys: |- |
59 | | - playwright-${{ runner.os }}- |
| 86 | + key: >- |
| 87 | + playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}-${{ |
| 88 | + steps.scope.outputs.label }} |
60 | 89 |
|
61 | 90 | - name: Install Playwright browsers |
62 | | - run: npx playwright install --with-deps |
| 91 | + if: steps.playwright-cache.outputs.cache-hit != 'true' |
| 92 | + env: |
| 93 | + BROWSERS: ${{ steps.scope.outputs.browsers }} |
| 94 | + run: |- |
| 95 | + # shellcheck disable=SC2086 # intentional word splitting into args |
| 96 | + npx playwright install $BROWSERS --with-deps |
| 97 | +
|
| 98 | + - name: Install Playwright system dependencies |
| 99 | + # Browser binaries are cached, but apt system libraries are not persisted |
| 100 | + # across ephemeral runners, so refresh them on a cache hit. |
| 101 | + if: steps.playwright-cache.outputs.cache-hit == 'true' |
| 102 | + env: |
| 103 | + BROWSERS: ${{ steps.scope.outputs.browsers }} |
| 104 | + run: |- |
| 105 | + # shellcheck disable=SC2086 # intentional word splitting into args |
| 106 | + npx playwright install-deps $BROWSERS |
63 | 107 |
|
64 | 108 | - name: Run Playwright tests |
65 | | - run: npm run test:e2e |
| 109 | + env: |
| 110 | + PROJECTS: ${{ steps.scope.outputs.projects }} |
| 111 | + run: |- |
| 112 | + # shellcheck disable=SC2086 # intentional word splitting into args |
| 113 | + npm run test:e2e -- $PROJECTS |
66 | 114 |
|
67 | 115 | - name: Upload Playwright report |
68 | 116 | if: ${{ !cancelled() }} |
|
0 commit comments