Skip to content

Commit aa992f9

Browse files
authored
ci: replace Chromatic with Pixel (#1041)
Swap visual regression testing from Chromatic to Pixel (pixel.coder.com), following the setup in coder/coder. The Pixel CI job installs Chromium, then pixel-storybook builds the Storybook (buildCommand in pixel.jsonc) and snapshots every story in the light and dark themes. Mainline builds auto-approve snapshots to avoid blocking CI after squash merges.
1 parent 1321a85 commit aa992f9

7 files changed

Lines changed: 284 additions & 177 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -81,49 +81,26 @@ jobs:
8181
run: ${{ runner.os == 'Linux' && 'xvfb-run -a' || '' }} pnpm test:integration --label "VS Code ${{ matrix.vscode-version }}"
8282
shell: bash
8383

84-
chromatic:
85-
name: Chromatic
84+
pixel:
85+
name: Pixel
8686
runs-on: ubuntu-24.04
87+
# Forks and Dependabot can't read the PIXEL_KEY secret.
88+
if: github.repository_owner == 'coder' && github.actor != 'dependabot[bot]'
8789
steps:
88-
- name: Checkout
89-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
90-
with:
91-
fetch-depth: 0
92-
ref: ${{ github.event.pull_request.head.ref }}
93-
persist-credentials: false
94-
90+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
9591
- name: Setup pnpm, Node.js, and dependencies
9692
uses: ./.github/actions/setup
9793

98-
# PR builds gate on visual review; mainline auto-accepts.
99-
- name: Publish to Chromatic (non-mainline)
100-
if: github.ref != 'refs/heads/main' && github.repository_owner == 'coder'
101-
uses: chromaui/action@4a45535b6910c0b99226ebcb7648faf88fb1ee2e # v18.0.1
102-
env:
103-
NODE_OPTIONS: "--max_old_space_size=4096"
104-
STORYBOOK: true
105-
with:
106-
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
107-
buildScriptName: "storybook:ci"
108-
exitOnceUploaded: true
109-
exitZeroOnChanges: true
110-
skip: "@(renovate/**|dependabot/**)"
111-
onlyChanged: true
112-
zip: true
113-
114-
# Auto-accept on mainline to avoid blocking CI after squash merges.
115-
- name: Publish to Chromatic (mainline)
116-
if: github.ref == 'refs/heads/main' && github.repository_owner == 'coder'
117-
uses: chromaui/action@4a45535b6910c0b99226ebcb7648faf88fb1ee2e # v18.0.1
94+
- name: Install Chromium
95+
run: pnpm exec playwright-core install --with-deps chromium
96+
97+
# Builds the Storybook (buildCommand in pixel.jsonc) and snapshots it.
98+
- name: Snapshot
99+
run: pnpm exec pixel-storybook
118100
env:
119-
NODE_OPTIONS: "--max_old_space_size=4096"
120-
STORYBOOK: true
121-
with:
122-
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
123-
autoAcceptChanges: true
124-
exitZeroOnChanges: true
125-
buildScriptName: "storybook:build"
126-
zip: true
101+
PIXEL_KEY: ${{ secrets.PIXEL_KEY }}
102+
# Auto-approve on mainline to avoid blocking CI after squash merges.
103+
PIXEL_AUTO_REVIEW: ${{ github.ref == 'refs/heads/main' }}
127104

128105
package:
129106
name: Package

.prettierrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"overrides": [
3+
{
4+
"files": "*.jsonc",
5+
"options": {
6+
"trailingComma": "none"
7+
}
8+
}
9+
]
10+
}

.storybook/preview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if (
4444

4545
// VS Code injects --vscode-font-family at runtime, but the upstream
4646
// vscode-elements theme data omits it. Set a static default so
47-
// Storybook (and Chromatic) renders with a predictable sans-serif
47+
// Storybook (and Pixel) renders with a predictable sans-serif
4848
// stack instead of falling back to the browser default (Times).
4949
const VSCODE_FONT_FAMILY =
5050
'"Segoe WPC", "Segoe UI", system-ui, "Ubuntu", "Droid Sans", sans-serif';

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"build": "concurrently -g -n webviews,extension,compile-tests:integration \"pnpm build:webviews\" \"node esbuild.mjs\" \"pnpm compile-tests:integration\"",
2222
"build:production": "cross-env NODE_ENV=production pnpm build",
2323
"build:webviews": "pnpm -r --filter \"./packages/*\" --parallel build",
24-
"chromatic": "chromatic",
2524
"compile-tests:integration": "tsc -p test/integration --outDir out --noCheck",
2625
"format": "prettier --write --cache --cache-strategy content .",
2726
"format:check": "prettier --check --cache --cache-strategy content .",
@@ -789,6 +788,7 @@
789788
"zod": "^4.4.3"
790789
},
791790
"devDependencies": {
791+
"@coder/pixel-storybook": "^0.2.1",
792792
"@eslint-react/eslint-plugin": "^5.11.3",
793793
"@eslint/js": "^10.0.1",
794794
"@eslint/markdown": "^8.0.3",
@@ -821,7 +821,6 @@
821821
"@vscode/vsce": "^3.9.2",
822822
"babel-plugin-react-compiler": "catalog:",
823823
"bufferutil": "^4.1.0",
824-
"chromatic": "^18.0.1",
825824
"coder": "catalog:",
826825
"concurrently": "^10.0.3",
827826
"cross-env": "^10.1.0",
@@ -838,6 +837,7 @@
838837
"jsdom": "^29.1.1",
839838
"jsonc-eslint-parser": "^3.1.0",
840839
"memfs": "^4.63.0",
840+
"playwright-core": "^1.61.1",
841841
"prettier": "^3.9.4",
842842
"react": "catalog:",
843843
"react-dom": "catalog:",

pixel.jsonc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"platformAccessUrl": "https://pixel.coder.com",
3+
"projectId": "019ed223-272f-7e3e-82fc-a8a135e5b4ca",
4+
"storybook": {
5+
"buildCommand": "pnpm storybook:ci"
6+
},
7+
"matrix": {
8+
// Values of the Storybook "theme" global, defined in
9+
// .storybook/preview.ts. Browsers and viewports stay at the default
10+
// since the webviews only ever render inside VS Code, which is
11+
// Chromium.
12+
"themes": ["light", "dark"]
13+
}
14+
}

0 commit comments

Comments
 (0)