X Tutup
Skip to content

Close PR that tries to merge maintenance branch into master#60

Merged
brettcannon merged 7 commits intopython:masterfrom
Mariatta:close-pr
Sep 29, 2017
Merged

Close PR that tries to merge maintenance branch into master#60
brettcannon merged 7 commits intopython:masterfrom
Mariatta:close-pr

Conversation

@Mariatta
Copy link
Copy Markdown
Member

@Mariatta Mariatta commented Sep 18, 2017

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> into python:master.
For example python:3.6 into python:master.

Closes python/core-workflow#168

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 18, 2017

Codecov Report

Merging #60 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #60   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          12     14    +2     
  Lines         780    827   +47     
  Branches       44     45    +1     
=====================================
+ Hits          780    827   +47
Impacted Files Coverage Δ
tests/test_close_pr.py 100% <100%> (ø)
bedevere/close_pr.py 100% <100%> (ø)
bedevere/__main__.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 48cc643...c3f8051. Read the comment docs.

Copy link
Copy Markdown
Member

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

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

The approach LGTM, but needs tests and there's some minor formatting style stuff to tweak to match PEP 8.

@router.register("pull_request", action="opened")
@router.register("pull_request", action="synchronize")
async def close_invalid_pr(event, gh, *args, **kwargs):
"""
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.

Drop the newline from the opening docstring (for style consistency in the codebase).

@router.register("pull_request", action="synchronize")
async def close_invalid_pr(event, gh, *args, **kwargs):
"""
Close the invalid PR
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.

Missing a period and the summary line on its own line.

@@ -0,0 +1,28 @@
"""Automatically close PR that tries to merge maintenance branch into master"""
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.

Missing a period.

import re

import gidgethub.routing

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.

Missing a newline between the last import and the first global definition.

if PYTHON_MAINT_BRANCH_RE.match(head_label) and \
base_label == "python:master":
data = {'state': 'closed',
'maintainer_can_modify': 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.

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.

@Mariatta
Copy link
Copy Markdown
Member Author

🆗 Made the requested changes.

Copy link
Copy Markdown
Member

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

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

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

from gidgethub import sansio

from . import backport, bpo, news, stage
from . import backport, bpo, news, stage, close_pr
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.

Alphabetize.



router = routing.Router(backport.router, bpo.router, news.router, stage.router)
router = routing.Router(backport.router, bpo.router, news.router, stage.router,
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.

Alphabetize.

@router.register("pull_request", action="synchronize")
async def close_invalid_pr(event, gh, *args, **kwargs):
"""Close the invalid PR.
PR is considered invalid if:
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.

Missing a blank line.

async def close_invalid_pr(event, gh, *args, **kwargs):
"""Close the invalid PR.
PR is considered invalid if:
base_label is 'python:master', and
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.

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.

}
event = sansio.Event(data, event="pull_request", delivery_id="12345")
gh = FakeGH(getitem=pr_data)
await close_pr.close_invalid_pr(event, gh)
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.

To help test the router for the module, it's best to call through it, e.g.:

await bpo.router.dispatch(event, gh)

I've learned this lesson the hard way. 😉

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

Missing a newline.

@Mariatta
Copy link
Copy Markdown
Member Author

I made the suggested changes, but now I don't know how to make codecov to pass...
Pretty sure I have all the necessary test cases.

@brettcannon brettcannon reopened this Sep 29, 2017
@brettcannon
Copy link
Copy Markdown
Member

I found the issue with why the tests weren't reaching 100% coverage (missing the "action" clause in the test data for the failing case). Now I'm just waiting for verification that coverage is good and then this is ready for merging!

@brettcannon brettcannon merged commit 9927086 into python:master Sep 29, 2017
@brettcannon
Copy link
Copy Markdown
Member

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

@brettcannon
Copy link
Copy Markdown
Member

And obviously thanks for putting in the time to do this!

@Mariatta
Copy link
Copy Markdown
Member Author

Awesome! Thanks for merging and fixing the unit test 😸

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.

bot to automatically close PRs that merge maintenance branch into master

3 participants

X Tutup