ci: label PRs by size without counting tests

Merged
OK
19d ago
+204-0

What and why

  • Every PR gets one size:XS .. size:XXL label (<10, <30, <100, <500, <1000, 1000+ lines), updated on each push. Lets reviewers see how big a PR is from the PR list.
  • Counts added plus deleted lines from the PR's file list, without *.test.*, *.spec.*, *.e2e.*, tests/, tests-*/, __tests__/, *-snapshots/, __snapshots__/, fixtures/, pnpm-lock.yaml. A PR touching only those is sized by all its lines.
  • Same shape as pr-policy: pull_request_target so fork PRs can be labeled, sparse checkout of the base branch's scripts/pr-size only, fetch with GITHUB_TOKEN. Never checks out or runs PR code. --dry-run prints the size and writes nothing.
  • Rules in scripts/pr-size/size.ts, API calls in scripts/pr-size/label.ts. Labels get created with colors the first time they're used.
  • Idea from T3 Code's pr-size.yml.

Verified

Ran it locally: yes

  • node scripts/pr-size/label.ts --dry-run against the last 10 PRs here:
PRGitHub +/-counted / totallabel
#1418+57/-057 / 57size:M
#1417 test-only+240/-00 / 240size:L
#1416+262/-21104 / 283size:L
#1413+159/-2884 / 187size:M
#1412+1467/-151321 / 1482size:XXL
#1411+794/-10804 / 804size:XL
#1410+357/-2177 / 378size:M
#1408+265/-99861812 / 10251size:XXL
#1407+454/-6160 / 460size:L
#1401+231/-18117 / 249size:L
  • The workflow itself has not run. pull_request_target uses the base branch copy, so it starts working after merge and won't label this PR.

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.