]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Test] Cache Playwright browsers correctly
authorAlexander Moisseev <moiseev@mezonplus.ru>
Fri, 31 Jul 2026 14:10:02 +0000 (17:10 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Fri, 31 Jul 2026 14:10:02 +0000 (17:10 +0300)
The browser cache key had no version pin, so the 'latest' matrix leg
restored stale browsers forever (the key is never rewritten on a hit)
and browsers were re-downloaded every run. Pin the 'legacy' key to the
Playwright version; roll the 'latest' key weekly (ISO year-week) with a
prefix restore-key so newest revisions are still pulled regularly while
the cache stays effective within a week. Both legs keep running on
every PR/push; npx playwright install stays as-is (idempotent, skips
already-cached browsers).

.github/workflows/ci_webui_e2e_playwright.yml

index 4fb7c3fb9382eb14c57352ad55d05e9bb88617e1..dcd10e0f2134172ba9ad98e06c86da948a9dc464 100644 (file)
@@ -102,11 +102,28 @@ jobs:
         with:
           node-version: ${{ matrix.node-version || 'lts/*' }}
 
+      - name: Determine browser cache key
+        id: browsers-key
+        run: |
+          # 'latest' is a moving target: roll the key weekly (ISO year-week) so the
+          # newest Playwright/browser revisions are re-fetched regularly, while still
+          # benefiting from the cache within a week. 'legacy' is pinned => stable key.
+          if [ "${{ matrix.label }}" = "latest" ]; then
+            echo "key=browsers-latest-${{ runner.os }}-$(date -u +%G-W%V)" >> "$GITHUB_OUTPUT"
+          else
+            echo "key=browsers-legacy-${{ matrix.version }}-${{ runner.os }}" >> "$GITHUB_OUTPUT"
+          fi
+
       - name: Cache Playwright browsers
+        id: playwright-cache
         uses: actions/cache@v4
         with:
           path: .cache/ms-playwright-${{ matrix.label }}
-          key: browsers-${{ matrix.label }}-${{ runner.os }}
+          key: ${{ steps.browsers-key.outputs.key }}
+          # Warm-restore the most recent matching cache when the key rolls (esp. 'latest'
+          # across weeks), so only changed browser revisions are re-downloaded.
+          restore-keys: |
+            browsers-${{ matrix.label }}-${{ runner.os }}-
 
       - id: run-playwright
         name: Run Playwright tests (${{ matrix.label }})