Compare commits

...
Author SHA1 Message Date
Claude Code 58b16326e9 fix(chromatic): emit webpack stats so TurboSnap can trace story deps
Second live-test failure on #44111: after fixing the E2BIG git-log
crash, the publish step got further but then failed with "Failed to
retrieve dependent story files" / "Could not retrieve dependent story
files."

TurboSnap (onlyChanged) needs a webpack stats.json to build the module
dependency graph it uses to trace which stories a changed file affects.
Normally chromaui/action builds Storybook itself and can inject stats
collection; since we hand it an already-built storybookBuildDir instead
(to reuse the shared Docker image rather than installing Node on the
bare runner), that stats file has to already exist in the build output.
Add --webpack-stats-json to the build-storybook invocation so it does.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-09 12:16:39 -07:00
Claude Code 04d7596974 fix(chromatic): bound fetch-depth to avoid E2BIG on a dormant project
Live-tested this workflow via the draft PR stacked on it (#44111) and
hit a real failure: chromaui/action's "Retrieving git information
failed" / "Command failed with E2BIG: git log ...", passing hundreds of
full commit SHAs as individual CLI arguments until it blew past the
OS's ARG_MAX.

Root cause (confirmed against chromaui/chromatic-cli#432, filed by
another user hitting the identical error on a different large repo):
with fetch-depth: 0, Chromatic's CLI walks git history back to the
last build it knows about for this project. This project's last known
build predates its ~2-year dormancy (shipped in #21095, removed in
#27232) -- so on this very first run, it tries to walk back through
literally every commit since then on a large, very active repo, and
chokes passing that whole list to git log as arguments.

The Chromatic team's own recommended workaround on that issue is
exactly this: bound the fetch depth, since a baseline that old isn't
useful anyway ("we should probably just bail out ... and warn the user
that we are running a build with no baseline"). 500 is far more than
any realistic PR needs once a recent baseline exists, which it will
after this workflow's own first successful run against master.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-09 12:06:38 -07:00
Claude Code 9eda4c6977 ci(chromatic): add workflow_dispatch for manual runs
Also lets this be triggered manually to verify the actual publish step
end-to-end on a branch, since the path-filtered push/pull_request
triggers won't fire on a PR that only touches this workflow file
itself.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-09 11:17:15 -07:00
Claude Code c56d46adc0 feat(ci): add Chromatic visual regression testing for Storybook
Publishes superset-frontend's Storybook to Chromatic on pushes to master
and on pull requests touching superset-frontend, using the existing
CHROMATIC_PROJECT_TOKEN repo secret.

Chromatic was implemented here once before (#21095, 2021) and removed
in #27232 (Feb 2024) for being unmaintained and overlapping with
Applitools, which has since also been discontinued (no live references
left, only historical CHANGELOG mentions) -- so that overlap no longer
applies.

Design choices, to keep this from repeating the prior setup's history
of "fix:"/"remove, it has errors" churn:

- Fork PRs don't receive CHROMATIC_PROJECT_TOKEN (GitHub withholds repo
  secrets from pull_request runs triggered by a fork); the publish
  steps guard on CHROMATIC_PROJECT_TOKEN != '' and simply no-op for
  them rather than failing, following the same env-var-gate pattern
  frontend-bundle-size-nightly.yml already uses for an optional secret.
- Non-blocking for now (exitZeroOnChanges: true): visual changes show
  up as a PR check + comment for review, without gating merges. Can
  flip to a required check once the team trusts the signal.
- TurboSnap enabled (onlyChanged: true) to keep runs fast against this
  monorepo's large chart-plugin story set; fetch-depth: 0 on checkout
  so it has the git history it needs to diff against the baseline.
- Reuses the existing superset-node-ci Docker target and the
  build-then-mount-output pattern frontend-bundle-size-nightly.yml
  already established, rather than installing Node directly on the
  runner.

chromaui/action is already wildcard-allowlisted in the ASF allowlist
(chromaui/action@*), so this doesn't touch that check. Verified locally:
pre-commit (zizmor) passes, actionlint passes (aside from a stale-label
false positive on ubuntu-26.04 and $TAG-quoting notices that are already
pervasive throughout the rest of this repo's workflows), and the real
check_asf_allowlist.py script accepts the new chromaui/action ref.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-09 11:15:06 -07:00
+127
View File
@@ -0,0 +1,127 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# Publishes superset-frontend's Storybook to Chromatic for visual
# regression testing. See https://www.chromatic.com/docs/github-actions
#
# Runs on pushes to master (keeps the Chromatic baseline in sync with
# mainline) and on pull requests that touch superset-frontend. Fork PRs
# don't receive CHROMATIC_PROJECT_TOKEN -- GitHub withholds repository
# secrets from pull_request runs triggered by a fork -- so the publish
# steps below no-op for them (via the CHROMATIC_PROJECT_TOKEN != '' guard)
# rather than failing.
#
# Non-blocking for now (exitZeroOnChanges: true): visual changes are
# surfaced as a PR check/comment for review, not enforced as a merge gate.
# A prior Chromatic setup here (#21095) was removed in #27232 for being
# unmaintained and overlapping with Applitools (since also discontinued).
# Keep this one simple and watch it before considering a required check.
name: Chromatic
on:
push:
branches:
- master
paths:
- "superset-frontend/**"
pull_request:
types: [synchronize, opened, reopened, ready_for_review]
paths:
- "superset-frontend/**"
workflow_dispatch: {}
# cancel previous workflow jobs for PRs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
env:
TAG: apache/superset:chromatic-${{ github.run_id }}
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
permissions:
contents: read
jobs:
chromatic:
runs-on: ubuntu-26.04
timeout-minutes: 30
# pull-requests: write lets chromaui/action post its check and PR
# comment. Withheld automatically by GitHub for fork-triggered
# pull_request runs, same as CHROMATIC_PROJECT_TOKEN above.
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# TurboSnap (onlyChanged below) needs history to diff against the
# baseline commit, but NOT fetch-depth: 0. This Chromatic project
# was dormant for ~2 years (Chromatic here shipped in #21095,
# removed in #27232) before this workflow, so its last known
# baseline predates thousands of commits on a very active repo.
# With full history, Chromatic's CLI tries to `git log` every
# commit back to that ancient baseline as individual CLI args and
# hits the OS ARG_MAX limit (E2BIG) -- see
# https://github.com/chromaui/chromatic-cli/issues/432, where the
# Chromatic team's own recommended workaround is exactly this: a
# bounded depth, since a multi-year-old baseline isn't useful
# anyway. 500 is far more than any realistic PR needs once a
# recent baseline exists (i.e. after this workflow's own first
# successful run on master).
fetch-depth: 500
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
- name: Build Docker Image
if: ${{ env.CHROMATIC_PROJECT_TOKEN != '' }}
run: |
docker buildx build \
-t $TAG \
--cache-from=type=registry,ref=apache/superset-cache:3.11-slim-trixie \
--target superset-node-ci \
.
# --webpack-stats-json writes preview-stats.json into storybook-static.
# TurboSnap (onlyChanged below) needs it to trace which stories a
# changed file affects; without it, chromaui/action fails with "Could
# not retrieve dependent story files" since storybookBuildDir points
# at an already-built Storybook it can't inject its own stats
# collection into.
- name: Build Storybook
if: ${{ env.CHROMATIC_PROJECT_TOKEN != '' }}
run: |
mkdir -p ${{ github.workspace }}/superset-frontend/storybook-static
docker run \
-v ${{ github.workspace }}/superset-frontend/storybook-static:/app/superset-frontend/storybook-static \
--rm $TAG \
bash -c "npm i && npm run build-storybook -- --webpack-stats-json"
- name: Publish to Chromatic
if: ${{ env.CHROMATIC_PROJECT_TOKEN != '' }}
uses: chromaui/action@6b31c4307e3f5a150ab5345b051bb40a62923a5f # v18.7.3
with:
projectToken: ${{ env.CHROMATIC_PROJECT_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
workingDir: superset-frontend
storybookBuildDir: storybook-static
# TurboSnap: only re-snapshot stories affected by files changed
# since the baseline build.
onlyChanged: true
exitZeroOnChanges: true
zip: true