Skip to content

Commit 17d21da

Browse files
committed
Workflow: Add cache to playwright
1 parent 86b8633 commit 17d21da

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

.github/workflows/playwright.yml

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

0 commit comments

Comments
 (0)