Skip to content

Commit 37ca8a6

Browse files
authored
ci(e2e): cache Playwright browser downloads (#1326)
## Summary Caches Playwright browser downloads for end-to-end CI. Cache keys include the Playwright version and the runner's architecture, hosted environment, and Linux distribution, so incompatible runner families cannot share browser archives. Cache misses keep the full Chromium and WebKit install. Cache hits reuse the browsers and install only the required system packages. Co-authored-by: Matthew Jacobs <mjacobs@users.noreply.github.com>
1 parent 446da68 commit 37ca8a6

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,40 @@ jobs:
358358
env:
359359
CGO_ENABLED: "1"
360360

361+
- name: Resolve Playwright version
362+
id: playwright-version
363+
run: |
364+
version=$(node -p "require('./package-lock.json').packages['node_modules/@playwright/test'].version")
365+
echo "version=$version" >> "$GITHUB_OUTPUT"
366+
working-directory: frontend
367+
368+
- name: Resolve Playwright runner platform
369+
id: playwright-platform
370+
run: |
371+
. /etc/os-release
372+
echo "linux-distribution=${ID:-unknown}-${VERSION_ID:-unknown}" >> "$GITHUB_OUTPUT"
373+
374+
- name: Cache Playwright browsers
375+
id: playwright-cache
376+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
377+
with:
378+
path: ~/.cache/ms-playwright
379+
key: playwright-browsers-${{ runner.os }}-${{ runner.arch }}-${{ runner.environment }}-${{ steps.playwright-platform.outputs.linux-distribution }}-${{ steps.playwright-version.outputs.version }}
380+
361381
- name: Install Playwright browsers
382+
if: steps.playwright-cache.outputs.cache-hit != 'true'
362383
run: npx playwright install --with-deps chromium webkit
363384
working-directory: frontend
364385

386+
# Cache hit: browser binaries are already present, but the runner
387+
# image itself isn't guaranteed to have the OS packages Playwright
388+
# needs (e.g. after a fresh self-hosted runner or an ubuntu-latest
389+
# image bump), so make sure those are still installed.
390+
- name: Install Playwright system dependencies
391+
if: steps.playwright-cache.outputs.cache-hit == 'true'
392+
run: npx playwright install-deps chromium webkit
393+
working-directory: frontend
394+
365395
- name: Run E2E tests
366396
run: npx playwright test --reporter=list
367397
working-directory: frontend

0 commit comments

Comments
 (0)