Skip to content

Commit d82bda3

Browse files
[ci] Cache Chrome binary across CI runs for Browser Run tests
Browser Run tests in `packages/miniflare/test/plugins/browser/index.spec.ts` and the `fixtures/browser-run` fixture call into `@puppeteer/browsers` to ensure Chrome is downloaded into the global Wrangler cache. Every CI run currently re-downloads ~150 MB of Chrome from scratch because the cache directory is per-runner-instance and not shared between runs. Add an `actions/cache@v4` step keyed on the OS + the Chrome version hardcoded in `packages/miniflare/src/index.ts` (`126.0.6478.182")`, restoring/saving `~/.cache/.wrangler/chrome` (Linux), `~/Library/Caches/.wrangler/chrome` (macOS), and `~/AppData/Local/xdg.cache/.wrangler/chrome` (Windows). Benefits: - Cuts ~150 MB and the associated download time off cold CI runs. - Reduces the surface area for the intermittent partial-extraction race that surfaces as `The browser folder (...) exists but the executable (...) is missing` (see #13971 for the diagnostic that exposed this, #13980 for the in-process recovery layer). When the cache is warm and the binary is already extracted, this race can't fire at all because `install()` short-circuits. The cache step runs for the `packages-and-tools` suite on all three OSes and for the `fixtures` suite on macOS + Windows (the Browser Run fixture is excluded on Ubuntu because of AppArmor). When the Chrome version in `packages/miniflare/src/index.ts` changes, the cache key here needs to be bumped manually. A miss only triggers a fresh download — no functional impact.
1 parent 9c4569f commit d82bda3

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

.github/workflows/test-and-check.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,32 @@ jobs:
136136
env:
137137
GITHUB_TOKEN: ${{ github.token }}
138138

139+
# Browser Run tests in `packages/miniflare/test/plugins/browser/index.spec.ts`
140+
# and the `fixtures/browser-run` fixture use `@puppeteer/browsers` to
141+
# download Chrome into the global Wrangler cache. Caching that binary
142+
# across CI runs avoids ~150 MB of repeat downloads per run and reduces
143+
# the surface area for the intermittent partial-extraction race that
144+
# surfaces as `The browser folder (...) exists but the executable (...)
145+
# is missing` (see #13971, #13980).
146+
#
147+
# The Browser Run fixture is skipped on Ubuntu (AppArmor), but the
148+
# miniflare browser spec runs everywhere, so the cache is needed on all
149+
# three OSes for `packages-and-tools` and on Windows + macOS for
150+
# `fixtures`.
151+
- name: Restore Chrome browser cache (Browser Run)
152+
if: steps.changes.outputs.everything_but_markdown == 'true' && (matrix.suite == 'packages-and-tools' || (matrix.suite == 'fixtures' && matrix.os != 'ubuntu-latest'))
153+
uses: actions/cache@v4
154+
with:
155+
# The Chrome version is hardcoded in `packages/miniflare/src/index.ts`
156+
# (search for `browserVersion:`). Bump this key when that version
157+
# changes — a cache miss only triggers a fresh download, no
158+
# functional impact.
159+
key: chrome-${{ runner.os }}-126.0.6478.182
160+
path: |
161+
~/.cache/.wrangler/chrome
162+
~/Library/Caches/.wrangler/chrome
163+
~/AppData/Local/xdg.cache/.wrangler/chrome
164+
139165
- name: Run tests (tools only)
140166
# tools _only_ needs to be tested on Linux because they're only intended to run in CI
141167
if: steps.changes.outputs.everything_but_markdown == 'true' && matrix.suite == 'packages-and-tools' && matrix.os == 'ubuntu-latest'

0 commit comments

Comments
 (0)