@@ -9,12 +9,17 @@ name: Size
99# ships); the retained-module-graph assertions in
1010# packages/signals/tests/treeshake.test.ts stay the which-module diagnostic
1111# underneath.
12- # The check job also runs on direct pushes to next: it is self-contained
13- # (absolute limits, no base ref), and PR-only triggering let the
14- # +createStore scenario sit failing at a release commit unnoticed — direct
15- # pushes never measured. The compare job stays PR-only; it needs a PR
16- # context (base branch, comment target). The floor-cap freeze step in check
17- # is PR-only for the same reason (it diffs against the base branch).
12+ #
13+ # Three jobs. `head` measures the commit under test; `base` (PRs only)
14+ # measures the PR's base with the head's harness; `check` — the required
15+ # status — decides with both (scripts/size/gate.mjs): a scenario fails only
16+ # when it is over its brotli cap AND grew past the minified allowance over
17+ # the base. The decision needs the base's minified numbers, so the base
18+ # measurement moved from the old informational `compare` job (which ran after
19+ # `check`) into a job `check` waits on; `head` and `base` run in parallel.
20+ # Pushes to next are gated too, against the commit before the push —
21+ # PR-only triggering let the +createStore scenario sit failing at a release
22+ # commit unnoticed.
1823on :
1924 push :
2025 branches : [next]
@@ -26,9 +31,7 @@ permissions:
2631 pull-requests : write
2732
2833jobs :
29- # The hard gate: self-contained on the PR head, fails when any scenario
30- # exceeds its limit. Never depends on the base branch.
31- check :
34+ head :
3235 runs-on : ubuntu-latest
3336 steps :
3437 - uses : actions/checkout@v4
@@ -48,46 +51,33 @@ jobs:
4851 - run : pnpm build
4952 - run : npm ci --no-audit --no-fund
5053 working-directory : scripts/size
51- # size.mjs gates every scenario against its cap and prints the lazy
52- # chunks and per-package minified bytes for each, so a bump is
53- # attributed in the same log that reports it. The JSON feeds the
54- # compare job 's PR comment .
55- - run : npm run size -- --json size-head.json
54+ # size.mjs prints the lazy chunks and per-package minified bytes for
55+ # each scenario , so a bump is attributed in the same log that reports
56+ # it. --no-gate: the decision is check's. Uploaded on pushes too — a
57+ # push to next 's size-head is what `npm run ratchet -- --from` reads .
58+ - run : npm run size -- --json size-head.json --no-gate
5659 working-directory : scripts/size
57- - if : always() && github.event_name == 'pull_request'
58- uses : actions/upload-artifact@v4
60+ - uses : actions/upload-artifact@v4
5961 with :
6062 name : size-head
6163 path : scripts/size/size-head.json
62- # The floor and page caps (scripts/size/floor-caps.json) are frozen: a PR
63- # may lower them, never raise them, unless its body carries a
64- # `Size-Exception:` line. Compared against the PR's base branch, so
65- # PR events only.
66- - if : github.event_name == 'pull_request'
67- run : git fetch --no-tags --depth=1 origin "${{ github.base_ref }}"
68- - if : github.event_name == 'pull_request'
69- run : npm run check-floor-caps -- "origin/${{ github.base_ref }}"
70- working-directory : scripts/size
71- env :
72- SIZE_EXCEPTION : ${{ github.event.pull_request.body }}
7364
74- # Best-effort base-vs-head delta comment. Builds the base branch and
75- # measures its artifacts with the HEAD's harness (SIZE_PACKAGES_ROOT), so
76- # both columns come from the same scenarios and the same Rolldown; the head
77- # numbers are the check job's. Informational and never blocks:
78- # continue-on-error keeps bootstrap PRs (and any hiccup) green. PR events
79- # only — it needs a base ref and a comment target.
80- compare :
81- # always(): the comment is most useful on the PR whose check failed.
82- if : always() && github.event_name == 'pull_request'
83- needs : check
65+ # Builds the base and measures its artifacts with the HEAD's harness
66+ # (SIZE_PACKAGES_ROOT), so both sides come from the same scenarios and the
67+ # same Rolldown. On a PR the head is the merge commit with base.sha, so the
68+ # difference is the PR's own change; on a push it is the pushed range
69+ # (`before`), so a merge that passed with a noise warning does not turn
70+ # next red on the absolute cap. continue-on-error: a base the head's
71+ # harness cannot build or measure leaves check on absolute caps instead of
72+ # blocking.
73+ base :
8474 runs-on : ubuntu-latest
8575 continue-on-error : true
8676 steps :
8777 - uses : actions/checkout@v4
8878 - uses : actions/checkout@v4
8979 with :
90- ref : ${{ github.event.pull_request.base.sha }}
80+ ref : ${{ github.event_name == 'pull_request' && github. event.pull_request.base.sha || github.event.before }}
9181 path : base
9282 - uses : pnpm/action-setup@v4
9383 - uses : actions/setup-node@v4
@@ -106,23 +96,50 @@ jobs:
10696 working-directory : base
10797 - run : npm ci --no-audit --no-fund
10898 working-directory : scripts/size
109- - run : node size.mjs --json size-base.json || true
99+ - run : node size.mjs --json size-base.json --no-gate
110100 working-directory : scripts/size
111101 env :
112102 SIZE_PACKAGES_ROOT : ${{ github.workspace }}/base
103+ - uses : actions/upload-artifact@v4
104+ with :
105+ name : size-base
106+ path : scripts/size/size-base.json
107+
108+ # The hard gate (the required status). always(): it runs when base failed;
109+ # a failed head leaves no size-head artifact and fails here.
110+ check :
111+ if : always()
112+ needs : [head, base]
113+ runs-on : ubuntu-latest
114+ steps :
115+ - uses : actions/checkout@v4
116+ - uses : actions/setup-node@v4
117+ with :
118+ node-version-file : " .nvmrc"
119+ - run : npm ci --no-audit --no-fund
120+ working-directory : scripts/size
121+ # gate.mjs's own tests; scripts/size is outside the workspace `pnpm test`.
122+ - run : npm test
123+ working-directory : scripts/size
113124 - uses : actions/download-artifact@v4
114125 with :
115126 name : size-head
116127 path : scripts/size
128+ - continue-on-error : true
129+ uses : actions/download-artifact@v4
130+ with :
131+ name : size-base
132+ path : scripts/size
133+ # The job summary carries the report on every run. The comment only
134+ # goes on PRs from this repository: a fork PR's token is read-only, so
135+ # createComment answers 403. Rendered before the gate step so a failing
136+ # PR still gets its table.
117137 - run : node report.mjs size-head.json size-base.json > size-comment.md
118138 working-directory : scripts/size
119- # The job summary carries the report on every PR. The comment only goes
120- # on PRs from this repository: a fork PR's token is read-only, so
121- # createComment answered 403 and the job showed as failed on every
122- # external PR.
123139 - run : cat size-comment.md >> "$GITHUB_STEP_SUMMARY"
124140 working-directory : scripts/size
125- - if : github.event.pull_request.head.repo.full_name == github.repository
141+ - if : github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
142+ continue-on-error : true
126143 uses : actions/github-script@v7
127144 with :
128145 script : |
@@ -135,3 +152,16 @@ jobs:
135152 const mine = comments.find(c => c.user.type === "Bot" && c.body.startsWith(marker));
136153 if (mine) await github.rest.issues.updateComment({ owner, repo, comment_id: mine.id, body });
137154 else await github.rest.issues.createComment({ owner, repo, issue_number, body });
155+ - run : node gate.mjs size-head.json size-base.json
156+ working-directory : scripts/size
157+ # The floor and page caps (scripts/size/floor-caps.json) are frozen: a PR
158+ # may lower them, never raise them, unless its body carries a
159+ # `Size-Exception:` line. Compared against the PR's base branch, so
160+ # PR events only. always(): reported even when the gate step failed.
161+ - if : always() && github.event_name == 'pull_request'
162+ run : git fetch --no-tags --depth=1 origin "${{ github.base_ref }}"
163+ - if : always() && github.event_name == 'pull_request'
164+ run : npm run check-floor-caps -- "origin/${{ github.base_ref }}"
165+ working-directory : scripts/size
166+ env :
167+ SIZE_EXCEPTION : ${{ github.event.pull_request.body }}
0 commit comments