-
Notifications
You must be signed in to change notification settings - Fork 118
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
feat: minimum reviewers on OWNERS file #1635
Open
Skisocks
wants to merge
20
commits into
jenkins-x:main
Choose a base branch
from
spring-financial-group:feat/min-reviewers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+695
−39
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ed3e68d
feat: minimum required reviewers on OWNERS
Skisocks f7287f4
test: update for minRequiredReviewers
Skisocks e175225
test: add tests for min required approvers
Skisocks b6f747e
feat: add required approvers text to message
Skisocks 4fc16e2
test: add updated text to tests
Skisocks d96925a
refactor: simplify AreFilesApproved
Skisocks 8473da9
fix: use the closest file to the change to get MinReviewers
Skisocks 65062ce
test: add tests cases for MinReviewers
Skisocks e1459fd
fix: use the changed files to get the min required reviewers
Skisocks 1928d45
feat: only set min reviewers if found in config
Skisocks 4a8664e
fix: escape traverse if no min reviewers found
Skisocks f95ca28
fix: default to 0 if no min reviewers found, in keeping with current …
Skisocks 0cf1e3f
test: add min reviewers to createFakeRepo
Skisocks a2fa460
test: approve handler for minimum reviewers
Skisocks 0d5911c
chore: remove redundant function
Skisocks c242327
fix: default to 1 min reviewer if not found
Skisocks 95470e0
fix: handle case where multiple reviewers but not all owners
Skisocks 57c16b1
fix: text rendering in tests
Skisocks ef54099
test: add case for 2 required approvals from different OWNERS
Skisocks d55358e
test: add more coverage of minReviewers tests
Skisocks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: add tests for min required approvers
commit e17522556672a534e0b672a64b5223c2c06ba8aa
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definition of GetRequiredApproversCount is not sufficient since it doesn't check whether the approvers are the correct ones for the files. Actually this function and the use of it should be replaced with a check in
UnapprovedFiles
where you should replaceif len(approvers) == 0 {
with
if len(approvers) < ap.owners.repo.MinimumReviewersForFile(fn) {
Or some other equivalent change.
GetFiles should get the equivalent and then using this TestGetFiles should get test cases for minimum_reviewers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, after testing a bit myself this suggestion isn't totally sufficient. The reason is that the keys of the map returned by GetFilesApprovers is "normalised" to each directory where approvers are set for the changed files. So the test "Min Reviewers/2required & root; 1 approval" started to fail since minimum_reviews are set at a deeper path than approvers are. Hopefully you can find a better solution...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@msvticket Been having difficulties implementing this as
GetOwnersSet()
(https://github.com/spring-financial-group/lighthouse/blob/main/pkg/plugins/approve/approvers/owners.go#L176) doesn't seem to return the OWNERS files that I'm expecting.o.removeSubdirs()
means that the highest level OWNERS file will always be returned for a given change, although I've now noticed that theNoParentOwners
field allows you to override this. To meNoParentOwners
should be the default behaviour (in fact this is how I thought it worked 😂), I'm wondering when you would ever not want this to be the case?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I'm aware of
NoParentOwners
I should be able to implement, this functionality just confused me 😂There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to admit that I haven't been aware of
no_parent_owners
either.Maybe you have found this already, but a function you probably need to change is Empty in repoowners.go