Repository navigation
ci: drop the size-base job; Main keeps every component's sizes and pull requests read the merge base's record - #9164
Conversation
…h PR, in the build job Measures every published package's npm download and unpacked size in build-storybook, after its build, and compares it with the merge base's measurement that Main now keeps for 14 days. Adds a Published Package Size section to the PR report and the job summary, and fails the job when a package's download grows more than 5% (and at least 1 KB) unless the PR description has a 'Size budget:' line.
…ll requests read the merge base's record Main's typecheck job records every public component's import and CSS size, the source modules its bundle reaches, its entry stats and every package's bundle stats (analyze-pr.js --main-record), and keeps it for 14 days in place of the whole package builds. build-storybook reads the merge base's record (--base-record), so no pull-request job installs or builds the merge base.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Requesting changes: reading the merge base's sizes from Main's per-commit record works where a record is found, but two gaps need fixing first.
- The new "Find the merge base" step in
ci.ymlruns before anything deepens the depth-50 clone, so a PR 50 or moremaincommits behind finds no record and loses Before/Delta and the package-size budget; please restore thegit fetch --deepen=200fallback the removedsize-basejob had, with a routing test. - The description says the Before figures are unchanged, but the removed build fallback also covered merge bases whose Main run was superseded by a later push (several recent
maincommits have no kept Main build) and stacked PRs, so please name those cases in the description or build the base only when no record exists.
[Automated review]
| if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request' | ||
| env: | ||
| BASE_REF: ${{ github.base_ref }} | ||
| run: echo "sha=$(git merge-base "origin/$BASE_REF" HEAD || true)" >> "$GITHUB_OUTPUT" |
There was a problem hiding this comment.
This runs on the depth-50 clone before anything deepens it (analyze-pr.js only deepens later, inside the analysis), so a PR 50 or more main commits behind gets an empty SHA, no record, and no package-size base. The removed size-base step deepened first:
if ! SHA=$(git merge-base "origin/$BASE_REF" HEAD); then
git fetch --deepen=200 origin "$BASE_REF:refs/remotes/origin/$BASE_REF" || true
SHA=$(git merge-base "origin/$BASE_REF" HEAD || true)
fi
echo "sha=$SHA" >> "$GITHUB_OUTPUT"…helper; the check also follows root build inputs - A package over its budget is flagged (job summary, PR report, a workflow warning) and fails nothing, like the component touch-only flags; the 'Size budget:' line and the enforce step are gone. - The package-size merge-base step deepens once when the 50-commit fetch holds no merge base, as size-base does. - Report counts render through num(). - tsconfig.json and scripts/ are in the check's paths scope. - size-base and the package-size lookup share lib/main-artifact.cjs.
There was a problem hiding this comment.
Requesting changes: reading the merge base's sizes from Main's per-commit record works where a record exists, and the earlier depth-50 lookup gap is fixed, but three points remain.
- When Main kept no record for the merge base (a
mainpush whose Main run was superseded, or any pull request intorelease/**), the report now shows no Before or Delta wheresize-baseused to build the base, so please build the base only in that case. - The description says the Before figures are unchanged, so please make that true or name those cases.
recordTargetsandwriteMainRecordrepeatsizeTargets' targeting rule, so please share one helper so base and head targeting cannot drift.
[Automated review]
| const name = `${prefix}-${process.env.BASE_SHA}`; | ||
| const runId = await mainArtifactRunId({github, ...context.repo, name, sha: process.env.BASE_SHA}); | ||
| core.setOutput(output, runId ?? ''); | ||
| core.info(runId ? `Using ${name} from run ${runId}.` : `No ${name}; its Before and Delta stay empty.`); |
There was a problem hiding this comment.
When this finds no record (Main kept none for 7 of its last 39 commits, because a later push supersedes a pending run, and a release/** merge base never has one), the analysis runs without --base-record, and Before and Delta go N/A. The removed size-base job built the base in that case. Could this build and measure the merge base only when no record is found?
| // The components a change can affect in the merge base's build, from its | ||
| // record: as sizeTargets decides in a built tree, a component whose own folder | ||
| // or file changed, or whose bundle reached a changed module of any package. | ||
| function recordTargets(record, changedFiles) { |
There was a problem hiding this comment.
This repeats sizeTargets' rule, the own-folder test and the reach test, and writeMainRecord repeats its mapping from bundle input to src module. If one helper decided a target and one mapped inputs, all three could call them, and base and head targeting could not drift apart.
There was a problem hiding this comment.
Requesting changes: merging main left Main's package-size measurement and upload in the typecheck job twice, so once this lands every push to main would fail at the second package-size-main-<sha> upload, and the earlier points are still open.
- Delete the second copy of the package-size steps in
deploy.yml(lines 158-168). - When Main kept no record for the merge base (a Main run a later push replaced, or a merge base only on a
release/**branch), Before and Delta now show N/A wheresize-basebuilt the base, which the description's "unchanged" claim leaves out; please build the base only in that case, or name those cases. recordTargetsandwriteMainRecordrepeatsizeTargets' targeting rule, so one shared helper would keep base and head targeting from drifting apart.
[Automated review]
| # A pull request compares its published package sizes with its merge | ||
| # base's from this measurement (ci.yml build-storybook). | ||
| - name: Measure published package size | ||
| run: node .github/scripts/package-size.mjs measure --output package-size.json | ||
|
|
||
| - name: Keep this commit's package size for PR size reports | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: package-size-main-${{ needs.main-commit.outputs.sha }} | ||
| path: package-size.json |
There was a problem hiding this comment.
After the merge of main, this block and the existing one at lines 158-168 both measure and upload package-size-main-${{ needs.main-commit.outputs.sha }} in the same job. upload-artifact refuses a second artifact with the same name in one run unless overwrite: true, so Main's typecheck would fail on every push to main and skip the export and type checks after it. Deleting lines 158-168 keeps one copy.
PR Analysis Report🔎 Preview ·
|
…rgeting rule and reach map for the head and the merge base's record; name the cases with no base record
There was a problem hiding this comment.
Reading the merge base's sizes from Main's per-commit record works: where a record exists, the Before figures, sized components and audit dependents match what size-base produced, and the duplicated package-size upload, the description's claim and the copied targeting rule from the last review are fixed. Approval now waits on one owner decision: architecture:component-style-authoring INV6 and spec:AST-080 FR8 require a base-against-head size for every changed component, and this change intentionally shows N/A when Main kept no record for the merge base, where size-base used to build it. An engineering owner settles that on this pull request, either by updating INV6 and FR8 on main to allow the gap and commenting /approve-spec <full head SHA>, or by asking for the merge base to be built only when no record is found; the author may decide as an engineering owner.
[Automated review]
| BASE_RECORD=() | ||
| if [ -f .component-size-base/component-size.json ]; then | ||
| BASE_RECORD=(--base-record .component-size-base/component-size.json) | ||
| fi |
There was a problem hiding this comment.
When no record was downloaded, the analysis runs without a base, so Before and Delta show N/A; the removed size-base job built the merge base in that case. architecture:component-style-authoring INV6 and spec:AST-080 FR8 require a base-against-head figure for every changed component, so this needs an engineering owner's decision: amend those claims on main, or build and measure the merge base only when no record is found.
…he base beside the Storybook build, so every changed component keeps a before size (AST-080 FR8)
There was a problem hiding this comment.
Requesting changes: building the merge base inside build-storybook when Main kept no record closes the earlier Before/Delta gap, and CI on this commit took that path successfully, but some wording still says the base is never built. Please reword the description's invariant "No pull-request job installs or builds the merge base", the component lookup's log line "its Before and Delta stay empty" (ci.yml:1013), and the routing test's "never building the base" title and comment (ci-tooling-routing.test.mjs:239 and :135) so they say the base is built only when Main kept no record.
[Automated review]
| const name = `${prefix}-${process.env.BASE_SHA}`; | ||
| const runId = await mainArtifactRunId({github, ...context.repo, name, sha: process.env.BASE_SHA}); | ||
| core.setOutput(output, runId ?? ''); | ||
| core.info(runId ? `Using ${name} from run ${runId}.` : `No ${name}; its Before and Delta stay empty.`); |
There was a problem hiding this comment.
For component-size-main, the next step builds the merge base when this finds nothing, so "its Before and Delta stay empty" no longer holds; CI on this commit printed it one line before the base build started. Something like No ${name}; building the merge base instead. for the component record keeps the log accurate.
| }); | ||
|
|
||
| it("measures the merge base from main's kept build, building it only without one", () => { | ||
| it("reads the merge base's sizes from main's kept records, never building the base", () => { |
There was a problem hiding this comment.
This test now asserts the fallback build, so "never building the base" (and the comment at line 135, "No pull-request job builds the merge base") no longer matches; for example "reads the merge base's sizes from main's kept records, building the base only without one".
There was a problem hiding this comment.
Requesting changes: reading the merge base's sizes from Main's record, and building the base inside build-storybook when there is none, works on this head's own CI, and the earlier wording is fixed. One line remains: the record lookup's miss message (.github/workflows/ci.yml:1013) now says the merge base is built for the package-size-main record too, which the fallback never builds, so keep "sizes are shown without a budget" for that record and the new message for the component record only.
[Automated review]
| const name = `${prefix}-${process.env.BASE_SHA}`; | ||
| const runId = await mainArtifactRunId({github, ...context.repo, name, sha: process.env.BASE_SHA}); | ||
| core.setOutput(output, runId ?? ''); | ||
| core.info(runId ? `Using ${name} from run ${runId}.` : `No ${name}; the merge base is built here instead.`); |
There was a problem hiding this comment.
This loop also runs for package-size-main, but the fallback below builds only the component record (component_run_id == '', line 1033), and the package comparison then reports Main's measurement as not found. Choosing the message by record keeps the log accurate:
const missing = output === 'component_run_id'
? 'the merge base is built here instead'
: 'sizes are shown without a budget';
core.info(runId ? `Using ${name} from run ${runId}.` : `No ${name}; ${missing}.`);There was a problem hiding this comment.
Requesting changes: the per-record miss message is fixed, and reading the merge base's sizes from Main's record, with an in-job build when there is none, works on this head's CI. One gap remains: when the lookup finds Main's record but the download step fails, nothing builds the merge base, so Before and Delta show N/A where the removed size-base job built it (it keyed on steps.download.outcome != 'success'). Giving the download step an id and starting the fallback on that step's outcome (.github/workflows/ci.yml:1036) covers both misses, and the routing test's start.if assertion moves with it.
[Automated review]
| # in the background; the wait before the analysis collects it. | ||
| - name: Start building the merge base without a record | ||
| id: base-build | ||
| if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && steps.merge-base.outputs.sha != '' && steps.size-records.outputs.component_run_id == '' |
There was a problem hiding this comment.
This starts the build only when the lookup found no run. If the lookup finds Main's record but the download step above fails (it has continue-on-error: true), there is no record and no fallback, so Before and Delta go N/A; the removed size-base job built the base on any download miss (steps.download.outcome != 'success'). Giving the download step an id and keying on its outcome covers both cases, since the download is skipped when the lookup finds nothing:
if: ... && steps.merge-base.outputs.sha != '' && steps.component-size-download.outcome != 'success'There was a problem hiding this comment.
Recommending approval: reading the merge base's sizes from Main's per-commit record, with the merge base built inside build-storybook whenever that record is not downloaded, keeps base-against-head sizes on every path, and this head's CI ran the no-record path successfully. The last open point, a found record whose download fails, is fixed by starting the fallback on the download step's outcome. The required test check failed only in an unrelated CLI watch test (build-theme.watch.test.mjs) and needs a re-run before merge.
[Automated review]
Maintainer impact
Every pull request that changes a component runs a separate
size-basejob. It checks out the merge base, installs its dependencies, downloads (or builds) its packages and measures them, so the PR report can show Before and Delta. Over the last 20 pull-request runs it ran 39 s on average (up to 105 s) on its own runner, plus job start-up, on every push. Main already builds every package once per commit, so this measures the same base again for each PR.Intended invariant
Change
analyze-pr.js --main-record: records every public component's import and CSS gzip size, the source modules its bundle reaches, each component folder's entry stats, and every component package's bundle stats (about 140 KB of JSON).analyze-pr.js --base-record <file>: reads that record instead of measuring a built merge-base checkout.--base-rootand--base-onlyare removed; nothing else used them.deploy.ymltypecheck: keepscomponent-size-main-<sha>for 14 days in place ofdists-main-<sha>(whole package builds, which onlysize-baseread).ci.yml:size-baseis removed.build-storybookfinds the merge base once (merge-base.sh), looks up both of Main's records for it (only from Main's own run onmainfor that commit, throughmain-artifact.cjs), and passes the component record to the analysis it already runs. The package-size steps share that lookup.mainreplaced Main's run for that commit (about 1 in 5 recentmaincommits), or when the record expired:build-storybookbuilds the merge base itself, so every changed component keeps a before size (AST-080 FR8). The record lookup now runs before the Storybook build, and the base builds in the background beside it. It builds core and its build tooling, plus any other component package the PR changes, assize-basedid, then records it with this head's analyzer. A wait before the analysis collects it, and its notice says how long the job waited. If the build fails or times out (10 min), Before and Delta stay empty, with a warning. Measured on this PR's own run, which had no record becausemainkeeps none until this lands: the base was ready before Storybook finished (a 0 s wait). Contention made the Storybook build step 2 min 36 s, against 1 min 27 s to 2 min 14 s in three recent runs, and the job 3 min 51 s against 2 min 19 s to 3 min 30 s. So a PR without a record pays roughly +0.4 to +1.5 runner-minutes in this one job, and PRs with a record pay nothing.analyze-pr.js: one targeting rule (affectedBy) decides the sized components both in a built head (sizeTargets) and from the merge base's record (recordTargets). Main's record and the head share one reach map (componentReach), so base and head targeting cannot drift apart.deploy.ymlmeasures and uploads the package size once. The merge had left the step twice, and a second upload of one name would fail the job. A new contract (workflow-artifact-names.test.mjs) fails any job that uploads one artifact name twice.pr-size-base. Nothing produces it now, so that step quietly finds nothing; it goes in the follow-up PR that redesigns the report.Evidence
main,--main-recordwrites 232 components, 707 reached modules and 5 package bundles. The converted tests read Before figures, reach-only components and a renamed defining module from the record.Scope
Testing
vitest run --project node .github/scripts: 1,558 pass.analyze-pr.test.mjs: the three merge-base tests now build the base, write its record with--main-record, and analyze the head with--base-record: reach decided only in the base build, a renamed defining module, entry and bundle stats, a family folder's new member (no base figure), and a missing record (no Before, head still sized).ci-tooling-routing.test.mjs: nosize-basejob; Main keeps the component record and no longer the package builds;build-storybooktrusts only Main's run for the merge-base commit and downloads the record before the analysis reads it.actionlint: no new findings.