Skip to content

Commit d9748bb

Browse files
Merge pull request #75 from open-formulieren/chore/5133-add-chromatic
Add Chromatic visual regression tests to CI pipeline
2 parents e5062d2 + 925a154 commit d9748bb

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

.github/workflows/ci.yml

+43-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- opened
1414
- reopened
1515
- synchronize
16-
# - ready_for_review relevant for chromatic, at some point
16+
- ready_for_review
1717
workflow_dispatch:
1818

1919
concurrency:
@@ -35,6 +35,7 @@ jobs:
3535
- name: Build Storybook docs
3636
run: |
3737
npm ci
38+
npm run compilemessages
3839
npm run build-storybook --quiet
3940
4041
- name: Upload artifact
@@ -58,6 +59,7 @@ jobs:
5859

5960
- name: Build library
6061
run: |
62+
npm run compilemessages
6163
npm run build:typecheck
6264
npm run build
6365
@@ -97,7 +99,7 @@ jobs:
9799
cache: npm
98100

99101
- name: Install dependencies
100-
run: npm install
102+
run: npm ci
101103

102104
- name: Run tests
103105
run: |
@@ -117,12 +119,13 @@ jobs:
117119
cache: npm
118120

119121
- name: Install dependencies
120-
run: npm install
122+
run: npm ci
121123

122124
# Reference: https://storybook.js.org/docs/6.5/react/writing-tests/test-runner#run-against-non-deployed-storybooks
123125
- name: Set up test environment
124126
run: |
125127
npx playwright install --with-deps
128+
npm run compilemessages
126129
127130
- name: Download storybook artifact
128131
uses: actions/download-artifact@v4
@@ -165,6 +168,43 @@ jobs:
165168
id: deployment
166169
uses: actions/deploy-pages@v4
167170

171+
chromatic:
172+
name: Visual regression test with Chromatic
173+
runs-on: ubuntu-latest
174+
needs:
175+
- storybook
176+
177+
# do not run in forks
178+
if: github.event_name == 'push' || ! github.event.pull_request.head.repo.fork
179+
180+
steps:
181+
- name: Checkout repository
182+
uses: actions/checkout@v4
183+
with:
184+
fetch-depth: 0 # 👈 Required to retrieve git history
185+
186+
- name: Download build artifact
187+
uses: actions/download-artifact@v4
188+
with:
189+
name: github-pages
190+
path: ./storybook-static
191+
192+
- name: Extract artifact
193+
run: |
194+
tar -xvf artifact.tar
195+
rm artifact.tar
196+
working-directory: ./storybook-static
197+
198+
- name: Publish to Chromatic for visual regression tests
199+
uses: chromaui/action@latest
200+
if: github.event.pull_request.draft == false || github.event.push
201+
with:
202+
autoAcceptChanges: main
203+
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
204+
storybookBuildDir: ./storybook-static
205+
onlyChanged: true
206+
externals: 'src/img/**'
207+
168208
publish:
169209
name: Publish the NPM package
170210
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)