Add PR size checker workflow#414
Conversation
|
Deployment failed with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac3d802d87
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const patterns = fs.existsSync(ignorePath) | ||
| ? fs.readFileSync(ignorePath, 'utf8') | ||
| .split(/\r?\n/) | ||
| .map((line) => line.trim()) | ||
| .filter((line) => line && !line.startsWith('#')) |
There was a problem hiding this comment.
Read ignore rules from the base revision
Because this runs after checking out the PR merge commit, a large PR can modify .prsize-ignore in the same branch (for example adding ** or apps/) and this code will read those untrusted ignore rules before counting lines, reducing the total below the hard limit without the large-pr-approved label. Read the ignore file from BASE_SHA (or otherwise disallow same-PR ignore changes from affecting the count) so contributors cannot self-bypass the size gate.
Useful? React with 👍 / 👎.
| size: | ||
| name: Check PR diff size |
There was a problem hiding this comment.
Require the new size-check status before merge
The repository's branch protection is restored from .github/protection.json and docs/repo-config.md enumerates the required status checks, but this commit only adds the optional PR Size / Check PR diff size job and does not add that context to the protected checks. In the current protected-branch setup, a PR over 1000 lines can still merge once the existing required checks pass, so the advertised hard limit is not actually enforced.
Useful? React with 👍 / 👎.
Summary
Fixes #282.
Adds a pull request size guard that counts added plus deleted lines against the PR base SHA, warns on large PRs, and fails on very large PRs unless a maintainer explicitly applies the
large-pr-approvedlabel.Changes
.github/workflows/pr-size.ymlforpull_requestsize checks.git diff --numstatagainst the PR base/head SHAs.PR_SIZE_WARN=400PR_SIZE_FAIL=1000large-pr-approvedis present..prsize-ignorefor generated/noisy files:package-lock.jsonCargo.lock*.snapdist/target/CONTRIBUTING.md.Validation
git diff --check.github/workflows/pr-size.ymlwith PyYAML successfully..github/protection.jsonwith Pythonjsonsuccessfully.large-pr-approvedbypass, and configurablePR_SIZE_WARN/PR_SIZE_FAIL.issues: write, repository checkout usescontents: read, and PR metadata usespull-requests: write.