Skip to content

ci: cache Playwright browser binaries across desktop CI jobs#483

Merged
wesbillman merged 3 commits intomainfrom
ci/cache-apt-and-playwright
May 5, 2026
Merged

ci: cache Playwright browser binaries across desktop CI jobs#483
wesbillman merged 3 commits intomainfrom
ci/cache-apt-and-playwright

Conversation

@wesbillman
Copy link
Copy Markdown
Collaborator

Summary

  • Adds actions/cache for Playwright Chromium binaries in the desktop and desktop-e2e-integration CI jobs
  • On cache hit, the ~180MB browser download from Playwright CDN is skipped entirely, eliminating the primary source of CI slowness when the CDN is congested (observed 9+ minutes in slow runs vs ~8 seconds normally)
  • Splits playwright install --with-deps chromium into conditional install (only on cache miss) + unconditional install-deps (system packages needed every run on fresh runners)
  • Keys cache on exact Playwright version extracted at runtime to avoid over-invalidation from unrelated lockfile changes

Details

Problem: The desktop and desktop-e2e-integration jobs download Playwright browser binaries from scratch every run. When the Playwright CDN is slow, this balloons from ~8 seconds to ~9 minutes. Combined with slow apt mirrors, total job time can go from 5 min to 23 min.

Solution: Cache the Playwright Chromium binary (~180MB) using actions/cache. The cache key is based on the exact Playwright version (extracted from @playwright/test/package.json at runtime), so it only invalidates when Playwright is actually bumped.

What stays the same: System dependencies (playwright install-deps chromium) run unconditionally on every run because each GitHub Actions runner is a fresh VM. Apt caching was evaluated and intentionally excluded — the complexity/risk outweighs the benefit given the existing retry/timeout configuration.

Changes:

  1. Set PLAYWRIGHT_BROWSERS_PATH at workflow level for reliable cache path resolution
  2. Add "Get Playwright version" step to extract version for cache key
  3. Add actions/cache step (pinned to SHA, v4.3.0) before Playwright install
  4. Make playwright install chromium conditional on cache miss
  5. Keep playwright install-deps chromium unconditional

Test plan

  • CI passes on this PR (the desktop and desktop-e2e-integration jobs exercise the new steps)
  • First run should populate the cache (cache miss, normal download)
  • Subsequent runs with same Playwright version should show cache hit and skip Chromium download
  • Bumping Playwright version in desktop/package.json should trigger cache miss

🤖 Generated with Claude Code

Adds actions/cache for Playwright Chromium binaries in the desktop and
desktop-e2e-integration jobs. On cache hit, the ~180MB browser download
from Playwright CDN is skipped entirely, eliminating the primary source
of CI slowness when the CDN is congested (observed 9+ minutes in slow runs).

- Set PLAYWRIGHT_BROWSERS_PATH to a workspace-relative path for reliable
  cache key resolution
- Key on exact Playwright version (extracted at runtime) to avoid
  over-invalidation from unrelated lockfile changes
- Split `playwright install --with-deps` into conditional `install` (only
  on cache miss) + unconditional `install-deps` (system packages needed
  every run on fresh runners)
- Pin actions/cache to SHA (v4.3.0)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread .github/workflows/ci.yml Fixed
Comment thread .github/workflows/ci.yml Fixed
wesbillman and others added 2 commits May 5, 2026 12:19
Split actions/cache into actions/cache/restore (read-only, all events) +
actions/cache/save (write, push events only). This prevents pull requests
from writing to the cache, addressing the cache poisoning attack vector
flagged by zizmor.

PRs still benefit from reading cached Playwright browsers populated by
push-to-main runs. Cache saves only happen on push events when the cache
key is new (miss).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wesbillman wesbillman enabled auto-merge (squash) May 5, 2026 19:53
@wesbillman wesbillman merged commit 6216f64 into main May 5, 2026
14 checks passed
@wesbillman wesbillman deleted the ci/cache-apt-and-playwright branch May 5, 2026 19:59
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.

2 participants