Skip to content

Commit 83bc41f

Browse files
committed
Workflow: Add cache to playwright
1 parent 86b8633 commit 83bc41f

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

.github/workflows/playwright.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,27 @@ jobs:
2424
with:
2525
hugo-version: '0.147.8'
2626
extended: true
27-
- name: Install dependencies and playwright browsers
28-
run: cd tests && npm ci && npx playwright install --with-deps
27+
- name: Check playwright version
28+
id: check-playwright-version
29+
run: |
30+
version=$(npm list @playwright/test --json | jq -r '.dependencies["@playwright/test"].version')
31+
echo "version=$version" >> $GITHUB_OUTPUT
32+
echo "Version:" $version
33+
- name: Attempt to restore cache
34+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
35+
id: restore-cache
36+
with:
37+
# By default this path is hardcoded by OS - https://playwright.dev/python/docs/browsers#managing-browser-binaries
38+
path: '~/.cache/ms-playwright'
39+
key: '${{ runner.os }}-playwright-${{ steps.check-playwright-version.outputs.version }}'
40+
# Fallback, if version changed, use the most recent cached version.
41+
restore-keys: |
42+
${{ runner.os }}-playwright-
43+
- name: Install dependencies
44+
run: cd tests && npm ci
45+
- name: Install playwright dependecies
46+
if: steps.restore-cache.outputs.cache-hit != 'true'
47+
run: npx playwright install --with-deps
2948
- name: Run Playwright tests
3049
id: test-ui
3150
run: |

0 commit comments

Comments
 (0)