Skip to content

Cache Playwright browser downloads in CI - #3

Merged
RISCfuture merged 1 commit into
mainfrom
ci/cache-playwright-browsers
Sep 1, 2026
Merged

Cache Playwright browser downloads in CI#3
RISCfuture merged 1 commit into
mainfrom
ci/cache-playwright-browsers

Conversation

@RISCfuture

Copy link
Copy Markdown
Contributor

The e2e job downloads roughly 350 MB of browser builds on every push and pull request, entirely uncached. cache: pnpm doesn't cover them — the browsers live in ~/.cache/ms-playwright, outside the pnpm store.

The install command is deliberately unchanged

playwright install stays exactly as it was. It skips browser revisions already present, so a warm cache makes it cheap — and it must keep running to install the apt system libraries, which the cache does not cover. Conditionalising it on a cache hit would break E2E precisely when the cache works.

Key design

Keyed on the pnpm-lock.yaml hash, exact-match, no restore-keys.

Version-keying was considered and rejected: extraction from the lockfile is feasible, but a silent parse failure after a future pnpm format change would yield a constant key and serve wrong-version browsers forever. Lockfile churn busts the hash key often enough (~25–40% of commits across these repos) that it still hits on most runs, at zero staleness risk.

Where a repo has two jobs installing different browser sets, they get different keys. Sharing would be a bug: keys are immutable, so whichever job saved first would claim the key, and a job needing more browsers would restore a partial cache, re-download the rest, then fail to re-save — a permanently partial entry paying restore cost forever.

Measured on the canary

Validated on RISCfuture/tim.codes before rollout. The cached entry is 467 MiB — larger than estimated, and entirely separate from the 141 MiB pnpm store, confirming the premise. E2E went 2m13s → 1m39s (26% faster) on the warm run, with the hit confirmed in the log.

Note

actionlint and yamllint clean. This PR's own run is a guaranteed cache miss.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SRgQmnzeh3vsVKudXWs3RV

The e2e job downloaded roughly 350 MB of browser builds on every push and
pull request. `cache: pnpm` does not cover them: the browsers live in
~/.cache/ms-playwright, outside the pnpm store.

The `playwright install` command is left exactly as it was. It skips
browser revisions already present, so a warm cache makes it cheap, and it
must keep running to install the apt system libraries the cache does not
cover -- conditionalising it on a cache hit would break e2e precisely
when the cache works.

Keyed on the lockfile hash rather than an extracted Playwright version: a
silent parse failure after a future lockfile format change would pin one
entry forever and serve wrong-version browsers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SRgQmnzeh3vsVKudXWs3RV
@RISCfuture
RISCfuture merged commit dc4ef3a into main Sep 1, 2026
3 checks passed
@RISCfuture
RISCfuture deleted the ci/cache-playwright-browsers branch September 1, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant