Skip to content

ci(playwright): keep a main-scoped apt-deps cache warm for merge-queue runs - #31718

Merged
chirag-madlani merged 1 commit into
mainfrom
ci/populate-playwright-apt-cache
Aug 19, 2026
Merged

chirag-madlani merged 1 commit into
mainfrom
ci/populate-playwright-apt-cache

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Aug 19, 2026 •

Copy link
Copy Markdown
Collaborator

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:

cache-apt-pkgs_1a177b42…  ref=refs/heads/gh-readonly-queue/main/pr-31632-…
cache-apt-pkgs_1a177b42…  ref=refs/heads/gh-readonly-queue/main/pr-31700-…
cache-apt-pkgs_1a177b42…  ref=refs/heads/gh-readonly-queue/main/pr-31537-…

Every playwright-chromium-deps-v2 cache 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:

Trigger Purpose
schedule (every 6 h) Keeps the cache warm across GitHub's 7-day-unused eviction / 10 GB LRU pressure; re-saves within 6 h when a runner-image roll shifts resolved package versions (which changes the action's computed key)
workflow_dispatch Immediate first populate; recovery after mid-incident eviction
push to main touching playwright-e2e-reusable.yml or this file A package-list / version-key change repopulates immediately instead of leaving a ≤6 h queue-wide miss window

Parity guarantee

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 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

  • YAML validated locally.
  • Package/version parity with the reusable workflow verified programmatically.
  • After merge: workflow_dispatch this workflow once → confirm a cache-apt-pkgs_* cache appears with ref=refs/heads/main in the caches API.
  • Next merge_group run: every shard's Cache Playwright system deps step logs a cache hit, and Install Playwright Browsers completes 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.

  • Runs every six hours, on manual dispatch, and when either relevant workflow changes on main.
  • Uses the same package list and explicit cache version as both Playwright restore sites.
  • The cache key does not account for runner-image changes, and the recurring third-party action remains referenced through a mutable tag.

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.1 reference at line 59.

Important Files Changed

Filename Overview
.github/workflows/populate-playwright-apt-cache.yml Adds the main-scoped apt-cache population workflow with matching restore inputs, but its static key does not isolate runner-image generations and its third-party action reference is mutable.

Reviews (1): Last reviewed commit: "ci(playwright): keep a main-scoped apt-d..." | Re-trigger Greptile

Greptile also left 2 inline comments on this PR.

…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]>
Copilot AI lite review requested due to automatic review settings August 19, 2026 04:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Aug 19, 2026
@gitar-bot

gitar-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Adds a dedicated scheduled workflow to maintain a main-scoped Playwright apt-dependencies cache, resolving merge-queue cache misses and mirroring failures. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Runner image missing from key

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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 security 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!

@github-actions

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 74eb2ed54cdff519bb43c0cd0bedfbc84ce917c7 in Playwright run 32216415875, attempt 1.

✅ 551 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking 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:

  • Common shard skew was 17.47% (convergence target: at most 15%).
  • Browser traffic was 217.14 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.83 per UI scenario (1618 boots / 572 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 128 0 0 0 0 0
✅ Shard chromium-02 141 0 0 0 0 0
✅ Shard chromium-03 130 0 0 0 0 0
✅ Shard data-asset-rules-01 61 0 0 0 0 0
✅ Shard domain-isolation-01 14 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@chirag-madlani
chirag-madlani merged commit 9c4cad5 into main Aug 19, 2026
90 of 92 checks passed
@chirag-madlani
chirag-madlani deleted the ci/populate-playwright-apt-cache branch August 19, 2026 06:15
chirag-madlani added a commit that referenced this pull request Aug 19, 2026
…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]>
chirag-madlani added a commit that referenced this pull request Aug 19, 2026
…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]>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants