Skip to content

Cache Playwright browsers in CI to avoid redundant downloads#298

Open
AndyTWF wants to merge 1 commit intomainfrom
fix-playwright-browser-caching
Open

Cache Playwright browsers in CI to avoid redundant downloads#298
AndyTWF wants to merge 1 commit intomainfrom
fix-playwright-browser-caching

Conversation

@AndyTWF
Copy link
Copy Markdown
Contributor

@AndyTWF AndyTWF commented Apr 8, 2026

Summary

  • Cache Playwright browser binaries using actions/cache@v4 keyed on Playwright version and OS
  • On cache hit, skip browser download (~30-60s) and only install system-level apt dependencies via playwright install-deps
  • On cache miss, do the full playwright install --with-deps as before
  • Applied to both e2e-tests.yml (1 job) and e2e-web-cli-parallel.yml (5 jobs sharing the same cache key)

Why

Playwright browsers were downloaded fresh on every CI run. In the parallel web CLI workflow, this happened 5 times per run. Caching eliminates redundant downloads, speeds up CI, and reduces flakiness from download failures.

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cli-web-cli Ready Ready Preview, Comment Apr 8, 2026 11:10pm

Request Review

@AndyTWF AndyTWF marked this pull request as ready for review April 8, 2026 23:09
Playwright browser binaries were being downloaded fresh on every CI run —
5 times in the parallel web CLI workflow alone. This adds actions/cache@v4
keyed on the Playwright version and OS. On cache hit, only system-level
apt dependencies are installed (skipping the ~30-60s browser download).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@AndyTWF AndyTWF force-pushed the fix-playwright-browser-caching branch from b394f00 to 7609957 Compare April 8, 2026 23:09
@AndyTWF AndyTWF requested a review from umair-ably April 8, 2026 23:09
@claude-code-ably-assistant
Copy link
Copy Markdown

Walkthrough

This PR adds Playwright browser caching to the CI workflows to avoid redundant browser downloads on every run. It applies the same cache-then-conditional-install pattern to both e2e-tests.yml and e2e-web-cli-parallel.yml, using actions/cache@v4 keyed on Playwright version and OS. The parallel web CLI workflow benefits most — previously 5 jobs each downloaded browsers independently; now they share a single cache entry.

Changes

Area Files Summary
Config .github/workflows/e2e-tests.yml Added Playwright version detection, cache step, and conditional install/install-deps steps (1 job)
Config .github/workflows/e2e-web-cli-parallel.yml Same caching pattern applied to all 5 parallel test jobs

Review Notes

  • Cache key design: Keyed on runner.os + Playwright version string (from pnpm exec playwright --version). This is correct — the cache will automatically invalidate when the Playwright version changes.
  • On cache hit: Only playwright install-deps is run (installs system-level apt dependencies, not the browser binaries). This is the right approach since apt deps aren't cached.
  • On cache miss: Falls back to playwright install --with-deps as before — no behavioral change for cold runs.
  • e2e-tests.yml installs all browsers (playwright install --with-deps without a browser arg); e2e-web-cli-parallel.yml installs only chromium. Both are consistent before and after this change.
  • No source code, test logic, or dependency changes — purely CI infrastructure.

🤖 Generated with Claude Code

Copy link
Copy Markdown

@claude-code-ably-assistant claude-code-ably-assistant bot left a comment

Choose a reason for hiding this comment

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

Review: Cache Playwright browsers in CI

This PR only modifies GitHub Actions workflow files — no TypeScript source, commands, or tests were changed, so the CLI command review checklist doesn't apply.

Summary

File Status Notes
.github/workflows/e2e-tests.yml OK Caching added correctly to the single job
.github/workflows/e2e-web-cli-parallel.yml OK Caching added to all 5 jobs; setup seeds cache, test jobs restore it

Logic review

The pattern used is the canonical approach for Playwright browser caching:

  1. Capture Playwright version → use as cache key
  2. Restore ~/.cache/ms-playwright from cache
  3. On miss: playwright install --with-deps (downloads browsers + installs system deps)
  4. On hit: playwright install-deps (only installs system deps, browsers already present)

This is correct. The setup job in e2e-web-cli-parallel.yml runs first and writes the cache; the four downstream test jobs (auth-tests, session-tests, ui-tests, rate-limit-test) all restore from the same key — so only the setup job bears the download cost after the first run.

One observation (not a blocker)

pnpm exec playwright --version outputs Version 1.48.0 (with the Version prefix). The resulting cache key is playwright-Linux-Version 1.48.0 — note the space and capital V. GitHub Actions does allow spaces in cache keys (the docs only prohibit commas), so this won't break anything. If you want a cleaner key you could strip the prefix with pnpm exec playwright --version | sed 's/Version //', but it's not necessary.

Overall

Correct, clean, and well-structured. The setup job seeding the cache for all parallel test runners is the right architecture here. Good to merge.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant