Skip to content

Commit 2eb5eda

Browse files
authored
add chromatic and publish the storybook (#1609)
Chromatic allows us to visually review UI changes: https://www.chromatic.com/builds?appId=69ccd5e5ca68b9aa5a54b890 --------- Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
1 parent f47e3db commit 2eb5eda

File tree

3 files changed

+86
-29
lines changed

3 files changed

+86
-29
lines changed

.github/workflows/ci.yaml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,16 @@ jobs:
182182
183183
ui-tests:
184184
runs-on: ubuntu-latest
185+
env:
186+
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
187+
permissions:
188+
contents: read
189+
pull-requests: write
185190
steps:
186191
- name: Checkout repository
187192
uses: actions/checkout@v6
193+
with:
194+
fetch-depth: 0
188195

189196
- name: Setup Node.js
190197
uses: actions/setup-node@v6
@@ -203,10 +210,31 @@ jobs:
203210
working-directory: ./ui
204211
run: npm run lint
205212

206-
- name: Run tests
213+
- name: Run unit tests (Jest)
207214
working-directory: ./ui
208215
run: npm run test
209216

217+
- name: Install Playwright browser (Chromium)
218+
working-directory: ./ui
219+
run: npx playwright install --with-deps chromium
220+
221+
- name: Run Storybook tests (Vitest + Playwright)
222+
working-directory: ./ui
223+
run: npm run test:vitest
224+
225+
- name: Build Storybook
226+
working-directory: ./ui
227+
run: npm run build-storybook
228+
229+
- name: Publish to Chromatic
230+
# Requires repo secret CHROMATIC_PROJECT_TOKEN. Skipped when unset, or on fork PRs (no token access).
231+
if: ${{ env.CHROMATIC_PROJECT_TOKEN != '' && (github.event.pull_request == null || github.event.pull_request.head.repo.full_name == github.repository) }}
232+
uses: chromaui/action@v16.0.0
233+
with:
234+
projectToken: ${{ env.CHROMATIC_PROJECT_TOKEN }}
235+
workingDir: ui
236+
storybookBuildDir: storybook-static
237+
210238
# This job builds the Docker images for the controller, UI, app, and CLI on arm64.
211239
build:
212240
needs: setup

ui/package-lock.json

Lines changed: 53 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
"start": "next start",
99
"lint": "eslint .",
1010
"test": "jest",
11+
"test:vitest": "vitest run",
1112
"test:watch": "jest --watch",
1213
"test:e2e:cypress": "cypress run --e2e",
1314
"test:e2e": "start-server-and-test dev http://localhost:8001 test:e2e:cypress",
1415
"storybook": "storybook dev -p 6006",
15-
"build-storybook": "storybook build"
16+
"build-storybook": "storybook build",
17+
"chromatic": "chromatic --exit-zero-on-changes"
1618
},
1719
"dependencies": {
1820
"@a2a-js/sdk": "^0.3.13",
@@ -82,6 +84,7 @@
8284
"@vitest/coverage-v8": "^4.1.2",
8385
"autoprefixer": "^10.4.23",
8486
"babel-plugin-react-compiler": "^1.0.0",
87+
"chromatic": "^16.0.0",
8588
"cypress": "^15.13.0",
8689
"eslint": "^9.39.2",
8790
"eslint-config-next": "16.2.1",

0 commit comments

Comments
 (0)