Repository navigation
ci(playwright): cache Chromium apt deps to skip the mirror fetch per shard - #30847
Conversation
…shard Every shard job (and the fixture builder on cache miss) runs `npx playwright install-deps chromium`, which apt-fetches ~21 MB of font packages from the Ubuntu Azure mirror. Two problems: 1. It repeats on every shard even though the package list only changes on Playwright version bumps. 2. When the Azure mirror hiccups, a single shard can crawl for many minutes on the download. chromium-18 in run 30788758311 hit 40 kB/s for 8m 45s, pushing its shard-job elapsed to 33.5 min and tripping the 30-min `shardsAtMostThirtyMinutesBeforeUpload` gate. Add `awalsh128/cache-apt-pkgs-action` before each `install-deps` call. On cache hit the action extracts the previously-installed files directly (/usr/share/fonts, /var/cache/fontconfig, dpkg state) — the subsequent `install-deps` sees every package as already-installed and skips fetching from the mirror. On cache miss (Playwright version bump) the action installs the same packages via apt as today and captures the result for next time. `install-deps` is deliberately kept as a safety net so a future Playwright version that adds a new dep doesn't silently miss it — the cache action only lists the packages we've seen it install today. `continue-on-error: true` on the cache action means a caching failure never blocks the shard — worst case we fall through to today's behavior (fresh apt fetch). Applied to both call sites: - fixture builder (line 795, runs only on fixture cache miss) - shard job (line 1056, runs on every chromium/basic/etc shard) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
Code Review ✅ ApprovedCaches Chromium apt dependencies in Playwright CI workflows to skip mirror fetches per shard and prevent timeout failures. No issues found. OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar | Powered by Gitar — free for open source |
There was a problem hiding this comment.
Pull request overview
This PR improves Playwright E2E CI stability and shard performance by avoiding repeated apt mirror downloads for Playwright’s Chromium system dependencies (fonts/xfonts), which have caused shard slowdowns and time-gate failures.
Changes:
- Adds an apt package cache restore step before
npx playwright install-deps chromiumin the fixture-builder path (only when the fixture cache is missed). - Adds the same apt package cache restore step before
npx playwright install-deps chromiumin every shard job so shard runs skip repeated mirror fetches.
Suppressed comments (1)
.github/workflows/playwright-postgresql-e2e.yml:1075
awalsh128/cache-apt-pkgs-actionis a third-party action and is currently pinned to a mutable tag (v1.5.1). For supply-chain safety, pin it to the immutable commit SHA (the rest of this workflow already pins third-party actions by SHA, e.g.tj-actions/changed-files@...).
uses: awalsh128/[email protected]
|
|
||
| # Restore Playwright's Chromium system deps (fonts + xfonts) from the | ||
| # GH Actions cache before install-deps runs. On cache hit the action | ||
| # extracts the previously-installed files (~/usr/share/fonts and |
| # bump that adds a new dep does not silently miss it. | ||
| - name: Cache Playwright system deps | ||
| if: ${{ needs.restore-playwright-fixture.outputs.fixture_cache_hit != 'true' || (needs.plan-playwright.outputs.requires_airflow == 'true' && needs.restore-playwright-fixture.outputs.ingestion_cache_hit != 'true') }} | ||
| uses: awalsh128/[email protected] |
✅ Playwright Results — workflow succeededValidated commit ✅ 549 passed · ❌ 0 failed · 🟡 1 flaky · ⏭️ 3 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 1h 0m 41s ⏱️ Max setup 3m 1s · max shard execution 18m 46s · max shard-job elapsed before upload 23m 4s · reporting 6s 🌐 201.44 requests/attempt · 2.83 app boots/UI scenario · 7.73% common-shard skew Optimization targets still in progress:
🟡 1 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
…shard (open-metadata#30847) Every shard job (and the fixture builder on cache miss) runs `npx playwright install-deps chromium`, which apt-fetches ~21 MB of font packages from the Ubuntu Azure mirror. Two problems: 1. It repeats on every shard even though the package list only changes on Playwright version bumps. 2. When the Azure mirror hiccups, a single shard can crawl for many minutes on the download. chromium-18 in run 30788758311 hit 40 kB/s for 8m 45s, pushing its shard-job elapsed to 33.5 min and tripping the 30-min `shardsAtMostThirtyMinutesBeforeUpload` gate. Add `awalsh128/cache-apt-pkgs-action` before each `install-deps` call. On cache hit the action extracts the previously-installed files directly (/usr/share/fonts, /var/cache/fontconfig, dpkg state) — the subsequent `install-deps` sees every package as already-installed and skips fetching from the mirror. On cache miss (Playwright version bump) the action installs the same packages via apt as today and captures the result for next time. `install-deps` is deliberately kept as a safety net so a future Playwright version that adds a new dep doesn't silently miss it — the cache action only lists the packages we've seen it install today. `continue-on-error: true` on the cache action means a caching failure never blocks the shard — worst case we fall through to today's behavior (fresh apt fetch). Applied to both call sites: - fixture builder (line 795, runs only on fixture cache miss) - shard job (line 1056, runs on every chromium/basic/etc shard) Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Every shard job (and the fixture builder on cache miss) runs
npx playwright install-deps chromium, which apt-fetches ~21 MB of font packages from the Ubuntu Azure mirror. Two problems today:shardsAtMostThirtyMinutesBeforeUploadgate.Change
Add
awalsh128/[email protected]before eachinstall-depscall, at both spots:On cache hit (99% of runs)
The action extracts the previously-installed files (
/usr/share/fonts,/var/cache/fontconfig, dpkg state) directly from GH Actions cache. The subsequentinstall-depssees every package as already-installed and skips the mirror fetch entirely (~1-2 s no-op).On cache miss (Playwright version bumps only)
The action installs the same packages via apt as today, then bundles the result into the cache for next time. Same net cost as today, plus a small tar-and-upload overhead.
Design notes
install-depsdeliberately kept as a safety net. If a Playwright version bump adds a new dep our hardcoded package list doesn't know about,install-depswill still catch it — we only miss the cache speedup for the newly-added package on the next few runs, and the failure mode is graceful (fetch fresh, don't fail).continue-on-error: trueon the cache action means any caching failure never blocks the shard — worst case we fall through to today's behavior.version: playwright-chromium-deps-v1in the cache key lets us bust the cache manually (bump to v2) if the package list needs to change.v1.5.1. Matches the repo's convention of pinning by tag (not SHA) alongsideactions/*deps.awalsh128/cache-apt-pkgs-actionis widely used and stable.Expected impact
Per-shard:
install-depsstep drops from ~30 s (happy path) → ~2 s. On a bad-mirror day: shards that would have crawled to 33 min stay near their normal ~25 min wall.Aggregate across a 20-shard merge_queue run: saves ~10 min of accumulated runner minutes on the happy path, and eliminates the mirror-slowness class of failure entirely.
Test plan
Cache Playwright system depsstep succeeding (miss on the first run, hit thereafter).install-depsruns but reports 0 packages newly installed.install-depsstep drops to ~2 s across all shards.Related: #30826 (docker pull retry — same shape of infra-resilience change).
🤖 Generated with Claude Code