Close PR that tries to merge maintenance branch into master#60
Close PR that tries to merge maintenance branch into master#60brettcannon merged 7 commits intopython:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #60 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 12 14 +2
Lines 780 827 +47
Branches 44 45 +1
=====================================
+ Hits 780 827 +47
Continue to review full report at Codecov.
|
brettcannon
left a comment
There was a problem hiding this comment.
The approach LGTM, but needs tests and there's some minor formatting style stuff to tweak to match PEP 8.
bedevere/close_pr.py
Outdated
| @router.register("pull_request", action="opened") | ||
| @router.register("pull_request", action="synchronize") | ||
| async def close_invalid_pr(event, gh, *args, **kwargs): | ||
| """ |
There was a problem hiding this comment.
Drop the newline from the opening docstring (for style consistency in the codebase).
bedevere/close_pr.py
Outdated
| @router.register("pull_request", action="synchronize") | ||
| async def close_invalid_pr(event, gh, *args, **kwargs): | ||
| """ | ||
| Close the invalid PR |
There was a problem hiding this comment.
Missing a period and the summary line on its own line.
bedevere/close_pr.py
Outdated
| @@ -0,0 +1,28 @@ | |||
| """Automatically close PR that tries to merge maintenance branch into master""" | |||
| import re | ||
|
|
||
| import gidgethub.routing | ||
|
|
There was a problem hiding this comment.
Missing a newline between the last import and the first global definition.
bedevere/close_pr.py
Outdated
| if PYTHON_MAINT_BRANCH_RE.match(head_label) and \ | ||
| base_label == "python:master": | ||
| data = {'state': 'closed', | ||
| 'maintainer_can_modify': True |
There was a problem hiding this comment.
Either pull the closing brace up to this line, or move all dict lines on their own, have them all end with a comma, and have the closing brace be indented to the same level as data.
|
🆗 Made the requested changes. |
brettcannon
left a comment
There was a problem hiding this comment.
There are a couple of minor style changes, but I trust you plenty to do it before merging so I'm just going to approve this now.
Thanks for the PR! I'm sure all of us who get auto-assigned to PRs will appreciate this. 😄
bedevere/__main__.py
Outdated
| from gidgethub import sansio | ||
|
|
||
| from . import backport, bpo, news, stage | ||
| from . import backport, bpo, news, stage, close_pr |
bedevere/__main__.py
Outdated
|
|
||
|
|
||
| router = routing.Router(backport.router, bpo.router, news.router, stage.router) | ||
| router = routing.Router(backport.router, bpo.router, news.router, stage.router, |
| @router.register("pull_request", action="synchronize") | ||
| async def close_invalid_pr(event, gh, *args, **kwargs): | ||
| """Close the invalid PR. | ||
| PR is considered invalid if: |
bedevere/close_pr.py
Outdated
| async def close_invalid_pr(event, gh, *args, **kwargs): | ||
| """Close the invalid PR. | ||
| PR is considered invalid if: | ||
| base_label is 'python:master', and |
There was a problem hiding this comment.
Might as well make this a list, i.e.:
* base_label is 'python:master'
* head_label is 'python:<some maintenance branch>'Otherwise put a period at the end of the sentence.
tests/test_close_pr.py
Outdated
| } | ||
| event = sansio.Event(data, event="pull_request", delivery_id="12345") | ||
| gh = FakeGH(getitem=pr_data) | ||
| await close_pr.close_invalid_pr(event, gh) |
There was a problem hiding this comment.
To help test the router for the module, it's best to call through it, e.g.:
Line 63 in 48cc643
I've learned this lesson the hard way. 😉
tests/test_close_pr.py
Outdated
| gh = FakeGH(getitem=pr_data) | ||
| await close_pr.close_invalid_pr(event, gh) | ||
| patch_data = gh.patch_data | ||
| assert patch_data is None No newline at end of file |
|
I made the suggested changes, but now I don't know how to make codecov to pass... |
|
I found the issue with why the tests weren't reaching 100% coverage (missing the |
|
Since I think we are all tired of these accidental PRs I have gone ahead and merged to get this out sooner rather than later. 😄 |
|
And obviously thanks for putting in the time to do this! |
|
Awesome! Thanks for merging and fixing the unit test 😸 |
This will close invalid PRs, so at least one less boring chore for core devs.
People in codeowners still get notified though...
A PR is considered invalid if it tries to merge
python:<maint_branch>intopython:master.For example
python:3.6intopython:master.Closes python/core-workflow#168