Repository navigation
ci(playwright): keep a main-scoped apt-deps cache warm for merge-queue runs - #31718
Conversation
…e runs The cache-hit gate on `install-deps` (PR #31691) works — but only when the cache hits, and in the merge queue it never does. GitHub Actions cache scoping restricts a run to caches created on its own ref or on the default branch. Merge-queue refs are unique per queue entry and deleted after the run, so an apt cache populated during a merge_group run is unreachable by every other queue entry: cache-apt-pkgs_1a177b42... ref=gh-readonly-queue/main/pr-31632-... cache-apt-pkgs_1a177b42... ref=gh-readonly-queue/main/pr-31700-... cache-apt-pkgs_1a177b42... ref=gh-readonly-queue/main/pr-31537-... No main-scoped copy of `playwright-chromium-deps-v2` exists, so every merge-queue shard misses, attempts a mirror-dependent populate, and the whole matrix goes red whenever Azure's Ubuntu mirror has a bad day (runs 32157314266, 32166970973, 32209207109 — all shards dead in setup with zero tests executed). The old fonts-only v1 key worked in the queue precisely because nightly scheduled runs on main had saved a main-scoped copy; v2 never got that chance. Add a dedicated 2-minute workflow that populates the same key from main's scope: * schedule (6h) — keeps the cache warm across GitHub's 7-day-unused eviction and 10 GB LRU pressure, and re-saves within 6 h whenever a runner-image roll shifts resolved package versions (which changes the action's computed key). * workflow_dispatch — immediate first populate, or recovery after an eviction mid-incident. * push to main touching playwright-e2e-reusable.yml (or this file) — a package-list or version-key change repopulates the new key immediately instead of leaving a ≤6 h window of queue-wide misses. Package list and `version:` are byte-identical to both "Cache Playwright system deps" steps in playwright-e2e-reusable.yml (verified programmatically: 28 packages, playwright-chromium-deps-v2, both call sites). The header comment pins the invariant: update both files together, since a drifted list populates a key nobody restores. Co-Authored-By: Claude Fable 5 <[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 ✅ ApprovedAdds a dedicated scheduled workflow to maintain a main-scoped Playwright apt-dependencies cache, resolving merge-queue cache misses and mirroring 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 👍 / 👎 | Powered by Gitar — free for open source |
| libatspi2.0-0t64 libcairo2 libcups2t64 libgbm1 libglib2.0-0t64 | ||
| libnspr4 libnss3 libpango-1.0-0 libx11-6 libxcb1 libxcomposite1 | ||
| libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 | ||
| version: playwright-chromium-deps-v2 |
There was a problem hiding this comment.
The static cache version does not encode the ubuntu-latest image, so an image transition retains the existing key and the scheduled job restores the old entry rather than populating packages for the new image. This defeats the stated automatic recovery from runner-image changes and can leave Playwright jobs using stale or incompatible apt files.
| timeout-minutes: 15 | ||
| steps: | ||
| - name: Populate Playwright system deps cache | ||
| uses: awalsh128/[email protected] |
There was a problem hiding this comment.
Mutable action in recurring workflow
The scheduled, push, and manual triggers execute cache-apt-pkgs-action through the mutable v1.5.1 tag. Retargeting that tag changes the code executed every six hours without a repository diff and gives it access to the runner and main-scoped cache token; pin this reference to the action's full commit SHA.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
✅ Playwright Results — workflow succeededValidated commit ✅ 551 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 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 29s ⏱️ Max setup 4m 20s · max shard execution 17m 39s · max shard-job elapsed before upload 20m 35s · reporting 5s 🌐 217.14 requests/attempt · 2.83 app boots/UI scenario · 17.47% common-shard skew Optimization targets still in progress:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
…etry (#31730) Run 32222855561's plan-playwright died on a single upstream blip: error https://registry.yarnpkg.com/regenerator-runtime/-/regenerator- runtime-0.14.1.tgz: Request failed "502 Bad Gateway" Two defects compounded: 1. setup-node's built-in `cache: yarn` is exact-key only. The queue batch changed yarn.lock, the key missed with no fallback ("yarn cache is not found"), and yarn cold-fetched all ~2000 tarballs from the registry — maximizing the surface for any single 5xx. yarn v1 does not retry HTTP errors on tarball downloads, so one 502 killed the whole plan job and ejected the queue entry. 2. No retry anywhere around `yarn install`, the last infra dependency in the playwright pipeline without one (docker pulls retry since #30826; apt is cached + gated since #31691/#31718). Fixes, applied to all four install call sites (plan-playwright, prepare-playwright-fixture, playwright-ci, slack-notify): * Replace setup-node's cache with an explicit actions/cache on ~/.cache/yarn keyed on the lockfile hash WITH a restore-keys fallback. A lockfile change now restores the previous cache and yarn fetches only the delta — a handful of tarballs instead of the world. * Wrap `yarn --ignore-scripts --frozen-lockfile` in a 3-attempt retry (15 s / 30 s backoff, `--network-timeout 100000`). The idiom is verified safe under the runner's `bash -e`. Also in plan-playwright: mark the two browser-cache seeding steps `continue-on-error`. They exist to populate the run-scoped browser cache once for all downstream shards (not for `--list`, which never launches a browser) — a seeding failure should degrade to shards self-installing, not fail planning. Comment updated to document the seeding role explicitly. `id: setup-node` / `id: install-dependencies` outcome wiring in the shard job is preserved. Follow-up (separate PR): cache the discovery output itself (playwright-test-list.json keyed on the playwright tree + config + mode flags) so plan-playwright skips install + discovery entirely on the hot path. Co-authored-by: Claude Fable 5 <[email protected]>
…ies survivable (#31746) * ci(playwright): break the cache-eviction death spiral + make apt retries survivable Diagnosis of runs 32223093113 and 32233411840 exposed three compounding defects that no amount of per-symptom patching was going to fix: 1. CACHE-EVICTION DEATH SPIRAL. The repo cache store measured 17.5 GB against a 10 GB LRU budget, with 49 of 50 caches on ephemeral refs (merge-queue branches, PR merge refs). The explicit yarn cache from #31730 was the biggest single source — on an ephemeral ref the exact key can never pre-exist, so every job saved a fresh ~700 MB duplicate (9 copies = 6.4 GB observed) even when restore-keys had restored content perfectly. Those saves evicted every main-scoped cache within ~30 minutes of creation (the #31718 apt cache created 06:15 was gone before 06:49), which turned downstream "cache hits" into cold fetches against apt mirrors / registry.yarnpkg.com / the Playwright CDN — and a bad day on any of those took the whole matrix down. More misses meant more ephemeral saves, feeding back into more eviction. Fix: every yarn and browser cache step in the reusable workflow is now RESTORE-ONLY (actions/cache/restore@v5) — ephemeral refs never save. The one writer is populate-playwright-apt-cache.yml, which runs on main and now warms all three caches (yarn, browser, apt), on the 6 h schedule, on dispatch, and on pushes to main touching yarn.lock / .nvmrc / the workflows. The plan job's run-scoped browser seeder is deliberately kept save-capable for lockfile-change entries; once eviction stops it no-ops on hit. Projected steady state ~6-8 GB, under budget, no evictions. 2. USELESS INSTALL RETRY. `timeout --signal=TERM ... npx playwright install-deps` only signals the direct child; the underlying apt-get survives and keeps holding /var/lib/apt/lists/lock. Run 32233411840 showed the exact sequence: apt had failed over from the dead Azure mirror to archive.ubuntu.com and was slowly succeeding, the 8-minute ceiling killed the wrapper mid-download, and the retry then died instantly on "Could not get lock ... held by process 15226". The same stale lock can be left by a timed-out cache-apt-pkgs action earlier in the job. Fix: a reap_apt() helper (killall -9 apt/apt-get/dpkg, remove stale lock files, dpkg --configure -a) runs BEFORE the first attempt and between attempts at both install-deps call sites. The shard job's single-attempt install gains the same one-retry loop the fixture builder already had. This adopts the diagnosis from PR #31737 at the location where it can actually work — the stale lock is created by our own timed-out first attempt, so clearing locks before the cache action (as #31737 does) runs too early to help. 3. POPULATE WORKFLOW TOO NARROW. It only warmed the apt cache; the yarn and browser caches had no main-scoped writer at all, so their first miss on any ephemeral ref started the duplicate-save churn. Verified: YAML valid on both files; all 6 yarn/browser cache steps in the reusable workflow audited restore-only; the reap+retry idiom tested under bash -e; the plan-job seeder confirmed retained. Co-Authored-By: Claude Fable 5 <[email protected]> * address greptile P1 — make the cache warmers independent The populate job ran its warmers sequentially with fail-fast semantics: a yarn-registry outage surviving all three retries (or a Chromium CDN failure) killed the job BEFORE the apt writer ran — blocking the refresh of the one cache whose absence takes down whole matrices, which is exactly the failure this workflow exists to prevent. Restructured: * apt populate runs FIRST (no node/yarn dependency) and continue-on-error, so nothing can starve it and its own failure cannot starve the others. * yarn and browser warmers are continue-on-error with explicit restore/save pairs; each save is gated on its warmer SUCCEEDING. The gating also fixes a latent bug a bare continue-on-error would have introduced: actions/cache's post-job save runs when the job succeeds, so a failed yarn install would have permanently baked a partial ~/.cache/yarn under the exact lockfile key (actions/cache never overwrites an existing key). * the browser warmer is additionally gated on the yarn warmer succeeding — npx resolves the pinned @playwright/test from the local install. * a final "Report warm failures" step fails the job if ANY warmer failed — full signal on schedule/dispatch, but only after every cache had its chance to refresh. Verified: YAML valid; apt package list + version still byte-identical to both reusable-workflow call sites; yarn/browser keys match the restore-only steps. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]>
Summary
The cache-hit gate on
install-deps(#31691) works — but only when the cache hits, and in the merge queue it never does.Root cause — GitHub Actions cache scoping
A workflow run can only restore caches created on its own ref or on the default branch. Merge-queue refs (
gh-readonly-queue/main/pr-N-sha) are unique per queue entry and deleted after the run. Live evidence from the caches API:Every
playwright-chromium-deps-v2cache is queue-ref-scoped; no main-scoped copy exists. So every merge-queue shard misses, attempts a mirror-dependent populate, and the whole matrix goes red whenever Azure's Ubuntu mirror has a bad day (runs 32157314266, 32166970973, 32209207109 — all shards dead in setup, zero tests executed).The old fonts-only v1 key worked in the queue precisely because nightly scheduled runs execute on main and had saved a main-scoped copy. v2 shipped yesterday and never got that chance.
Change
One new 2-minute workflow that populates the same key from main's scope:
schedule(every 6 h)workflow_dispatchpushto main touchingplaywright-e2e-reusable.ymlor this fileParity guarantee
Package list and
version:are byte-identical to bothCache Playwright system depssteps inplaywright-e2e-reusable.yml— verified programmatically (28 packages,playwright-chromium-deps-v2, both call sites match). The header comment pins the invariant: update both files together, since a drifted list populates a key nobody restores.Follow-up (not blocking): extract the shared list into a composite action so it exists in exactly one place.
Test plan
workflow_dispatchthis workflow once → confirm acache-apt-pkgs_*cache appears withref=refs/heads/mainin the caches API.Cache Playwright system depsstep logs a cache hit, andInstall Playwright Browserscompletes in ~1-5 s (the ci(playwright): make env blocking gate actually cover install-deps #31691 gate skip path).Related: #31691 (cache-hit gate), #30847 (original apt cache).
🤖 Generated with Claude Code
Greptile Summary
This PR adds a main-scoped scheduled workflow that populates the Playwright Chromium apt-dependency cache for merge-queue and PR jobs.
main.Confidence Score: 4/5
The PR appears safe to merge, with non-blocking hardening needed around runner-image cache invalidation and immutable action pinning.
The workflow should populate the same key restored by the Playwright jobs, but image transitions can retain stale cache contents and the recurring job allows a third-party tag to change executable code without a repository update.
Files Needing Attention: .github/workflows/populate-playwright-apt-cache.yml
Security Review
The recurring trusted-branch workflow invokes a mutable third-party action tag. Pinning the action to a full commit SHA prevents publisher-side tag changes from altering code executed by scheduled runs. The scheduled, push, and manual triggers all reach the
@v1.5.1reference at line 59.Important Files Changed
Reviews (1): Last reviewed commit: "ci(playwright): keep a main-scoped apt-d..." | Re-trigger Greptile