Repository navigation
Commit efee372
feat(pr-size): opt-in exclude_tests so the cap measures production code (BE-6791)
The size cap counts added + deleted lines across a PR's net diff and already
excludes generated files and dependency lockfiles. Test files were not
excluded, so a change that is mostly test coverage trips the cap even when the
production diff is small — and the only escape was the `oversized-ok` bypass
label, which signals "legitimately large" rather than "mostly tests".
Add an `exclude_tests` input (default false) that keeps test-file lines out of
the counted total. Test files are recognized by path convention: `*_test.go`;
`test_*.py` / `*_test.py` / `conftest.py`; `.test.` / `.spec.` before a JS/TS
source extension; and any file under a `test/`, `tests/`, `testing/`,
`testdata/`, `e2e/`, `__tests__/`, `__mocks__/` or `__snapshots__/` directory
segment.
Off by default deliberately. `bump-callers.sh` auto-opens SHA-bump PRs into
every calling repo, so a default-on change would propagate a weaker guardrail
fleet-wide with nobody opting in. Per-repo knobs are the established shape here
(`extra_lockfiles`, `extra_generated_globs`, `mode: warn`).
Detection is a naming convention, not a proof — unlike the Go generated marker,
which must precede the package clause, and `linguist-generated`, read from the
base ref so a PR cannot exempt itself. Nothing stops production code being
parked in `tests/`. Two mitigations: the opt-in itself, and the excluded total
is ALWAYS reported on its own line (`Excluded (tests): N`), so a large
test-only PR is visible rather than silently small. When the knob is off, test
lines are still broken out of the counted number so the option is discoverable.
Matching is on whole path segments and separator-anchored suffixes, so
`contest/`, `attestation/`, `latest.go`, `protest.go` and `manifest.ts` are
untouched. `spec/` is deliberately NOT a test directory — in this org it holds
OpenAPI schemas, which are production artifacts.
`Evaluate` now takes a `Policy` struct rather than a third positional bool;
adjacent bool parameters are silently swappable at a call site. The three
buckets never overlap — a generated file that is also a test counts once, as
generated — so counted + generated + test always sums to the diff's non-binary
changed lines regardless of policy.
Verified against Comfy-Org/cloud#6343 (the PR that prompted this): 1678 counted
today, 396 counted with the flag on, 1282 reported as test, with its
`openapi.yaml` correctly staying counted.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 2042a86 commit efee372
7 files changed
Lines changed: 446 additions & 25 deletions
File tree
- .github/workflows
- docs/callers
- scripts/check-pr-size
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
16 | 28 | | |
17 | 29 | | |
18 | 30 | | |
| |||
104 | 116 | | |
105 | 117 | | |
106 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
107 | 133 | | |
108 | 134 | | |
109 | 135 | | |
| |||
144 | 170 | | |
145 | 171 | | |
146 | 172 | | |
| 173 | + | |
147 | 174 | | |
148 | 175 | | |
149 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| 69 | + | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| |||
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
88 | 108 | | |
89 | 109 | | |
90 | 110 | | |
| |||
0 commit comments