fix(e2e): remove restore-keys to prevent stale browser cache

- Removed restore-keys fallback from Playwright cache
- Only exact cache matches (same package-lock.json hash) are used
- This prevents restoring incompatible browser versions when Playwright updates
- Added cache-hit check to skip install when cache is valid
- Firefox and WebKit were failing because old cache was restored but browsers were incompatible
This commit is contained in:
GitHub Actions
2026-01-31 08:48:55 +00:00
parent 61324bd2ff
commit 13c22fea9a

View File

@@ -242,15 +242,25 @@ jobs:
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
with:
path: ~/.cache/ms-playwright
# Use exact match only - no restore-keys fallback
# This ensures we don't restore stale browsers when Playwright version changes
key: playwright-${{ matrix.browser }}-${{ hashFiles('package-lock.json') }}
restore-keys: playwright-${{ matrix.browser }}-
- name: Install Playwright browsers
run: |
# Always run install to ensure browsers match Playwright version
# The install command is idempotent - skips if already installed
npx playwright install --with-deps ${{ matrix.browser }}
echo "✅ Playwright ${{ matrix.browser }} installed"
# Force install if cache miss or version mismatch
if [[ "${{ steps.playwright-cache.outputs.cache-hit }}" != "true" ]]; then
echo "📥 Cache miss - downloading ${{ matrix.browser }} browser..."
npx playwright install --with-deps ${{ matrix.browser }}
else
echo "✅ Cache hit - verifying ${{ matrix.browser }} browser..."
# Verify the cached browser is valid by checking version
if ! npx playwright --version > /dev/null 2>&1; then
echo "⚠️ Cached browser appears invalid, reinstalling..."
npx playwright install --with-deps ${{ matrix.browser }}
fi
fi
echo "✅ Playwright ${{ matrix.browser }} ready"
- name: Run E2E tests (Shard ${{ matrix.shard }}/${{ matrix.total-shards }})
run: |