Skip to content

Add PR size checker workflow#414

Open
drsteinerdj wants to merge 2 commits into
vjuliaife:mainfrom
drsteinerdj:bounty/pr-size-checker
Open

Add PR size checker workflow#414
drsteinerdj wants to merge 2 commits into
vjuliaife:mainfrom
drsteinerdj:bounty/pr-size-checker

Conversation

@drsteinerdj

@drsteinerdj drsteinerdj commented Jun 27, 2026

Copy link
Copy Markdown

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-approved label.

Changes

  • Adds .github/workflows/pr-size.yml for pull_request size checks.
  • Counts diff size with git diff --numstat against the PR base/head SHAs.
  • Uses configurable workflow env thresholds:
    • PR_SIZE_WARN=400
    • PR_SIZE_FAIL=1000
  • Posts or updates a single PR comment when the warning or failure threshold is reached.
  • Fails the workflow at 1000+ changed lines unless large-pr-approved is present.
  • Adds .prsize-ignore for generated/noisy files:
    • package-lock.json
    • Cargo.lock
    • *.snap
    • dist/
    • target/
  • Documents the PR size policy in CONTRIBUTING.md.

Validation

  • git diff --check
  • Parsed .github/workflows/pr-size.yml with PyYAML successfully.
  • Parsed .github/protection.json with Python json successfully.
  • Confirmed workflow still supports 400+ line warning, 1000+ line hard fail, large-pr-approved bypass, and configurable PR_SIZE_WARN / PR_SIZE_FAIL.
  • Reviewed the generated workflow logic and permissions; comment writes use issues: write, repository checkout uses contents: read, and PR metadata uses pull-requests: write.

@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

The `vercel.json` schema validation failed with the following message: should NOT have additional property `rootDirectory`

Learn More: https://vercel.com/docs/concepts/projects/project-configuration

@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tariff-shield-web Error Error Jun 27, 2026 8:17pm

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread .github/workflows/pr-size.yml Outdated
Comment on lines +42 to +46
const patterns = fs.existsSync(ignorePath)
? fs.readFileSync(ignorePath, 'utf8')
.split(/\r?\n/)
.map((line) => line.trim())
.filter((line) => line && !line.startsWith('#'))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +17 to +18
size:
name: Check PR diff size

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add PR Size Checker That Warns on Large Diffs and Fails on Very Large Diffs

1 participant