Skip to content

Commit 2b9a487

Browse files
committed
ci: add caching for snapshots
1 parent ad847ec commit 2b9a487

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

.github/workflows/nodejs.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ on:
1212
- next
1313
- v4
1414

15+
workflow_call:
16+
inputs:
17+
update-snapshots:
18+
description: "Update snapshots?"
19+
type: boolean
20+
21+
workflow_dispatch:
22+
inputs:
23+
update-snapshots:
24+
description: "Update snapshots?"
25+
type: boolean
26+
1527
permissions:
1628
contents: read
1729

@@ -97,9 +109,6 @@ jobs:
97109
node ./scripts/prepare-test-for-old-node.js
98110
if: matrix.node-version == '18.x'
99111

100-
- name: Install Playwright browsers and dependencies
101-
run: npx playwright install --with-deps
102-
103112
- name: Link webpack-dev-server
104113
run: |
105114
cp -R client tmp-client
@@ -116,6 +125,21 @@ jobs:
116125
run: npm run test:coverage -- --ci --shard=${{ matrix.shard }}
117126
if: matrix.node-version != '18.x'
118127

128+
- name: Install Playwright browsers and dependencies
129+
run: npx playwright install --with-deps
130+
131+
- name: Set up cache
132+
id: cache
133+
uses: actions/cache@v4
134+
with:
135+
key: cache/${{github.repository}}/${{github.ref}}
136+
restore-keys: cache/${{github.repository}}/refs/heads/master
137+
path: .test/**
138+
139+
- name: Initialize snapshots
140+
if: ${{steps.cache.outputs.cache-hit != 'true' || inputs.update-snapshots == 'true'}}
141+
run: npx playwright test --update-snapshots
142+
119143
- name: Run E2E tests for webpack version ${{ matrix.webpack-version }}
120144
run: npm run test:e2e -- --ignore-snapshots
121145

playwright.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
module.exports = {
44
testIgnore: "**/*.ignore.*",
55
testDir: "./test/e2e",
6+
outputDir: ".test/spec/output",
7+
snapshotPathTemplate:
8+
".test/spec/snaps/{projectName}/{testFilePath}/{arg}{ext}",
69
fullyParallel: false,
710
forbidOnly: process.env.CI !== "true",
811
retries: process.env.CI ? 2 : 0,

0 commit comments

Comments
 (0)