Skip to content

add support for --merge-pr#2266

Merged
damianam merged 12 commits intoeasybuilders:eb331from
boegel:merge_pr
Jul 11, 2017
Merged

add support for --merge-pr#2266
damianam merged 12 commits intoeasybuilders:eb331from
boegel:merge_pr

Conversation

@boegel
Copy link
Copy Markdown
Member

@boegel boegel commented Jul 7, 2017

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_merge function

@boegel boegel added this to the 3.4.0 milestone Jul 7, 2017
@boegel boegel requested review from a team, migueldiascosta, vanzod and verdurin July 7, 2017 23:08
Copy link
Copy Markdown
Member

@verdurin verdurin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments

Comment thread easybuild/tools/build_log.py Outdated
: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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a typo?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 'print to stdout rather than stderr'?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other way around print to stderr rather than stdout

Comment thread easybuild/tools/github.py Outdated
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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

occurred

Comment thread easybuild/tools/github.py Outdated
try:
status, data = url.put(**kwargs)
except socket.gaierror, err:
_log.warning("Error occured while performing put request: %s", err)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

occurred

Comment thread easybuild/tools/github.py Outdated
found_lgtm = False
for comment in pr_data['issue_comments']['bodies']:
if 'lgtm' in comment:
found_lgtm = True
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree on checking against approved review. Cleaner and less prone to personal quirks.

@boegel
Copy link
Copy Markdown
Member Author

boegel commented Jul 8, 2017

@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):

$ eb --merge-pr 4827 -x
== temporary log file in case of crash /tmp/eb-Gz20kc/easybuild-G3wn6E.log

easybuilders/easybuild-easyconfigs PR #4827 was submitted by nathanhaigh, you are using GitHub account 'boegel'

Checking eligibility of easybuilders/easybuild-easyconfigs PR #4827 for merging...
* targets develop branch: OK
* test suite passes: OK
* last test report is successful: (no test reports found) => not eligible for merging!
* approved review: MISSING => not eligible for merging!
* milestone is set: no milestone found => not eligible for merging!

WARNING: Review indicates this PR should not be merged (use -f/--force to do so anyway)

@boegel
Copy link
Copy Markdown
Member Author

boegel commented Jul 8, 2017

documentation update @ easybuilders/easybuild#356

@boegel boegel changed the base branch from develop to eb331 July 9, 2017 20:51
@boegel boegel modified the milestones: 3.3.1, 3.4.0 Jul 9, 2017
Comment thread easybuild/tools/github.py
def check_pr_eligible_to_merge(pr_data):
"""
Check whether PR is eligible for merging.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Comment thread easybuild/tools/github.py Outdated
print_warning("Failed to determine outcome of test report for comment:\n%s" % comment)

if 'lgtm' in comment:
found_lgtm = True
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this useless?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn't get cleaned up, indeed, thanks.

Comment thread easybuild/tools/github.py
# 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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed by checking status, thanks for bringing this up

Comment thread easybuild/tools/github.py

# 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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Comment thread easybuild/tools/github.py

# 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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Comment thread easybuild/tools/github.py
status, reviews_data = github_api_get_request(reviews_url, github_user)
pr_data['reviews'] = reviews_data

force = build_option('force')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ;-)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. ;-)

boegel added a commit to boegel/easybuild-framework that referenced this pull request Jul 10, 2017
@damianam
Copy link
Copy Markdown
Member

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?

Comment thread easybuild/tools/github.py

pr_target_account = build_option('pr_target_account')
pr_target_repo = build_option('pr_target_repo')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure pr_target_repo == GITHUB_EASYCONFIGS_REPO?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

@migueldiascosta migueldiascosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@easybuilders easybuilders deleted a comment from boegelbot Jul 11, 2017
@verdurin
Copy link
Copy Markdown
Member

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.

@damianam
Copy link
Copy Markdown
Member

Seems like it lgte (looks good to everyone ;-)). Going in!

@damianam damianam merged commit f75d294 into easybuilders:eb331 Jul 11, 2017
@boegel
Copy link
Copy Markdown
Member Author

boegel commented Jul 11, 2017

@verdurin the lgtm is no longer needed, --merge-pr will only look for an approved review (which basically is a lgtm statement)

the Going in, thanks is just being friendly, but it's not a strict requirement ;)

@boegel boegel deleted the merge_pr branch July 11, 2017 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants