-
Notifications
You must be signed in to change notification settings - Fork 22
Add a review to a PR instead of a comment (issue #14) #36
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
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks for your contribution! Can you please add tests to your PR?
If it's hard to do that now (because some methods in this file are large), please note that I'm refactoring this file and adding tests as I go, e.g., see #37 for my latest refactoring; more coming soon. Let me know if something is complex or hard to test, I'm working on improving this and happy to do that to enable you to write tests easier.
Thanks again!
ghutil/ghutil.go
Outdated
@@ -416,7 +420,7 @@ func (ghc *GitHubClient) ProcessPullRequest(ctx context.Context, orgName string, | |||
} | |||
|
|||
if labelsUpdatedForNonCompliance { | |||
addComment(pullRequestNonComplianceReason) | |||
addReview(pullRequestNonComplianceReason, ReviewRequestChanges) |
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.
Can we have the tool resolve its own review if the user updates their PR such that next time, it's a compliant PR?
@mbrukman |
@mbrukman finally got the tests working. Let me know what you think. |
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.
Thanks for updating the code and adding tests! A few comments / questions below.
@@ -409,26 +414,23 @@ func (ghc *GitHubClient) ProcessPullRequest(ctx context.Context, orgName string, | |||
} else { | |||
logging.Infof(" No action needed: [%s] label already added", LabelClaYes) | |||
} | |||
|
|||
addReview(pullRequestNonComplianceReason, ReviewApprove) |
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.
If "ReviewApprove" is going to add an "approval" to the PR in the sense of getting a check mark on the PR, that's a bit of an issue, because the bot having commit permissions on the repo (which appears to be required to add/remove labels) means that just passing the CLA check gets a user a valid green check, and thus making it look like it's ready for merge.
Is there another state we can have the bot take which just resolves their comments on the PR, without approving the PR for the contents, since it's not actually reviewing the meaning of the PR, just CLA compliance?
}, | ||
}, | ||
} | ||
var prNum = 42 |
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.
You're using prNum
here, but there's already a global const pullNumber
which has the same value, and you're using both of them below, so I think you can just drop this line. Similarly in the other test method.
mockGhc.Issues.EXPECT().AddLabelsToIssue(ctx, orgName, repoName, prNum, []string{"cla: yes"}).Return(nil, nil, nil) | ||
var reviewBody = "" | ||
var body *string | ||
body = &reviewBody |
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.
Just inline &""
below where you use body
? Or if that's not possible, just inline &reviewBody
? Similarly below and in the other test method.
var reviewBody = "" | ||
var body *string | ||
body = &reviewBody | ||
var reviewEvent = "APPROVE" |
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.
Can you use the constant from the ghutil
package here and in the other test method instead of copying it here?
if labelsUpdatedForNonCompliance { | ||
addComment(pullRequestNonComplianceReason) | ||
} | ||
addReview(pullRequestNonComplianceReason, ReviewRequestChanges) |
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.
Another thing I just realized: this is a big change of behavior for crbot
, so it would be nice to control this with a command-line flag, and to be able to keep the old behavior (adding labels) as an option as well.
In fact, it would probably be safest to keep the old behavior as default, and make the new behavior something users can enable with a command-line flag, so that folks can try it out, without being suddenly surprised with a new behavior when they sync + rebuild their binaries.
@mbrukman Thanks for the feedback! Sorry it took me a while to get back to you. |
For this issue: #14
When PR is not compliant, instead of just leaving a comment, the bot would leave a "REQUEST_CHANGES" review with a message of the non-compliance.