ci: cache the apt packages Playwright installs for Chromium

Merged
KD
1mo ago
+85-5

What and why

  • playwright-core install chromium --with-deps downloads the same 38.2 MB of .deb files (17 upgrades, 9 new font packages) from the Ubuntu mirror in every job.
  • In 38 of 84 recent spec jobs, the mirror served them at about 200 kB/s. The step took 118-302 s instead of 14-45 s. Example from one job log: Fetched 38.2 MB in 3min 13s (198 kB/s), against Fetched 38.2 MB in 5s (8481 kB/s) in a fast job.
  • The spec gate waits for its slowest job. 13 of 14 recent spec runs had at least one slow install job.
  • The new .github/actions/chromium composite action does these steps:
    1. It points apt's archive directory at /var/cache/chromium-apt (Dir::Cache::Archives). The runner owns the directory, so the cache can restore into it. partial belongs to _apt:root with mode 0700, like /var/cache/apt/archives/partial. The runner's temp directory did not work: _apt cannot traverse /home/runner, so apt downloaded as root (W: Download is performed unsandboxed as root).
    2. It restores the newest cache entry for the Ubuntu release, architecture, and Playwright version.
    3. It runs the same install --with-deps command, so apt downloads only the packages whose version changed.
    4. It runs apt-get autoclean to remove versions that the mirror no longer serves.
    5. It saves the archives under a digest of their file names, but only when the set changed.
  • The installed packages do not change, so rendering and screenshot baselines do not change.
  • All five install steps use the action: spec check and test, both benchmark jobs, and the weekly agent job. The web path filter in .github/filters.yml lists the action.

Issue

No matching issue. This is a CI time optimization.

Verified

Ran it locally: no - CI-only change; the restore, root apt install, and save run only on Actions runners.

  • apt archive reuse, checked without root through apt-get install -d with the same Dir::Cache::Archives setting: an empty directory gave Need to get 14.7 MB of archives., and a filled directory gave Need to get 0 B/14.7 MB of archives.
  • apt-get autoclean kept the file-name digest the same for current archives and deleted a planted archive whose version the mirror does not serve.
  • actionlint 1.7.7 passed on spec.yml, benchmark.yml, and agent.yml, with the unknown Blacksmith runner label warnings ignored.
  • CI on the first commit (d552754d), with the archives in $RUNNER_TEMP/chromium-apt:
    • The check job missed the cache, downloaded 38.2 MB, and saved chromium-apt-ubuntu-24.04-x86_64-playwright-1.64.1-c46104d3e234d6a2. The other spec jobs that missed got Unable to reserve cache, as expected.
    • The later web job restored that entry and logged Need to get 0 B/38.2 MB of archives.
    • The check job also logged W: Download is performed unsandboxed as root. 006e60e8 fixes this by moving the archives to /var/cache/chromium-apt.
  • CI at 006e60e8, with the archives in /var/cache/chromium-apt:
    • The benchmark web job missed the cache, downloaded 38.2 MB, and saved the same key. The unsandboxed as root warning was gone.
    • On a rerun, all 6 spec jobs and both benchmark jobs restored the entry and logged Need to get 0 B/38.2 MB of archives. The save step was skipped because the key did not change.
    • Install step per job: min 11 s, median 13.5 s, p75 16 s, max 19 s over 16 jobs. Before this change, 84 jobs gave min 14 s, median 27 s, p75 167 s, max 302 s. The table is in the PR comment.
    • The mirror was fast during these runs, so I did not see a slow-mirror job on this branch.
  • A cache that a PR branch saves is visible only to that branch. After merge, a push to main saves the cache that every pull request can restore.

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.

AI assistance and human review

AI was used to prepare these changes. Human-reviewed by @kdy1.

  • Harness: Claude Code
  • Model: claude-opus-5-5

šŸ¤– Generated with Claude Code