Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an indicative limit for judging if a PR is too big in PR guidelines #6128

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

pchila
Copy link
Member

@pchila pchila commented Nov 22, 2024

@ycombinator: Let's wait till at least 2/3 of the reviewers tagged on this PR have approved it. It's an unusually high bar but I'd rather we clear that first than have pushback later.

What does this PR do?

Add indications about expected size of PRs in CONTRIBUTING.md

Why is it important?

To improve code review experience.

Checklist

  • [ ] My code follows the style guidelines of this project
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] I have added an entry in ./changelog/fragments using the changelog tool
  • [ ] I have added an integration test or an E2E test

Disruptive User Impact

How to test this PR locally

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

@pchila pchila added documentation Improvements or additions to documentation chore Tasks that just need to be done, they are neither bug, nor enhancements labels Nov 22, 2024
@pchila pchila self-assigned this Nov 22, 2024
@pchila pchila requested a review from a team as a code owner November 22, 2024 14:24
Copy link
Contributor

mergify bot commented Nov 22, 2024

This pull request does not have a backport label. Could you fix it @pchila? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label to automatically backport to the 8./d branch. /d is the digit

Copy link
Contributor

mergify bot commented Nov 22, 2024

backport-v8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Nov 22, 2024
@pierrehilbert
Copy link
Contributor

I'm also adding folks from my team as we are working also on the Agent repository.

Copy link
Contributor

@michalpristas michalpristas left a comment

Choose a reason for hiding this comment

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

500 seems like a reasonable limit

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Does this count unit tests in this line count? That seems low if it included unit tests, some changes have way more tests than line changes and I can see that easily going over 500 lines.

Copy link
Member

@rdner rdner left a comment

Choose a reason for hiding this comment

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

Also worried about unit-tests included in this count but I guess we will use common sense in this case.

@cmacknz
Copy link
Member

cmacknz commented Nov 25, 2024

The 500 line limit is the point where it is productive to suggest that a PR is too big, not an absolute limit that will be enforced without thought.

This is codifying that it is explicitly OK for a reviewer to suggest splitting up a PR, which will hopefully lead to the reviewer and author collaborating on the best way to split the PR to make it easier to review.

"I can't understand all this, please help me" by itself should be a fine review comment without even having a 500 line limit regardless.

@pchila
Copy link
Member Author

pchila commented Nov 26, 2024

Does this count unit tests in this line count? That seems low if it included unit tests, some changes have way more tests than line changes and I can see that easily going over 500 lines.

That is why I added the clause

(excluding generated code or other changes that normally should not require close review by a human)

to catch stuff like testdata in a unit test, generated code or anything else that does not require the same effort for review as code.

For example a super complicated unit test of 2k lines of code for a single testcase may be deemed too complicated and too big (In that case the PR could be split by separating refactoring (if needed to simplify the testcases), tests and feature code in multiple PRs maybe) but in general single unit tests should be short and easy to understand

The guideline is there to remind people that we should strive to keep the PR size small and that is ok to ask for a big change to be split in smaller ones and as @cmacknz said it's not a mindlessly automated hard limit... it will be evaluated case by case

@@ -44,6 +44,8 @@ Keep these in mind as both authors and reviewers of PRs:
- The PR must contain related changes and leave out unrelated changes (e.g. refactorings, etc. that could be their own PR instead).
- If the PR could be broken up into two or more PRs either "vertically" (by separating concerns logically) or horizontally (by sharding the PR into a series of PRs --- usually works well with mass refactoring or cleanup type PRs), it should. A set of such related PRs can be tracked and given context in a meta issue.

* The PR changeset should be rather small: 500 lines of code (excluding generated code or other changes that normally should not require close review by a human) is the soft limit that should be used to judge if a PR is "too big".
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM 👍 500 lines is also used in OTel Collector guidelines:

We recommend that any PR (unless it is trivial) to be smaller than 500 lines (excluding go mod/sum changes) in order to help reviewers to do a thorough and reasonably fast reviews.

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Thanks for the clarity. +1

@pierrehilbert
Copy link
Contributor

@kaanyalti I think we are only missing your approval here

@pchila pchila enabled auto-merge (squash) December 2, 2024 07:36
@ycombinator
Copy link
Contributor

buildkite test this

@ycombinator ycombinator force-pushed the add-size-for-pull-requests branch from 5d8bf1d to f7b342a Compare December 2, 2024 16:06
Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@ycombinator ycombinator disabled auto-merge December 2, 2024 17:04
@ycombinator ycombinator merged commit 7d4ddfd into elastic:main Dec 2, 2024
7 checks passed
mergify bot pushed a commit that referenced this pull request Dec 2, 2024
ycombinator pushed a commit that referenced this pull request Dec 13, 2024
(cherry picked from commit 7d4ddfd)

Co-authored-by: Paolo Chilà <paolo.chila@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify chore Tasks that just need to be done, they are neither bug, nor enhancements documentation Improvements or additions to documentation skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.