Skip to content

Automatically label oversized PRs to keep reviews small #204

Description

@hanayik

Problem

Large PRs are slow and lead to shallow reviews. We want a nudge toward smaller,
targeted PRs without blocking anyone.

Proposal

A GitHub Actions workflow that measures each PR and applies an
Oversized PR label when it is over budget.

  • Budget: 250 changed lines (additions + deletions)
  • Counts only .ts, .tsx, .js, .jsx (and .mts, .cts, .mjs, .cjs)
  • Skips brand-new files, so a new test or module is free
  • Skips the auto-generated asset index files
  • Adds a sticky comment listing the largest files
  • Removes the label and comment once the PR shrinks under budget
  • Advisory only: the check never fails, so nothing is blocked

How it works

  • .github/workflows/pr-size.yml runs on pull_request_target so fork PRs can be labeled
  • .github/scripts/pr-size.ts does the work through the GitHub REST API
  • The PR's code is never checked out or executed
  • Dry run locally: bun .github/scripts/pr-size.ts <pr-number> --dry-run

Reference

Against recent merged PRs, #194 came in at 134 lines and #195 at 373 lines
in existing files, so #195 would have been labeled.

Open questions

  • Is 250 the right budget?
  • Should test files be excluded from the count as well?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions