Skip to content

Commit 6326600

Browse files
authored
Disable CI status change comments unless the "automerge" label is used (#578)
1 parent f89f450 commit 6326600

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

miss_islington/status_change.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ async def check_status(event, gh, *args, **kwargs):
2222
event.data["commit"].get("committer")
2323
and event.data["commit"]["committer"]["login"] == "miss-islington"
2424
):
25-
await check_ci_status_and_approval(gh, sha, leave_comment=True)
25+
# Leave comment temporarily disabled when automerge not used. See #577.
26+
await check_ci_status_and_approval(gh, sha, leave_comment=False)
2627
else:
2728
pr_for_commit = await util.get_pr_for_commit(gh, sha)
2829
if pr_for_commit:
@@ -106,12 +107,9 @@ async def check_ci_status_and_approval(
106107
)
107108
success = result["state"] == "success" and not failure
108109
if leave_comment:
109-
if failure:
110+
if failure or not success:
110111
emoji = "❌"
111112
status = "it's a failure or timed out"
112-
elif not success:
113-
emoji = "❌"
114-
status = "it's a failure"
115113
else:
116114
emoji = "✅"
117115
status = "it's a success"

tests/test_status_change.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ async def test_ci_passed_with_awaiting_merge_label_pr_is_merged():
129129

130130
gh = FakeGH(getitem=getitem, getiter=getiter)
131131
await status_change.router.dispatch(event, gh)
132-
expected_body = "Status check is done, and it's a success ✅."
133-
assert gh.post_data["body"] == expected_body
132+
# Leave comment temporarily disabled when automerge not used. See #577.
133+
# expected_body = "Status check is done, and it's a success ✅."
134+
# assert gh.post_data["body"] == expected_body
134135
assert gh.put_data["sha"] == sha # is merged
135136
assert gh.put_data["merge_method"] == "squash"
136137
assert (
@@ -197,8 +198,9 @@ async def test_ci_and_check_run_passed_with_no_awaiting_merge_label_pr_is_not_me
197198

198199
gh = FakeGH(getitem=getitem)
199200
await status_change.router.dispatch(event, gh)
200-
expected_body = "Status check is done, and it's a success ✅."
201-
assert gh.post_data["body"] == expected_body
201+
# Leave comment temporarily disabled when automerge not used. See #577.
202+
# expected_body = "Status check is done, and it's a success ✅."
203+
# assert gh.post_data["body"] == expected_body
202204
assert not hasattr(gh, "put_data") # is not merged
203205

204206

@@ -254,8 +256,9 @@ async def test_ci_not_passed_awaiting_merge_label_pr_is_not_merged():
254256

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

261264

@@ -323,8 +326,9 @@ async def test_ci_passed_and_check_run_failure_awaiting_merge_label_pr_is_not_me
323326

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

330334

@@ -471,8 +475,9 @@ async def test_ci_passed_and_check_run_pending_awaiting_merge_label_pr_is_not_me
471475

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

478483

@@ -540,9 +545,10 @@ async def test_ci_passed_and_check_run_timed_out_awaiting_merge_label_pr_is_not_
540545

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

548554

0 commit comments

Comments
 (0)