add support for --merge-pr#2266
Conversation
| :param silent: be silent (only log, don't print) | ||
| :param prefix: include message prefix characters ('== ') | ||
| :param newline: end message with newline | ||
| :param stderr: print to stderr rather than stderr |
There was a problem hiding this comment.
Should be 'print to stdout rather than stderr'?
There was a problem hiding this comment.
The other way around print to stderr rather than stdout
| status, data = url.get(**kwargs) | ||
| except socket.gaierror, err: | ||
| _log.warning("Error occured while performing get request: %s" % err) | ||
| _log.warning("Error occured while performing get request: %s", err) |
| try: | ||
| status, data = url.put(**kwargs) | ||
| except socket.gaierror, err: | ||
| _log.warning("Error occured while performing put request: %s", err) |
| found_lgtm = False | ||
| for comment in pr_data['issue_comments']['bodies']: | ||
| if 'lgtm' in comment: | ||
| found_lgtm = True |
There was a problem hiding this comment.
According to this all maintainers have to use the formulation 'lgtm' then, for this test to work? Worth mentioning that in the contributors' guide, if it isn't there already.
There was a problem hiding this comment.
I want to relax this a bit and also make this check pass when an approved review is submitted, especially since that's required now to merge (via the web interface).
There was a problem hiding this comment.
I agree on checking against approved review. Cleaner and less prone to personal quirks.
|
@verdurin Please re-review, and maybe also give it a try yourself? Example usage (I'll write up documentation too) in dry run mode (only difference is that submitted the comment and actually merging are not done if PR is eligible for merging): |
|
documentation update @ easybuilders/easybuild#356 |
| def check_pr_eligible_to_merge(pr_data): | ||
| """ | ||
| Check whether PR is eligible for merging. | ||
|
|
There was a problem hiding this comment.
More of a question rather than a comment, this empty line sometimes exists sometimes doesn't. Shouldn't we stick to one style? Or is there a reason for it? I favour having it.
There was a problem hiding this comment.
We should stick to one style, and I generally prefer having a blank line there as well, but the only way to make this consistent is to have an automated style check for it...
| print_warning("Failed to determine outcome of test report for comment:\n%s" % comment) | ||
|
|
||
| if 'lgtm' in comment: | ||
| found_lgtm = True |
There was a problem hiding this comment.
This didn't get cleaned up, indeed, thanks.
| # also fetch status of last commit | ||
| pr_head_sha = pr_data['head']['sha'] | ||
| status_url = lambda g: g.repos[pr_target_account][pr_target_repo].commits[pr_head_sha].status | ||
| status, status_data = github_api_get_request(status_url, github_user) |
There was a problem hiding this comment.
If status is not used, maybe it makes sense to replace it with _ to make it clear? Even though I'd suggest to check the status here too, as individual consecutive requests might return different status.
There was a problem hiding this comment.
fixed by checking status, thanks for bringing this up
|
|
||
| # also fetch comments | ||
| comments_url = lambda g: g.repos[pr_target_account][pr_target_repo].issues[pr].comments | ||
| status, comments_data = github_api_get_request(comments_url, github_user) |
|
|
||
| # also fetch reviews | ||
| reviews_url = lambda g: g.repos[pr_target_account][pr_target_repo].pulls[pr].reviews | ||
| status, reviews_data = github_api_get_request(reviews_url, github_user) |
| status, reviews_data = github_api_get_request(reviews_url, github_user) | ||
| pr_data['reviews'] = reviews_data | ||
|
|
||
| force = build_option('force') |
There was a problem hiding this comment.
I wouldn't give this possibility. If it is not elegible for merging it needs more careful evaluation. Slapping --force is an easy way out for potentially lazy maintainers.
There was a problem hiding this comment.
I disagree here, in rare cases it makes sense to merge a PR that doesn't strictly meet all requirements.
For example, when only trivial changes are made that do not add new easyconfigs and do not alter the semantics of existing easyconfigs, we can merge it without requiring a test report. One recent example is easybuilders/easybuild-easyconfigs#4815...
I would rather have maintainers use --merge-pr X --force after running it without --force first, than favouring manual merges where it's easier to overlook one of the other requirements. Of course, people shouldn't be using --force all the time...
There was a problem hiding this comment.
That's a good point and a good example. I was thinking more about new additions or version changes, than that kind of small tuning. I guess it makes sense then. But I wonder if a middle ground is possible. In other words, check what is the nature of the changes, and reject to merge, even with --force, if new files are added, or there are changes in version, toolchain, configopts, etc, but allow it if the changes are just comments, or description, whatis and maybe one or two more parameters. That's probably a PITA to implement and possibly not worth the effort though, as long as all behave responsibly ;-)
There was a problem hiding this comment.
That would be nice, but that's definitely tricky to implement, and I'm not sure it'll be worth the trouble...
We can always look into that enhancement later though, if we find it's really necessary, but I don't expect that maintainers will go and 'abuse' --merge-pr X --force, to avoid tarring & feathering by the other maintainers. ;-)
…1 release notes
|
I haven't have time to take a look at the tests, but otherwise lgtm. I'll try to take a look at the tests tomorrow. Anyway, maybe @vanzod or @migueldiascosta can give their feedback too before merging? |
|
|
||
| pr_target_account = build_option('pr_target_account') | ||
| pr_target_repo = build_option('pr_target_repo') | ||
|
|
There was a problem hiding this comment.
make sure pr_target_repo == GITHUB_EASYCONFIGS_REPO?
There was a problem hiding this comment.
Well, we could be a bit smarter, and skip the check for a successful test report for other repositories, since the other checks are just as important for framework & easyblocks?
There was a problem hiding this comment.
I'd even argue that for easyblocks a successful test report might be just as important as for the easyconfigs repo, given that both decide how the software is built. But we would have to make sure that the easyblock is used in the easyconfigs being built. In any case, I thought that at this moment the github integration worked just with the easyconfigs repo, so I wouldn't delay this PR because of this.
There was a problem hiding this comment.
We don't have a way to submit test reports for easyblock PRs yet.
It's true that currently most GitHub-related options only work with the easyconfigs repo for now, but the intention is to extend that to also easyblocks/framework, certainly for --new-pr and --update-pr.
The extra effort here to make --merge-pr also work well for the easyblocks & framework repos is minimal, see 17789d5.
|
Looks good, just wanted to reiterate my earlier comment that if we're expecting 'lgtm' and 'Going in, thanks...' for each PR, then that should be documented. |
|
Seems like it lgte (looks good to everyone ;-)). Going in! |
|
@verdurin the the |
support for
eb --merge-pr, meant to help EasyBuild maintainers merging PRs (easyconfigs only for now)checks the requirements documented at http://easybuild.readthedocs.io/en/latest/Contributing.html#requirements-for-pull-requests as best as possible, see implementation of the
check_pr_eligible_to_mergefunction