Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
webhook/github: Add emoji support for check run events.
Pritesh Shetty9779763cd8c2
diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.pyindex 5bdb5676dcf..60b9794aa28 100644--- a/zerver/webhooks/github/tests.py+++ b/zerver/webhooks/github/tests.py@@ -563,12 +563,12 @@ class GitHubWebhookTest(WebhookTestCase):def test_check_run_success(self) -> None:expected_topic_name = "hello-world / checks"expected_message = """-Check [randscape](http://github.com/github/hello-world/runs/4) completed (success). ([d6fde92930d](http://github.com/github/hello-world/commit/d6fde92930d4715a2b49857d24b940956b26d2d3))+:check: Check [randscape](http://github.com/github/hello-world/runs/4) completed (success). ([d6fde92930d](http://github.com/github/hello-world/commit/d6fde92930d4715a2b49857d24b940956b26d2d3))""".strip()self.check_webhook("check_run__completed_success", expected_topic_name, expected_message)def test_check_run_failure(self) -> None:- expected_message = "Check [success_job](https://github.com/Pritesh-30/test-repo/actions/runs/21484616811/job/61890143312) completed (failure). ([e9a540c97cd](https://github.com/Pritesh-30/test-repo/commit/e9a540c97cd4efe9505bbd03bad55fe508bc863c))"+ expected_message = ":warning: Check [success_job](https://github.com/Pritesh-30/test-repo/actions/runs/21484616811/job/61890143312) completed (failure). ([e9a540c97cd](https://github.com/Pritesh-30/test-repo/commit/e9a540c97cd4efe9505bbd03bad55fe508bc863c))"self.check_webhook("check_run__completed_failure", "test-repo / checks", expected_message)def test_team_edited_description(self) -> None:diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.pyindex ae0f9ebf2c2..d27a0d4c821 100644--- a/zerver/webhooks/github/view.py+++ b/zerver/webhooks/github/view.py@@ -59,6 +59,17 @@ DISCUSSION_TEMPLATES = {"edited_body": "{sender} edited [discussion #{discussion_number}{configured_title}]({url}):\n\n{body_fence} quote\n{body}\n{body_fence}",}+CHECK_RUN_CONCLUSION_EMOJI = {+ "success": ":check:",+ "failure": ":warning:",+ "cancelled": ":not_allowed:",+ "skipped": ":fast_forward:",+ "timed_out": ":times_up:",+ "action_required": ":wrench:",+ "neutral": ":minus:",+ "stale": ":sleeping:",+}+class Helper:def __init__(@@ -800,8 +811,8 @@ def get_pull_request_review_requested_body(helper: Helper) -> str:def get_check_run_body(helper: Helper) -> str:payload = helper.payloadtemplate = """-Check [{name}]({html_url}) {status} ({conclusion}). ([{short_hash}]({commit_url}))-""".strip()+{emoji} Check [{name}]({html_url}) {status} ({conclusion}). ([{short_hash}]({commit_url}))+"""kwargs = {"name": payload["check_run"]["name"].tame(check_string),@@ -813,9 +824,14 @@ Check [{name}]({html_url}) {status} ({conclusion}). ([{short_hash}]({commit_url}payload["check_run"]["head_sha"].tame(check_string),),"conclusion": payload["check_run"]["conclusion"].tame(check_string),+ "emoji": CHECK_RUN_CONCLUSION_EMOJI.get(+ payload["check_run"]["conclusion"].tame(check_string), ""+ )+ if helper.include_emoji_indicators+ else "",}- return template.format(**kwargs)+ return template.format(**kwargs).strip()def get_star_body(helper: Helper) -> str: