mirror of
https://github.com/Comfy-Org/github-workflows.git
synced 2026-11-05 00:17:37 +00:00
[PR #36] [MERGED] feat: reusable PR-size cap workflow with per-repo inputs #47
Labels
No labels
cursor-review-catalog-drift
groom
groom
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/github-workflows#47
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/github-workflows/pull/36
Author: @mattmillerai
Created: 7/18/2026
Status: ✅ Merged
Merged: 7/21/2026
Merged by: @mattmillerai
Base:
main← Head:matt/be-3481-pr-size-reusable📝 Commits (4)
d2e53fbfeat: add reusable PR-size cap workflow with per-repo inputs132efeaMerge remote-tracking branch 'origin/main' into matt/be-3481-pr-size-reusable2eecbcdfix(check-pr-size): cap the deleted-file blob read in contentGeneratedc413115Merge origin/main into matt/be-3481-pr-size-reusable📊 Changes
8 files changed (+1836 additions, -0 deletions)
View changed files
➕
.github/workflows/pr-size.yml(+303 -0)➕
.github/workflows/test-pr-size.yml(+55 -0)📝
README.md(+1 -0)➕
scripts/check-pr-size/go.mod(+3 -0)➕
scripts/check-pr-size/main.go(+367 -0)➕
scripts/check-pr-size/main_test.go(+397 -0)➕
scripts/check-pr-size/size.go(+298 -0)➕
scripts/check-pr-size/size_test.go(+412 -0)📄 Description
ELI-5
Big PRs are hard to review well, so we have a CI check (built for the cloud repo) that fails a PR when it changes too many lines of hand-written code — generated files and lockfiles don't count, and a label lets a legitimately big change through. This PR moves that check into this shared-workflows repo so any Comfy-Org repo can turn it on with a few lines of config, picking its own line cap and its own list of "don't count these" files, and can start in a warn-only mode that reports without blocking.
What
.github/workflows/pr-size.yml— reusable (workflow_call) PR-size cap, same topology ascursor-review.yml: callers add a thin SHA-pinned wrapper; the counting logic lives here.max_lines(1000),mode(enforce|warn— warn reports and comments on overage but never fails the check, for gradual rollout),bypass_label(oversized-ok),extra_lockfiles,extra_generated_globs,comment(true),bot_app_id,workflows_ref.BOT_APP_PRIVATE_KEY(pass-through; callers use the existingvars.APP_ID+ bot-key pattern). When credentials are absent orcomment: false, the workflow degrades gracefully to check status + step summary — no comment job failure.contents: readand builds the checker from this repo's pinned checkout (no PR-authored code executes in it); the comment job holds the bot write token, checks out no PR code, and receives the report as an artifact.scripts/check-pr-size/— the Go module (diff parsing, generated-file classification, cap evaluation), extended with--mode,--bypass-label,--extra-lockfiles, and--extra-generated-globs, plus anover_capflag handed to the comment job so warn mode still comments. The base-ref-onlylinguist-generatedreading (a PR cannot mark its own files generated) and the Go// Code generated ... DO NOT EDIT.marker rule carry over unchanged; the marker rule simply never matches in non-Go repos..github/workflows/test-pr-size.yml— CI for the module:gofmt,go vet,go teston change (mirrorstest-cursor-review-scripts.yml).Verification
go test ./...,go vet,gofmt -l— all clean (49 tests incl. new tables for extras parsing, glob semantics, warn/enforce exit contract, report rendering).over_cap=true; warn-over → exit 0 +over_cap=true; bypass → exit 0 +over_cap=false; extras exclude lockfiles/globs; invalid--mode→ exit 2;GITHUB_STEP_SUMMARY+GITHUB_OUTPUTwrites verified.zizmor(v1.27.0): no findings on both new workflows (actions hash-pinned, app token scoped toissues/pull-requestswrite).actionlint: clean — it caught that thesecretscontext is unavailable in step-levelif, so the credentials-present test is evaluated in jobenvinstead.Judgment calls
persist-credentials: true+ token-drop dance. The original fetched the base branch with persisted credentials, then stripped the token before running the (PR-authored) checker. Here the checker is trusted (built from this repo) andfetch-depth: 0already fetches all refs during the authenticated checkout, so the job diffsbase.sha...head.shadirectly withpersist-credentials: falsethroughout — equivalent counts (three-dot uses the merge-base), simpler, and zizmor-clean.over_capflag carried in the report artifact rather than the size job's result, because inwarnmode the job is green on overage but must still comment. The flag rides the artifact (not job outputs) so it carries identically whether the size job passed or failed. A crash before rendering leaves any existing sticky comment untouched instead of overwriting it with an empty body — a small robustness improvement over the source.git clean -ffdxon the tool checkout before building, so files a PR pre-seeds under_pr_size_tool/(untracked in the tool repo, which checkout does not remove) can't be compiled into the checker.extra_generated_globsare documented in the input description (*segment-local,**cross-segment,?single char; slash-less patterns match base names at any depth) and pinned by table tests.<!-- ci-pr-size -->is kept identical so existing comments carry over when that repo flips to a thin caller).Out of scope (tracked separately): registering pr-size callers in the bump dispatcher, flipping the origin repo to a thin caller, and per-repo onboarding (cap selection, bypass-label creation, branch protection).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.