ci: add PR size labeler with XXL gate#9055
Conversation
| const EXCLUDE_GLOBS = [ | ||
| '**/*.lock', | ||
| '**/package-lock.json', | ||
| '**/poetry.lock', | ||
| '**/yarn.lock', | ||
| '**/Pipfile.lock', | ||
| '**/uv.lock', | ||
| '**/requirements*.txt', | ||
| 'schema/**', | ||
| '**/__snapshots__/**', | ||
| '**/*.snap', | ||
| '**/*.svg', | ||
| '**/*.png', | ||
| '**/*.jpg', | ||
| '**/*.jpeg', | ||
| '**/*.gif', | ||
| '**/*.ico', | ||
| '**/*.pdf', | ||
| ]; |
There was a problem hiding this comment.
do we have any of these except requirements?
There was a problem hiding this comment.
A more useful list would be ignore the dep/test/document changes. Could discuss
| issue_number: pull_number, | ||
| per_page: 100, | ||
| }); | ||
| const existing = comments.find(c => c.body && c.body.startsWith(STICKY_MARKER)); |
There was a problem hiding this comment.
can we just create a check that success & fail on each commit so we can throw away all these find/update in place logic?
There was a problem hiding this comment.
wait, this workflow itself is already a check. So we can just fail the workflow if it's more than 1000 useful lines
| # gh label create size/XXL --color b60205 --description "PR size: 1000+ changed lines" | ||
| # gh label create size/override --color 0e8a16 --description "Maintainer override for size/XXL gate" | ||
| # | ||
| # Spec: docs/superpowers/specs/2026-06-01-pr-size-labeler-design.md |
| const stale = currentLabels.filter(n => SIZE_LABELS.includes(n) && n !== bucket.label); | ||
| const alreadyApplied = currentLabels.includes(bucket.label); | ||
|
|
||
| if (!alreadyApplied) { |
There was a problem hiding this comment.
I think the most useful part is when this feature gates huge PRs. But I don't think we care if its a S or XL. So I'd suggest we just focus on fail/success
| uses: actions/github-script@v9 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | |
There was a problem hiding this comment.
let's use a standalone script.
|
Another part is we should update the contribution guild to call this 1000 line limit out & suggestion if they hit this blocker. https://github.com/aws/aws-sam-cli/blob/develop/CONTRIBUTING.md |
Summary
Adds
.github/workflows/pr-size-labeler.yml, a new GitHub Actions workflow that:size/XS,size/S,size/M,size/L,size/XL,size/XXLbased onadditions + deletionsacross non-excluded files.schema/**, snapshots, and image binaries from the count so generated noise doesn't dominate the bucket.size/XXL(≥ 1,000 changed lines), unless a maintainer appliessize/override. Removing the override re-arms the gate.Built across six small commits — skeleton → fetch+compute → label management → gate+sticky comment → try/catch → docs.
Action required from a maintainer before this lands
gh label createcommands; run them in this repo once.Size labelto branch protection. The gate only blocks merges if the check is required.If the labels do not exist,
addLabelsreturns 422; the script's catch swallows it and the gate is silently skipped — so the setup step is load-bearing.Behavior on each event
openedsynchronizereopenedlabeledsize/overrideunblocks).unlabeledsize/overridere-arms the gate).Test plan
These smokes should be run on a fork before requiring this check in branch protection —
pull_request_targetruns the workflow file from the base ref, so the workflow needs to be present on a base branch first.size/XXL, sticky comment, failing check. Applysize/override→ check passes, comment updates (no second comment). Removesize/override→ check fails again.size/M, no comment, passing check. Push another commit that brings the total to ~130. Expectsize/Mremoved andsize/Lapplied.package-lock.jsonand 5 lines to a.pyfile. Expectsize/XS.actionlint .github/workflows/pr-size-labeler.ymlis clean.