feat(ci): add visual PR scoring to analysis report (dry run)#3748
Open
jiunshinn wants to merge 1 commit into
Open
feat(ci): add visual PR scoring to analysis report (dry run)#3748jiunshinn wants to merge 1 commit into
jiunshinn wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
0964ffb to
a28f421
Compare
a28f421 to
aa195c4
Compare
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 #3667 — phase 1 (dry run). Statically classifies each PR's diff as visual / likely-visual / maybe-visual / non-visual and surfaces the result in the PR Analysis Report comment. No labels, no reviewer requests — the point is to calibrate against real PR traffic first (open question 1 in #3667).
Summary
.github/scripts/lib/classify-visual.js— pure function over the unified diff; no rendering, no install/build..github/scripts/classify-visual-pr.js— CI entry point. Fails loudly if there is no merge base instead of classifying an empty diff as non-visual.ci.yml— new lightweightclassify-visualjob withfetch-depth: 0, runs on every PR including docsite-only (docsite CSS is a visual surface, e.g. fix/docsite: flashing of desktop UI on docs/components #3665). Bothpr-commentandpr-comment-updatedownload the artifact, so the section survives comment updates.generate-pr-comment.jsreads the classification from its own artifact;analyze-pr.jsis untouched.vitest.config.ts— include.github/scripts/**/*.test.mjsso the 23 classifier tests run underpnpm test.Scoring
Per #3667: CSS-property edits (×3) + design-token references (×2) + style-surface files (×3 per file) + JSX structural changes (×1, capped at 10); buckets ≥12 / ≥5 / ≥2.
Deviations from the issue spec: generic token regex (
*Vars.and*Vars[...]— coversshadowVars,borderVars, bracket access);*.markers.stylex.tsare not style surfaces (scoping markers move no pixels); TS type members (width: number;) don't count; multi-line block comments are tracked per diff side.Scope decisions and known limitations
packages/,apps/) are scanned. Tooling (.github/,scripts/, root configs) can mention CSS-ish content — mocks, fixtures, CSS generators — without moving pixels. (This PR classifies itself non-visual, score 0.)__tests__files are skipped; only.ts/.tsx/.js/.jsx/.mjs/.csslines are scanned.build-theme.mjsin Fix built theme.css pinning color-scheme so Theme mode can force ligh… #3690) has no static signal. The rendered-pixel tier from Auto-flag visual PRs for non-blocking design review #3667 would catch it.Validation
Calibrated against 22 real PRs (recent merged + open): 21/22 matched manual expectations; the a11y wave classifies non-visual while focus-ring fixes (#3722/#3723) correctly flag. #3649 flags visual because it bundles a Text font-size change alongside the pagination fix — the "bundled style edit" case #3667 calls arguably correct.
Calibration table
Tests: 23 vitest cases (signals, file filtering, block comments, buckets, section rendering); full
pnpm testandcheck:repogreen. No changeset (no published package changed).Found while validating (pre-existing, not fixed here): the
buildjob fetches the base branch with--depth=1on a depth-1 checkout, soanalyze-pr.js's three-dot diff has no merge base and component detection comes up empty on PRs. Happy to fix in a follow-up.Out of scope (phase 2 — needs maintainer decisions)
Applying
design/tokens/theminglabels and requesting designer reviews (which designers? collaborator access?). Fork PRs:pr-commentstill skips forks (read-only token); the classification artifact is uploaded regardless, but surfacing it on fork PRs would need wiring into #3659's comment flow as well.