Skip to content

Commit 93f3127

Browse files
authored
ci: key the browser cache on the Playwright version alone (#182)
* ci: key the browser cache on the Playwright version alone Hashing the whole version catalog meant any dependency bump paid the 60s cold browser install; the key now uses the Playwright version itself, so the cache only invalidates when the browsers actually change. Also answers the old inline comment wondering whether a smarter key exists. * ci: fix the canary's browser cache key too The canary still carried the original key on reference-app/ build.gradle.kts — the earlier chromium-only change silently missed it because its text differed — so it kept the stale-cache bug: a Playwright bump would restore old browsers that PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD then refuses to replace. Now keyed on the Playwright version like the CI workflow.
1 parent 72870f0 commit 93f3127

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

.github/workflows/gradle.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@ jobs:
2828
distribution: 'temurin'
2929
- name: Set up Gradle
3030
uses: gradle/actions/setup-gradle@v6
31+
# Key the browser cache on the Playwright version alone so unrelated dependency
32+
# bumps in the catalog do not trigger a browser reinstall.
33+
- name: Resolve Playwright version
34+
id: playwright-version
35+
run: echo "version=$(grep -m1 '^playwright = ' gradle/libs.versions.toml | cut -d'"' -f2)" >> "$GITHUB_OUTPUT"
3136
- name: Setup ms-playwright cache
3237
id: setup-ms-playwright-cache
3338
uses: actions/cache@v6
3439
with:
3540
# Some dependencies are downloaded to this directory
3641
path: /home/runner/.cache/ms-playwright
37-
# There probably is a smarter way to create this key but this should be ok for now.
38-
key: ms-playwright-chromium-${{ runner.os }}-${{ hashFiles('gradle/libs.versions.toml') }}
42+
key: ms-playwright-chromium-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
3943
- name: Install Playwright Dependencies
4044
if: steps.setup-ms-playwright-cache.outputs.cache-hit != 'true'
4145
# Chromium only — the only browser the tests use; one Gradle invocation.

.github/workflows/upstream-canary.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,17 @@ jobs:
6262
distribution: 'temurin'
6363
- name: Set up Gradle
6464
uses: gradle/actions/setup-gradle@v6
65+
# Key the browser cache on the Playwright version alone so unrelated dependency
66+
# bumps do not trigger a browser reinstall.
67+
- name: Resolve Playwright version
68+
id: playwright-version
69+
run: echo "version=$(grep -m1 '^playwright = ' gradle/libs.versions.toml | cut -d'"' -f2)" >> "$GITHUB_OUTPUT"
6570
- name: Setup ms-playwright cache
6671
id: setup-ms-playwright-cache
6772
uses: actions/cache@v6
6873
with:
6974
path: /home/runner/.cache/ms-playwright
70-
key: ms-playwright-cache-${{ runner.os }}-${{ hashFiles('reference-app/build.gradle.kts') }}
75+
key: ms-playwright-chromium-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
7176
- name: Install Playwright Dependencies
7277
if: steps.setup-ms-playwright-cache.outputs.cache-hit != 'true'
7378
# Chromium only — the only browser the tests use; one Gradle invocation.

0 commit comments

Comments
 (0)