check-pr-size.yml
Diff-scoped, blocking check that fails a pull request changing more than 20 files or 600 lines. Every PR should be as small and focused as it can be while completely solving its stated task. A sweep goes out as minimal batches, one PR per batch of one concern. This implements gha#1188.
The check counts the files a PR changes and the lines it adds plus deletes, measured from the merge base to HEAD. A rename counts as one file. A binary file counts as one file and no lines.
These paths are not counted, since nobody writes them by hand: lockfiles, renv.lock, _freeze/, docs/, images, PDFs, CSV and R data files, and minified scripts. Add more with paths-ignore. A path that the repository’s .gitattributes marks linguist-generated is not counted either, so a repository marks its committed generator outputs once, and GitHub folds them in review as well (gha#1959).
The lines of a newly added _fig-* subfile are not counted either, since figure code in several languages is long but mechanical (ai-config#4928). Each such file still counts as a file, and editing an existing _fig-* file still counts its lines.
Exemptions
A pure rename (no line changed) does not count toward the file cap. A PR whose description says “mechanical, content-identical” (a pure move, rename, or split with no wording change) is exempt at any size, as one carrying the exemption label is. A diff that is a pure token substitution is exempt without either (#2050): every hunk adds as many lines as it removes, and each changed line differs from the line it replaces only by one map of at most 10 substitutions that stays the same across the PR, such as a macro renamed in every file that uses it. Each substitution swaps one name (a backslash macro or an identifier) for another. An inserted or deleted token, a phrase, punctuation, a number, or a logic word such as true, not, or never is an edit, not a substitution, so it is measured as usual. The check prints the map, so a reviewer sees exactly what was substituted. The reusable workflow reads the description live through the API. Other PRs keep the 20-file and 600-line caps (ai-config#5129).
Inputs
| Input | Default | Meaning |
|---|---|---|
max-files |
20 |
Most files a PR may change |
max-lines |
600 |
Most added plus deleted lines |
paths-ignore |
none | Extra paths not counted (*, ?, **) |
exempt-label |
size-exempt |
Label that lifts the cap, read live through the API |
pr-body |
none | The PR description (composite only; the reusable workflow reads it itself) |
fail |
true |
Block instead of warn |
python-version |
3.x |
Python used to run the check |
Scope
With no base to diff against, or when the diff cannot be computed, the check skips with a warning instead of measuring the whole tree. The caller stub triggers on labeled, unlabeled, and edited, so adding the exemption label or editing the description re-runs the check.