-
Notifications
You must be signed in to change notification settings - Fork 71
pr: add GitHub approval upon success with --approve-pr #471
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
Conversation
@GaetanLepage sorry for the ping, but wanted to know your thoughts/feedback? |
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 is a very good idea indeed!
I see myself using this.
Wdyt @SuperSandro2000 @Mic92?
I think I like the idea of this but I lack the time to properly review this. |
Thanks for the input @SuperSandro2000 I have reviewed the implementation. @ethancedwards8 it seems like there is an unused instance of |
7d09fcf
to
85f9c08
Compare
Fixed it. Thanks! |
Mhm. It feels a bit odd to me that we encourage not testing any of the build packages this way. it feels like it would make your approval less meaningfull if you haven't even tried to run the build package. I would prefer if the approval would also state that it was generated by nixpkgs-review --approve-pr in a review comment. This is especially needed for ryantm PRs where the automatic testing already happened. |
If you mean making sure the binary works/runs, couldn't that just be solved by adding versionCheckHook (or something similar) to more packages? |
I agree in general, but this is not always possible.
This scenario is a significant share of the PRs I review. This feature would make my life easier for sure. Maybe we can print a message in the terminal to warn the user about the risks of such automation. |
Could expand approve_pr like this and add the message? Than it's up to the merger what to do with this message. def approve_pr(self, pr: int, comment: str = "") -> Any:
"Approve a PR with an optional comment"
print(f"Approving {pr_url(pr)}")
data = {"event": "APPROVE"}
if comment:
data["body"] = comment
return self.post(
f"/repos/NixOS/nixpkgs/pulls/{pr}/reviews",
data=data,
) |
85f9c08
to
b984f4c
Compare
I added that feature. See here: NixOS/nixpkgs#385798 |
b984f4c
to
fb2f2a2
Compare
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.
LGTM!
I tried it and got:
|
Which PR did you test it on? |
Worked for me: NixOS/nixpkgs#386703 |
Did you run it on a PR which you opened? It might have trouble then. Not sure. I will try that |
Yeah. I ran it on a PR that I opened. NixOS/nixpkgs#373125
Since you can't approve your own PR, it freaks out. |
Is there a way to check that? |
The graphql api provides a field that tells you whether you authored the PR: query {
repository(owner: "NixOS", name: "nixpkgs") {
pullRequest(number: 387466) {
viewerDidAuthor
}
}
} Alternatively you could use the rest api to get your own user id via |
I have a little remark about this: a successful run of nixpkgs-review is not necessarily sufficient to consider a change safe. My favorite example for this is Nextcloud: the review essentially checks if the package builds, i.e. if the sources can be copied into the store-path. And this is definitely not the only case. I do understand that this is useful in many other cases and I don't think the feature itself shouldn't land. However, I'd be very grateful if you could add a note to the docs (and perhaps even a link or short note about that in the helptext) that peoople should carefully consider whether the review they're running is actually sufficient to approve a PR. |
Yes, your comment is very relevant. As mentioned above, this should only been used in specific trivial cases where the reviewing has already been done and I agree that a warning/documentation would be a good addition. |
That was also my concern, which is why suggested to make approvals created by nixpkgs-review visually different from normal approvals: https://github.com/Mic92/nixpkgs-review/pull/471/files#diff-068fea7dedadb885b7dcccc0fe1bc843caa6f1da0c6622ee7a7d56e99c31475aR421 Than it's up to the merge what to do with this information. |
I think we can just catch the error and check for the http result code and print a warning with possible explanations but without failing nixpkgs-review (since it's not crucial to normal usage of nixpkgs-review if the approval works or not). |
Would posting a GH approval ✔️ be smart if it only serves to decrease the signal to noise ratio of human review? Wouldn't it instead make sense to indicate in the nixpkgs-review report with a unique searchable string that all builds succeeded? A human can already quickly glance that a nixpkgs-review has passed, but not search for such PRs currently. I frequently search for terms like Using a unique string would both aid discoverability while not diluting the |
My understanding of the use case for this flag is the following: Maybe, people could misunderstand this, and I'm fine with adding a custom message. TLDR: For me, such automatically posted approvals should be used, and understood as plain, legitimate approvals. |
Signed-off-by: Ethan Carter Edwards <[email protected]>
fe35375
to
f5005ce
Compare
Alright, thank you everyone for your patience with me. I've had a crazy few weeks. I am a high school senior so I have been visiting colleges and wrapping up with exams. I tested catching the error against this PR: NixOS/nixpkgs#388325 and it works. Let me know if anyone has any questions. |
Also, fwiw, I have been using this for a little over two weeks with no complaints or concerns over it. https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr%20Approved%20automatically%20following%20the%20successful%20run%20of%20nixpkgs-review.%20is%3Aclosed . I think people are generally understanding of what the approval means. Like Mr. Lepage mentioned, this is pretty helpful for python package bumps. |
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.
Final nit, otherwise, LGTM!
f5005ce
to
e66c20e
Compare
This will not only fix behaviour in nixpkgs-review pr --approve-pr but also when running nixpkgs-review approve when in a PR shell. Signed-off-by: Ethan Carter Edwards <[email protected]>
This feature will add an approval to Github upon all packages building when pr is passed the flag --approve-pr Signed-off-by: Ethan Carter Edwards <[email protected]>
e66c20e
to
0b7a6f5
Compare
Tested |
Thanks @ethancedwards8 ! |
This feature will add an approval to Github upon all packages building when pr is passed the flag --approve-pr.
I found this especially needed when reviewing r-ryantm PRs as they usually can be approved if they build/pass tests