Skip to content

Commit

Permalink
Disable CI status change comments unless the "automerge" label is used
Browse files Browse the repository at this point in the history
Works around #577
  • Loading branch information
ambv committed Sep 9, 2022
1 parent f89f450 commit b19c203
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
3 changes: 2 additions & 1 deletion miss_islington/status_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ async def check_status(event, gh, *args, **kwargs):
event.data["commit"].get("committer")
and event.data["commit"]["committer"]["login"] == "miss-islington"
):
await check_ci_status_and_approval(gh, sha, leave_comment=True)
# Leave comment temporarily disabled when automerge not used. See #577.
await check_ci_status_and_approval(gh, sha, leave_comment=False)
else:
pr_for_commit = await util.get_pr_for_commit(gh, sha)
if pr_for_commit:
Expand Down
32 changes: 19 additions & 13 deletions tests/test_status_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ async def test_ci_passed_with_awaiting_merge_label_pr_is_merged():

gh = FakeGH(getitem=getitem, getiter=getiter)
await status_change.router.dispatch(event, gh)
expected_body = "Status check is done, and it's a success βœ…."
assert gh.post_data["body"] == expected_body
# Leave comment temporarily disabled when automerge not used. See #577.
# expected_body = "Status check is done, and it's a success βœ…."
# assert gh.post_data["body"] == expected_body
assert gh.put_data["sha"] == sha # is merged
assert gh.put_data["merge_method"] == "squash"
assert (
Expand Down Expand Up @@ -197,8 +198,9 @@ async def test_ci_and_check_run_passed_with_no_awaiting_merge_label_pr_is_not_me

gh = FakeGH(getitem=getitem)
await status_change.router.dispatch(event, gh)
expected_body = "Status check is done, and it's a success βœ…."
assert gh.post_data["body"] == expected_body
# Leave comment temporarily disabled when automerge not used. See #577.
# expected_body = "Status check is done, and it's a success βœ…."
# assert gh.post_data["body"] == expected_body
assert not hasattr(gh, "put_data") # is not merged


Expand Down Expand Up @@ -254,8 +256,9 @@ async def test_ci_not_passed_awaiting_merge_label_pr_is_not_merged():

gh = FakeGH(getitem=getitem)
await status_change.router.dispatch(event, gh)
expected_body = "@miss-islington and @Mariatta: Status check is done, and it's a failure ❌."
assert gh.post_data["body"] == expected_body
# Leave comment temporarily disabled when automerge not used. See #577.
# expected_body = "@miss-islington and @Mariatta: Status check is done, and it's a failure ❌."
# assert gh.post_data["body"] == expected_body
assert not hasattr(gh, "put_data") # is not merged


Expand Down Expand Up @@ -323,8 +326,9 @@ async def test_ci_passed_and_check_run_failure_awaiting_merge_label_pr_is_not_me

gh = FakeGH(getitem=getitem, getiter=getiter)
await status_change.router.dispatch(event, gh)
expected_body = "@miss-islington and @Mariatta: Status check is done, and it's a failure or timed out ❌."
assert gh.post_data["body"] == expected_body
# Leave comment temporarily disabled when automerge not used. See #577.
# expected_body = "@miss-islington and @Mariatta: Status check is done, and it's a failure or timed out ❌."
# assert gh.post_data["body"] == expected_body
assert not hasattr(gh, "put_data") # is not merged


Expand Down Expand Up @@ -471,8 +475,9 @@ async def test_ci_passed_and_check_run_pending_awaiting_merge_label_pr_is_not_me

gh = FakeGH(getitem=getitem, getiter=getiter)
await status_change.router.dispatch(event, gh)
expected_body = "@miss-islington and @Mariatta: Status check is done, and it's a failure or timed out ❌."
assert gh.post_data["body"] == expected_body
# Leave comment temporarily disabled when automerge not used. See #577.
# expected_body = "@miss-islington and @Mariatta: Status check is done, and it's a failure or timed out ❌."
# assert gh.post_data["body"] == expected_body
assert not hasattr(gh, "put_data") # is not merged


Expand Down Expand Up @@ -540,9 +545,10 @@ async def test_ci_passed_and_check_run_timed_out_awaiting_merge_label_pr_is_not_

gh = FakeGH(getitem=getitem, getiter=getiter)
await status_change.router.dispatch(event, gh)
expected_body = ("@miss-islington and @Mariatta: Status check is done, "
"and it's a failure or timed out ❌.")
assert gh.post_data["body"] == expected_body
# Leave comment temporarily disabled when automerge not used. See #577.
# expected_body = ("@miss-islington and @Mariatta: Status check is done, "
# "and it's a failure or timed out ❌.")
# assert gh.post_data["body"] == expected_body
assert not hasattr(gh, "put_data") # is not merged


Expand Down

0 comments on commit b19c203

Please sign in to comment.