Cache Playwright browser downloads in CI - #3
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
e2ejob downloads roughly 350 MB of browser builds on every push and pull request, entirely uncached.cache: pnpmdoesn't cover them — the browsers live in~/.cache/ms-playwright, outside the pnpm store.The install command is deliberately unchanged
playwright installstays 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.yamlhash, exact-match, norestore-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.codesbefore 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
actionlintandyamllintclean. This PR's own run is a guaranteed cache miss.🤖 Generated with Claude Code
https://claude.ai/code/session_01SRgQmnzeh3vsVKudXWs3RV