-
-
Notifications
You must be signed in to change notification settings - Fork 461
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] Pull request review script #346
Conversation
Hi @madman-bob Thanks for your proposal ! On my side it looks good. I have one request for testing/fixing purpose: Can you add a --dry-run option that will print the results instead of making them ? Other than that, I've asked my colleague to review it as well. Regards, Joël |
Seems reasonable |
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.
Wow, excellent work! Thanks for this. Little comments, but very good
@@ -0,0 +1,167 @@ | |||
#!/usr/bin/env python |
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.
Is this working both on 2.7/3.x?
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.
Tested in 2.7. Works in 3.6 with a minor change to config.py. Not using any particularly exciting language features, so should work in all 3.x.
tools/review_pull_request.py
Outdated
pr_is_old = now - pull_request.created_at > timedelta(days=31 * 6) | ||
|
||
if pr_is_old and full_pull_request.comments_count == 0: | ||
pull_request.create_comment("Please re-open if necessary") |
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.
We can put here a longer text for not being rude, like:
This is an automatic message for telling you that this PR is going to be closed due to a long inactivity period.
Please ask for reopening if needed.
"""
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 a nitpicking comment here: isn't better to use the last update date? If some big PR is having a long discussion it will be auto-closed after 6 months even if there is recent conversations/reviews.
EDIT: Pedro already said that in the next review comment 😅 #346 (comment)
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.
Then the comments_count could be removed (there are inactive PRs with comments)
tools/review_pull_request.py
Outdated
now = datetime.now(pull_request.created_at.tzinfo) | ||
pr_is_old = now - pull_request.created_at > timedelta(days=31 * 6) | ||
|
||
if pr_is_old and full_pull_request.comments_count == 0: |
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.
We can have PRs with comments, but also abandoned. I think a better metric that the number of comments is the date of the PR < 6 months if no comment, but the date of the last comment < 6 months in case that you have comments.
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 was just following the requirements as lain out in the original issue. You may well be right, but I don't really want to get into discussing what the best metrics are. It should be easy enough to change, and feel free to do so, if you want to.
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.
Yeah, thanks, but as you know the API, please do it you. I give you my approval on behalf the @OCA/board
tools/review_pull_request.py
Outdated
full_pull_request = repository.pull_request(pull_request.number) | ||
|
||
now = datetime.now(pull_request.created_at.tzinfo) | ||
pr_is_old = now - pull_request.created_at > timedelta(days=31 * 6) |
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.
Put directly 365 / 2 ~= 183
I'm thinking right now about the GitHub rate limits, that can be a problem making this process. Look how I handled these limits when pulling Transifex translations. I wrap any GitHub call this way: maintainer-tools/tools/tx_pull.py Lines 137 to 166 in 20557fa
and call it this way: maintainer-tools/tools/tx_pull.py Line 277 in 20557fa
|
contributions = get_contribution_counts() | ||
|
||
for pull_request in wrap_github_call(repository.pull_requests): | ||
if contributions[pull_request.user.id] < 3: |
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 think this (and all other hardcoded values further down) should be arguments with the curernt value as default value
tools/review_pull_request.py
Outdated
) | ||
|
||
now = datetime.now(pull_request.created_at.tzinfo) | ||
pr_is_old = now - pull_request.created_at > timedelta(days=31 * 6) |
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.
same thing as above
tag_new_pull_requests(repository_name, dry_run=args.dry_run) | ||
|
||
if args.tag_all_new_pull_requests: | ||
tag_all_new_pull_requests(dry_run=args.dry_run) |
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 you pass args
to the functions, it's much simpler to implement my proposals above
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.
@hbrunn OTOH passing args as arguments would make these functions harder to compose when we will want to run them behind a webhook.
github.repository, | ||
[OCA_USERNAME, repository_name] | ||
) | ||
contributions = get_contribution_counts() |
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 concerns about the performance of this.
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.
In what way?
…ied time to determine age Rather than time created
Have rebased onto |
@madman-bob Thank you for your contribution. The @OCA/board will be testing your script in the next few months so the merge may only happen at the OCA code sprint in Belgium in October. If you want to claim the bounty earlier, please start the process (I think you have to initiate the process). |
@max3903 Thanks, but I'm only allowed to start the bounty claim once the original issue has been closed. |
@madman-bob Done |
@max3903 Thank you very much. Claim submitted. |
@sbidoul can this be closed as it has been moved to specialized repo? |
Yes! |
Add a script to automatically review pull requests in the manner described in #203.