From 9f3f5929958815fbc3b09bf7d046a0b78278227c Mon Sep 17 00:00:00 2001 From: dciangot Date: Sat, 21 Nov 2026 10:10:56 +0100 Subject: [PATCH] Add pull request size and scope guidelines Ask for PRs below about 500 changed lines with a single logical change, keep refactors separate from behavior changes, and describe how large work is split into a stack of PRs. Mirror the rules in the PR template and the reviewer checklist. Replace the dead external links in CONTRIBUTING.md and REVIEWING.md, which the link checker flags on every change to these files, and use an absolute URL for the contributing guide in the PR template, since a relative link does not resolve from a PR description. Signed-off-by: dciangot --- .github/PULL_REQUEST_TEMPLATE.md | 12 +++++++- CONTRIBUTING.md | 48 +++++++++++++++++++++++++++++++- REVIEWING.md | 8 ++++-- 3 files changed, 64 insertions(+), 4 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 3259778b..b3af6e88 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,7 +8,17 @@ advice. # Summary - + + +## Checklist + +- [ ] The PR changes fewer than ~500 lines (added + deleted) and does one + logical thing, see + [Pull Request Size and Scope](https://github.com/interlink-hq/interLink/blob/main/CONTRIBUTING.md#pull-request-size-and-scope) +- [ ] Refactoring and behavior changes are not mixed in this PR +- [ ] Tests for the changes are included +- [ ] Commits are signed off (`git commit -s`) and signed +- [ ] If this PR is part of a series, the previous PR it depends on is linked --- diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 452ba387..749cfd4f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,7 +27,7 @@ you submit the pull request). We have a 3 steps process for contributions. ### Sign Your Commits -[Instructions](https://contribute.cncf.io/maintainers/github/templates/required/contributing/#sign-your-commits) +[Instructions](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) ### DCO @@ -63,6 +63,52 @@ repository, you can amend your commit with the sign-off by running contribution entails. 2. **Run E2E tests with success**. You can follow the steps described [here](https://interlink-hq.github.io/interLink/docs/Developers) +3. **Keep the pull request small and focused**, as described in + [Pull Request Size and Scope](#pull-request-size-and-scope). + +### Pull Request Size and Scope + +Small pull requests are reviewed faster, reviewed more carefully and are easier +to revert. Please follow these limits; if a change cannot respect them, explain +why in the pull request description. + +| Aspect | Guideline | +| --------------------- | ---------------------------------------------------------- | +| Changed lines | Stay below **500** (added + deleted), tests included | +| Files touched | Ideally at most **15** | +| Logical changes | **One** per pull request | +| Commits | Each one builds, passes tests and is signed off and signed | +| Review turnaround aim | A reviewer should be able to finish in about 30 minutes | + +When counting changed lines, ignore generated files (for example OpenAPI +specifications and `go.sum`), vendored or lock files, and pure file moves or +renames with no content change. Check your count with `git diff --stat` against +the target branch. + +To keep within these limits: + +- **Separate refactoring from behavior changes.** A pull request either moves or + restructures code without changing what it does, or changes behavior, not + both. Say which one it is in the description. +- **Separate mechanical changes from logic.** Renames, formatting and file moves + go in their own pull request, so reviewers can skim them. +- **Add code together with its tests.** Do not postpone tests to a follow-up + pull request. +- **Introduce, then migrate, then remove.** For a replacement of an existing + mechanism, add the new code first (unused, but tested), then switch callers + over in one or more pull requests, and finally delete the old code. +- **Keep every step shippable.** After each pull request merges, `main` must + build, pass the tests and keep working for users. +- **Split large work into a stack of pull requests.** Open an issue that lists + the planned steps, and reference it from every pull request. State in the + description which pull request it depends on, and open the next one only + when the previous one is approved or merged, so that reviewers are not asked + to look at the same lines twice. +- **Do not mix in unrelated fixes.** Open a separate pull request (or issue) for + anything you notice along the way. + +A pull request description must say _what_ changed, _why_, and _how it was +tested_, following the pull request template. ### Code Review Process diff --git a/REVIEWING.md b/REVIEWING.md index c0ec1ac8..f3aadfe3 100644 --- a/REVIEWING.md +++ b/REVIEWING.md @@ -60,7 +60,7 @@ that we build trust: ## Process -[Instructions](https://contribute.cncf.io/maintainers/github/templates/recommended/reviewing/#process) +[Instructions](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/reviewing-proposed-changes-in-a-pull-request) ⚠️ **TBD** @@ -69,6 +69,10 @@ that we build trust: Below are a set of common questions that apply to all pull requests: - [ ] Is this PR targeting the correct branch? +- [ ] Is the PR small enough to review (below ~500 changed lines) and focused on + one logical change? If not, ask the author to split it, see + [Pull Request Size and Scope](CONTRIBUTING.md#pull-request-size-and-scope). +- [ ] Does the PR keep refactoring separate from behavior changes? - [ ] Does the commit message provide an adequate description of the change? - [ ] Does the affected code have corresponding tests? - [ ] Are the changes documented, not just with inline documentation, but also @@ -84,5 +88,5 @@ Reviewers are encouraged to read the following articles for help with common reviewer tasks: - [The Art of Closing: How to closing an unfinished or rejected pull request](https://blog.jessfraz.com/post/the-art-of-closing/) -- [Kindness and Code Reviews: Improving the Way We Give Feedback](https://product.voxmedia.com/2018/8/21/17549400/kindness-and-code-reviews-improving-the-way-we-give-feedback) +- [Kindness and Code Reviews: Improving the Way We Give Feedback](https://web.archive.org/web/2023/https://product.voxmedia.com/2018/8/21/17549400/kindness-and-code-reviews-improving-the-way-we-give-feedback) - [Code Review Guidelines for Humans: Examples of good and back feedback](https://phauer.com/2018/code-review-guidelines/#code-reviews-guidelines-for-the-reviewer)