Repository navigation
ci(storybook): make Visual Diff safe to require - #856
Merged
Merged
Conversation
Drop the pull_request paths filter so the Visual Diff check always reports and can be required. A Visual Changes job checks the diff against visual-paths.sh, which also covers dependencies, Tailwind, PostCSS, CT config and .node-version; with nothing visual, Visual Diff passes at once. Add CODEOWNERS for the workflows and the visual-diff scripts.
Reverts the Badge padding change, the tailwind.config.ts comment and the narrowed visual path list used for the CI proofs.
List changed files with --no-renames -z so a move out of a visual path and names git would quote are both seen, read them NUL-separated, run the base commit's visual-paths.sh so a PR cannot loosen its own gate (no base copy runs everything), and add packages/design for tokens.json.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #736
Summary
Follow-up to #854, so that Visual Diff can be marked as a required check.
pull_requesttrigger no longer has apathsfilter. A new first job, Visual Changes (changes), lists the PR's changed files (its merge commit against the base, usinggit diff --name-only, with no new action) and checks them against the base commit's copy ofpackages/ui/scripts/visual-diff/visual-paths.sh, so a PR cannot loosen the list that judges it. If the base has no copy, as on today'smain, every job runs with a warning. Files are listed with--no-renames -z, so a file moved out of a visual path still counts, and names git would put in quotes (non-ASCII, newlines) are matched as they are. If nothing visual changed, every Storybook job is skipped and Visual Diff passes straight away with a notice. Otherwise it works as before: every shard must finish, exit 3 (a story failed to render) still fails even with the label, and exit 1 needsvisual-change-approved. If the changed files cannot be listed or the base cannot be fetched, every job runs. If the script exits with anything other than 0 or 1, the job fails, and Visual Diff fails with it.pnpm-lock.yaml, rootpackage.json,pnpm-workspace.yaml(overrides and catalogs),.node-version,packages/ui/package.json,tailwind.config.ts,postcss.config.mjs,playwright-ct.config.ts,playwright/**(CT harness and Tailwind content)tsconfig.json, andpackages/design/**(src/design-tokens.stories.tsximportspackages/design/tokens.json). The list is kept in one script, so thepushtrigger no longer has a duplicatepathscopy: onmainthe same job checks the pushed range. The old copy had the same gaps (point 2 of the review)..github/CODEOWNERScovers.github/workflows/, itself,packages/ui/scripts/visual-diff/,packages/ui/.storybook/,packages/ui/playwright/andplaywright-ct.config.ts. The owner isbntvllnt, the repo's admin. Thevllntorg has no teams. CODEOWNERS only enforces a review if "Require review from Code Owners" is turned on. Until then, a PR can still change its own copy ofstorybook.ymlorrun.mjswithout that review.visual-paths.shis already read from the base.Owner steps (after merge)
main: turn on Require review from Code Owners.Visual Diff. Today the only required check isPrivacy Guard.Type of change
chore— tooling / CI / depsTest plan
actionlint .github/workflows/storybook.yml: only the SC2034 warning that is already onmain(iunused in the test-runner wait loop).bash -nonvisual-paths.sh. Stdin cases: docs-only gives exit 1;tailwind.config.ts,pnpm-lock.yaml,.node-version,src/**,.storybook/**and the workflow give exit 0;packages/ui-native/**,apps/registry/package.jsonandpackages/ui/README.mdgive exit 1; empty input gives exit 1; a last line with no newline is still read.changesstep on real merge commits: docs-only givesvisual=false,tailwind.config.tsgivesvisual=true, and a push with an all-zerobeforewarns and givesvisual=true.Review fixes (head
3523138e)An independent review of
e8b12fbefound three ways a visual change could pass without screenshots, plus a PR judging itself with its own copy of the script. All four are fixed in5aba914e; the docs follow in3523138e.origin/mainwas merged in and had nothing new.Local repro. The exact
changesstep script, taken from each commit's workflow, was run on PR-style merge commits (parent 1 = base, parent 2 = one throwaway change):e8b12fbe)5aba914e)git mv packages/ui/themes/presets.css docs/brand-old.cssvisual=false✗visual=true(matchedpackages/ui/themes/presets.css)packages/ui/src/ünïcode.stories.tsxvisual=false✗visual=true(matched the unquoted name)packages/design/tokens.jsonvisual=false✗visual=trueexit 1to its ownvisual-paths.sh, plus asrceditvisual=false✗visual=true(the base copy judged)docs/agents/LANES.md)visual=falsevisual=false(script exit 1)origin/maintoday)visual=truebeforevisual=trueactionlintshows only the SC2034 warning that is already onmain, andbash -n visual-paths.shpasses.CI proofs (on
e8b12fbe, before the review fixes)Every PR that contains this change also changes
storybook.ymlandvisual-paths.sh, and both are visual paths. So for (a) and (b), a throwaway commit first removed those two entries from the list. The rest of the logic was left unchanged.2bc7860avisual=false(8 s). Visual Diff: success in 2 s with the notice "No file that can change rendered pixels changed…". Builds, tests and all 8 shards: skipped.packages/ui/tailwind.config.ts196d872cpackages/ui/tailwind.config.ts, sovisual=true. All 8 shards ran. Visual Diff: success (a comment changes no pixels).defaultpaddingpx-2.5→px-4, no label98f15911e8b12fbereverts all three throwaways. Its tree is identical toe59cc961, the real change. The label was never applied.Not exercised in CI: the case where
changesfails, so that Visual Diff reports "did not finish" and fails; and a push tomain, which diffsbefore..HEADand counts the push as visual whenbeforecannot be fetched. That fallback was checked locally with an all-zerobefore.The throwaway commits and the revert used
--no-verify. The hook runs react-doctor on staged.tsfiles, and this worktree has nonode_moduleswhile the host load is around 20. The real commite59cc961went through the hook; it had no staged TS, so the hook did nothing.Breaking changes
None. PRs that change no visual path now show skipped Storybook jobs and a passing Visual Diff, where before the workflow did not run at all.