Skip to content

Commit e67e729

Browse files
authored
🤖 Add Chromatic for visual regression testing (#383)
1 parent 0a1aea1 commit e67e729

File tree

5 files changed

+56
-3
lines changed

5 files changed

+56
-3
lines changed

.github/workflows/chromatic.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Chromatic
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches: ["**"]
9+
10+
jobs:
11+
chromatic:
12+
name: Visual Regression Testing
13+
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
14+
# Skip for forked PRs since they don't have access to secrets
15+
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push'
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0 # Required for Chromatic to track changes
21+
22+
- uses: ./.github/actions/setup-cmux
23+
24+
- name: Generate version file
25+
run: ./scripts/generate-version.sh
26+
27+
- name: Build Storybook
28+
run: bun x storybook build --stats-json
29+
30+
- name: Run Chromatic
31+
uses: chromaui/action@latest
32+
with:
33+
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
34+
exitZeroOnChanges: true
35+
onlyChanged: true
36+

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ include fmt.mk
3838
.PHONY: test test-unit test-integration test-watch test-coverage test-e2e
3939
.PHONY: dist dist-mac dist-win dist-linux
4040
.PHONY: docs docs-build docs-watch
41-
.PHONY: storybook storybook-build test-storybook
41+
.PHONY: storybook storybook-build test-storybook chromatic
4242
.PHONY: benchmark-terminal
4343
.PHONY: ensure-deps
4444
.PHONY: check-eager-imports check-bundle-size check-startup
@@ -252,6 +252,9 @@ storybook-build: node_modules/.installed src/version.ts ## Build static Storyboo
252252
test-storybook: node_modules/.installed ## Run Storybook interaction tests (requires Storybook to be running or built)
253253
@bun x test-storybook
254254

255+
chromatic: node_modules/.installed ## Run Chromatic for visual regression testing
256+
@bun x chromatic --exit-zero-on-changes
257+
255258
## Benchmarks
256259
benchmark-terminal: ## Run Terminal-Bench with the cmux agent (use TB_DATASET/TB_SAMPLE_SIZE/TB_ARGS to customize)
257260
@TB_DATASET=$${TB_DATASET:-terminal-bench-core==0.1.1}; \

bun.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@typescript/native-preview": "^7.0.0-dev.20251014.1",
5959
"@vitejs/plugin-react": "^4.0.0",
6060
"babel-plugin-react-compiler": "^1.0.0",
61+
"chromatic": "^13.3.1",
6162
"cmdk": "^1.0.0",
6263
"concurrently": "^8.2.0",
6364
"dotenv": "^17.2.3",
@@ -1074,6 +1075,8 @@
10741075

10751076
"chownr": ["[email protected]", "", {}, "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ=="],
10761077

1078+
"chromatic": ["[email protected]", "", { "peerDependencies": { "@chromatic-com/cypress": "^0.*.* || ^1.0.0", "@chromatic-com/playwright": "^0.*.* || ^1.0.0" }, "optionalPeers": ["@chromatic-com/cypress", "@chromatic-com/playwright"], "bin": { "chroma": "dist/bin.js", "chromatic": "dist/bin.js", "chromatic-cli": "dist/bin.js" } }, "sha512-qJ/el70Wo7jFgiXPpuukqxCEc7IKiH/e8MjTzIF9uKw+3XZ6GghOTTLC7lGfeZtosiQBMkRlYet77tC4KKHUng=="],
1079+
10771080
"chromium-pickle-js": ["[email protected]", "", {}, "sha512-1R5Fho+jBq0DDydt+/vHWj5KJNJCKdARKOCwZUen84I5BreWoLqRLANH1U87eJy1tiASPtMnGqJJq0ZsLoRPOw=="],
10781081

10791082
"ci-info": ["[email protected]", "", {}, "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ=="],

chromatic.config.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"projectId": "68e30fca49979473fc9abc73",
3+
"buildScriptName": "storybook:build",
4+
"storybookBuildDir": "storybook-static",
5+
"exitZeroOnChanges": true,
6+
"exitOnceUploaded": true,
7+
"autoAcceptChanges": false
8+
}
9+

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"docs:watch": "make docs-watch",
4242
"storybook": "make storybook",
4343
"storybook:build": "make storybook-build",
44-
"test:storybook": "make test-storybook"
44+
"test:storybook": "make test-storybook",
45+
"chromatic": "make chromatic"
4546
},
4647
"dependencies": {
4748
"@ai-sdk/anthropic": "^2.0.29",
@@ -98,17 +99,18 @@
9899
"@typescript/native-preview": "^7.0.0-dev.20251014.1",
99100
"@vitejs/plugin-react": "^4.0.0",
100101
"babel-plugin-react-compiler": "^1.0.0",
102+
"chromatic": "^13.3.1",
101103
"cmdk": "^1.0.0",
102104
"concurrently": "^8.2.0",
103105
"dotenv": "^17.2.3",
104106
"electron": "^38.2.1",
105107
"electron-builder": "^24.6.0",
106108
"electron-devtools-installer": "^4.0.0",
107109
"electron-mock-ipc": "^0.3.12",
110+
"escape-html": "^1.0.3",
108111
"eslint": "^9.36.0",
109112
"eslint-plugin-react": "^7.37.5",
110113
"eslint-plugin-react-hooks": "^5.2.0",
111-
"escape-html": "^1.0.3",
112114
"jest": "^30.1.3",
113115
"mermaid": "^11.12.0",
114116
"playwright": "^1.56.0",

0 commit comments

Comments
 (0)