diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 762907a8..973971d2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -77,6 +77,50 @@ jobs: run: ${{ runner.os == 'Linux' && 'xvfb-run -a' || '' }} pnpm test:integration --label "VS Code ${{ matrix.vscode-version }}" shell: bash + chromatic: + name: Chromatic + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + persist-credentials: false + + - name: Setup pnpm, Node.js, and dependencies + uses: ./.github/actions/setup + + # PR builds gate on visual review; mainline auto-accepts. + - name: Publish to Chromatic (non-mainline) + if: github.ref != 'refs/heads/main' && github.repository_owner == 'coder' + uses: chromaui/action@5c6ec06f45a2117a25f07b1bf2b2f3009233fac8 # v16.3.0 + env: + NODE_OPTIONS: "--max_old_space_size=4096" + STORYBOOK: true + with: + projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} + buildScriptName: "storybook:ci" + exitOnceUploaded: true + exitZeroOnChanges: true + skip: "@(renovate/**|dependabot/**)" + onlyChanged: true + zip: true + + # Auto-accept on mainline to avoid blocking CI after squash merges. + - name: Publish to Chromatic (mainline) + if: github.ref == 'refs/heads/main' && github.repository_owner == 'coder' + uses: chromaui/action@5c6ec06f45a2117a25f07b1bf2b2f3009233fac8 # v16.3.0 + env: + NODE_OPTIONS: "--max_old_space_size=4096" + STORYBOOK: true + with: + projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} + autoAcceptChanges: true + exitZeroOnChanges: true + buildScriptName: "storybook:build" + zip: true + package: name: Package runs-on: ubuntu-24.04 diff --git a/package.json b/package.json index 54d15887..1066eb9e 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "build": "concurrently -g -n webviews,extension,compile-tests:integration \"pnpm build:webviews\" \"node esbuild.mjs\" \"pnpm compile-tests:integration\"", "build:production": "cross-env NODE_ENV=production pnpm build", "build:webviews": "pnpm -r --filter \"./packages/*\" --parallel build", + "chromatic": "chromatic", "compile-tests:integration": "tsc -p test/integration --outDir out --noCheck", "format": "prettier --write --cache --cache-strategy content .", "format:check": "prettier --check --cache --cache-strategy content .", @@ -30,6 +31,7 @@ "package:prerelease": "pnpm build:production && vsce package --pre-release --no-dependencies", "storybook": "storybook dev -p 6006 --config-dir .storybook", "storybook:build": "storybook build --config-dir .storybook", + "storybook:ci": "storybook build --test --config-dir .storybook", "test": "cross-env CI=true ELECTRON_RUN_AS_NODE=1 electron node_modules/vitest/vitest.mjs", "test:extension": "cross-env ELECTRON_RUN_AS_NODE=1 electron node_modules/vitest/vitest.mjs --project extension", "test:integration": "pnpm compile-tests:integration && node esbuild.mjs && vscode-test", @@ -724,6 +726,7 @@ "@vscode/vsce": "^3.9.1", "babel-plugin-react-compiler": "catalog:", "bufferutil": "^4.1.0", + "chromatic": "^16.9.1", "coder": "catalog:", "concurrently": "^9.2.1", "cross-env": "^10.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 820a984b..a409aa6e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -225,6 +225,9 @@ importers: bufferutil: specifier: ^4.1.0 version: 4.1.0 + chromatic: + specifier: ^16.9.1 + version: 16.9.1 coder: specifier: 'catalog:' version: '@coder/coder@https://codeload.github.com/coder/coder/tar.gz/3e34ba7bf029394b642bced1428af2d94a99f55a' @@ -2354,6 +2357,21 @@ packages: chownr@1.1.4: resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} + chromatic@16.9.1: + resolution: {integrity: sha512-+EkBJqLfeCfSqC3rz1H8GDwT9OoHRB/iX3qbjtW9wu3BeySnDjumD8E/BflEsHV7RoCzeKcp85zKGR/ZKcX7rw==} + hasBin: true + peerDependencies: + '@chromatic-com/cypress': ^0.*.* || ^1.0.0 + '@chromatic-com/playwright': ^0.*.* || ^1.0.0 + '@chromatic-com/vitest': ^0.*.* || ^1.0.0 + peerDependenciesMeta: + '@chromatic-com/cypress': + optional: true + '@chromatic-com/playwright': + optional: true + '@chromatic-com/vitest': + optional: true + cli-cursor@5.0.0: resolution: {integrity: sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==} engines: {node: '>=18'} @@ -6954,6 +6972,10 @@ snapshots: chownr@1.1.4: optional: true + chromatic@16.9.1: + dependencies: + semver: 7.7.4 + cli-cursor@5.0.0: dependencies: restore-cursor: 5.1.0