diff --git a/miss_islington/delete_branch.py b/miss_islington/delete_branch.py index b9c7c622..f7087608 100644 --- a/miss_islington/delete_branch.py +++ b/miss_islington/delete_branch.py @@ -1,11 +1,14 @@ import asyncio +import gidgethub import gidgethub.routing +import stamina router = gidgethub.routing.Router() @router.register("pull_request", action="closed") +@stamina.retry(on=gidgethub.GitHubException, timeout=120) async def delete_branch(event, gh, *args, **kwargs): """ Delete the branch once miss-islington's PR is closed. diff --git a/miss_islington/tasks.py b/miss_islington/tasks.py index ffe74e72..f03fc9ed 100644 --- a/miss_islington/tasks.py +++ b/miss_islington/tasks.py @@ -29,7 +29,6 @@ cache = cachetools.LRUCache(maxsize=500) sentry_sdk.init(os.environ.get("SENTRY_DSN"), integrations=[CeleryIntegration()]) - CHERRY_PICKER_CONFIG = { "team": "python", "repo": "cpython", @@ -125,7 +124,7 @@ async def backport_task_asyncio( ) try: cp.backport() - except cherry_picker.BranchCheckoutException: + except cherry_picker.BranchCheckoutException as bce: await util.comment_on_pr( gh, issue_number, @@ -139,6 +138,8 @@ async def backport_task_asyncio( """, ) await util.assign_pr_to_core_dev(gh, issue_number, merged_by) + bce_state = cp.get_state_and_verify() + print(bce_state, bce) cp.abort_cherry_pick() except cherry_picker.CherryPickException as cpe: await util.comment_on_pr( @@ -153,9 +154,25 @@ async def backport_task_asyncio( """, ) await util.assign_pr_to_core_dev(gh, issue_number, merged_by) - cpe_exc = cpe cpe_state = cp.get_state_and_verify() - print(cpe_state) + print(cpe_state, cpe) + cp.abort_cherry_pick() + except cherry_picker.GitHubException as ghe: + await util.comment_on_pr( + gh, + issue_number, + f"""\ + Sorry {util.get_participants(created_by, merged_by)}, I had trouble completing the backport. + Please retry by removing and re-adding the "needs backport to {branch}" label. + Please backport backport using [cherry_picker](https://pypi.org/project/cherry-picker/) on the command line. + ``` + cherry_picker {commit_hash} {branch} + ``` + """, + ) + await util.assign_pr_to_core_dev(gh, issue_number, merged_by) + ghe_state = cp.get_state_and_verify() + print(ghe_state, ghe) cp.abort_cherry_pick() diff --git a/requirements.txt b/requirements.txt index 4ba241be..c76aed93 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,10 @@ -cherry_picker==2.4.0 -#git+https://github.com/python/cherry-picker.git@remove-initial-state#egg=cherry_picker +#cherry_picker==2.4.0 +git+https://github.com/python/cherry-picker.git@network-issues#egg=cherry_picker aiohttp==3.11.11 gidgethub==5.3.0 cachetools==5.5.0 redis==5.2.1 celery==5.4.0 sentry-sdk==2.19.2 +stamina==24.3.0 click==8.1.8