mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-06 08:58:05 +00:00
ci: cache Playwright browsers keyed on @playwright/test version (#489)
The Playwright browser download (Chrome for Testing + Chrome Headless Shell + FFmpeg, ~170MB total) is the single largest cost in the start-app composite action. Observed in a recent E2E run: 4m15s to download cold vs ~10s on a warm cache. Across weekly cache evictions and the ~30% of runs that hit a cold cache, that is multiple action minutes per PR averaged over time, and several minutes of wall-time regression on any individual cold run. Split the existing `playwright install --with-deps chromium` step into two halves: 1. `playwright install-deps chromium` runs unconditionally because apt packages live under /var and are not preserved by actions/cache. This is fast (~10s). 2. `playwright install chromium` runs only when the browser cache under ~/.cache/ms-playwright misses. The cache key is pinned to the @playwright/test version read from the root package.json, so a future bump invalidates the cache automatically and the old browsers are replaced cleanly. Sharding (the other half of the original optimization plan) was evaluated and rejected. With ~80s of per-job setup and only ~60s of test time, 2-way sharding would roughly double action minutes while saving only ~5s of wall time on warm runs. The math only pencils out when test time significantly exceeds setup time, which is not the case for Sencho today. Revisit if the suite grows past ~5 minutes of pure test time.
This commit is contained in:
@@ -87,6 +87,33 @@ runs:
|
||||
shell: bash
|
||||
run: npx wait-on http://localhost:${{ inputs.port }}/api/health http://localhost:5173 --timeout 30000
|
||||
|
||||
- name: Install Playwright browsers
|
||||
# Playwright bundles Chrome for Testing (~170MB) and FFmpeg. Downloading
|
||||
# them on every E2E run is the single largest cost in this composite:
|
||||
# observed ~4m15s cold vs ~10s warm when the path is cached. Cache the
|
||||
# download under a key pinned to the @playwright/test version so a
|
||||
# future bump invalidates automatically.
|
||||
- name: Read Playwright version
|
||||
id: playwright-version
|
||||
shell: bash
|
||||
run: npx playwright install --with-deps chromium
|
||||
run: |
|
||||
version=$(node -p "require('./package.json').devDependencies['@playwright/test'].replace(/^[\^~]/, '')")
|
||||
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Cache Playwright browsers
|
||||
id: playwright-cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/ms-playwright
|
||||
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
|
||||
|
||||
# OS deps are apt packages under /var, which actions/cache does not
|
||||
# preserve, so they have to be reinstalled every run regardless of the
|
||||
# browser cache state. It is fast (~10s).
|
||||
- name: Install Playwright OS dependencies
|
||||
shell: bash
|
||||
run: npx playwright install-deps chromium
|
||||
|
||||
- name: Install Playwright browsers
|
||||
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: npx playwright install chromium
|
||||
|
||||
Reference in New Issue
Block a user