Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

webhooks/github: Add fixtures for check run events.

Pritesh Shetty4f3dfe7f4932
diff --git a/zerver/webhooks/github/fixtures/check_run__completed_failure.json b/zerver/webhooks/github/fixtures/check_run__completed_failure.json
new file mode 100644
index 00000000000..6fe16159766
--- /dev/null
+++ b/zerver/webhooks/github/fixtures/check_run__completed_failure.json
@@ -0,0 +1,337 @@
+{
+ "action": "completed",
+ "check_run": {
+ "id": 61890143312,
+ "name": "success_job",
+ "node_id": "CR_kwDOQwktts8AAAAOaPCkUA",
+ "head_sha": "e9a540c97cd4efe9505bbd03bad55fe508bc863c",
+ "external_id": "b5080068-d305-527e-8b8b-58565a95ee08",
+ "url": "https://api.github.com/repos/Pritesh-30/test-repo/check-runs/61890143312",
+ "html_url": "https://github.com/Pritesh-30/test-repo/actions/runs/21484616811/job/61890143312",
+ "details_url": "https://github.com/Pritesh-30/test-repo/actions/runs/21484616811/job/61890143312",
+ "status": "completed",
+ "conclusion": "failure",
+ "started_at": "2026-01-29T15:42:01Z",
+ "completed_at": "2026-01-29T15:42:04Z",
+ "output": {
+ "title": null,
+ "summary": null,
+ "text": null,
+ "annotations_count": 1,
+ "annotations_url": "https://api.github.com/repos/Pritesh-30/test-repo/check-runs/61890143312/annotations"
+ },
+ "check_suite": {
+ "id": 55811931452,
+ "node_id": "CS_kwDOQwktts8AAAAM_qZ9PA",
+ "head_branch": "feature",
+ "head_sha": "e9a540c97cd4efe9505bbd03bad55fe508bc863c",
+ "status": "completed",
+ "conclusion": "failure",
+ "url": "https://api.github.com/repos/Pritesh-30/test-repo/check-suites/55811931452",
+ "before": "5e44251d2c6df83fbdbb183b36690184ff179f24",
+ "after": "e9a540c97cd4efe9505bbd03bad55fe508bc863c",
+ "pull_requests": [],
+ "app": {
+ "id": 15368,
+ "client_id": "Iv1.05c79e9ad1f6bdfa",
+ "slug": "github-actions",
+ "node_id": "MDM6QXBwMTUzNjg=",
+ "owner": {
+ "login": "github",
+ "id": 9919,
+ "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
+ "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4",
+ "gravatar_id": "",
+ "url": "https://api.github.com/users/github",
+ "html_url": "https://github.com/github",
+ "followers_url": "https://api.github.com/users/github/followers",
+ "following_url": "https://api.github.com/users/github/following{/other_user}",
+ "gists_url": "https://api.github.com/users/github/gists{/gist_id}",
+ "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}",
+ "subscriptions_url": "https://api.github.com/users/github/subscriptions",
+ "organizations_url": "https://api.github.com/users/github/orgs",
+ "repos_url": "https://api.github.com/users/github/repos",
+ "events_url": "https://api.github.com/users/github/events{/privacy}",
+ "received_events_url": "https://api.github.com/users/github/received_events",
+ "type": "Organization",
+ "user_view_type": "public",
+ "site_admin": false
+ },
+ "name": "GitHub Actions",
+ "description": "Automate your workflow from idea to production",
+ "external_url": "https://help.github.com/en/actions",
+ "html_url": "https://github.com/apps/github-actions",
+ "created_at": "2018-07-30T09:30:17Z",
+ "updated_at": "2025-12-02T18:13:15Z",
+ "permissions": {
+ "actions": "write",
+ "administration": "read",
+ "artifact_metadata": "write",
+ "attestations": "write",
+ "checks": "write",
+ "contents": "write",
+ "copilot_requests": "write",
+ "deployments": "write",
+ "discussions": "write",
+ "issues": "write",
+ "merge_queues": "write",
+ "metadata": "read",
+ "models": "read",
+ "packages": "write",
+ "pages": "write",
+ "pull_requests": "write",
+ "repository_hooks": "write",
+ "repository_projects": "write",
+ "security_events": "write",
+ "statuses": "write",
+ "vulnerability_alerts": "read"
+ },
+ "events": [
+ "branch_protection_rule",
+ "check_run",
+ "check_suite",
+ "create",
+ "delete",
+ "deployment",
+ "deployment_status",
+ "discussion",
+ "discussion_comment",
+ "fork",
+ "gollum",
+ "issues",
+ "issue_comment",
+ "label",
+ "merge_group",
+ "milestone",
+ "page_build",
+ "public",
+ "pull_request",
+ "pull_request_review",
+ "pull_request_review_comment",
+ "push",
+ "registry_package",
+ "release",
+ "repository",
+ "repository_dispatch",
+ "status",
+ "watch",
+ "workflow_dispatch",
+ "workflow_run"
+ ]
+ },
+ "created_at": "2026-01-29T15:41:57Z",
+ "updated_at": "2026-01-29T15:42:05Z"
+ },
+ "app": {
+ "id": 15368,
+ "client_id": "Iv1.05c79e9ad1f6bdfa",
+ "slug": "github-actions",
+ "node_id": "MDM6QXBwMTUzNjg=",
+ "owner": {
+ "login": "github",
+ "id": 9919,
+ "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
+ "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4",
+ "gravatar_id": "",
+ "url": "https://api.github.com/users/github",
+ "html_url": "https://github.com/github",
+ "followers_url": "https://api.github.com/users/github/followers",
+ "following_url": "https://api.github.com/users/github/following{/other_user}",
+ "gists_url": "https://api.github.com/users/github/gists{/gist_id}",
+ "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}",
+ "subscriptions_url": "https://api.github.com/users/github/subscriptions",
+ "organizations_url": "https://api.github.com/users/github/orgs",
+ "repos_url": "https://api.github.com/users/github/repos",
+ "events_url": "https://api.github.com/users/github/events{/privacy}",
+ "received_events_url": "https://api.github.com/users/github/received_events",
+ "type": "Organization",
+ "user_view_type": "public",
+ "site_admin": false
+ },
+ "name": "GitHub Actions",
+ "description": "Automate your workflow from idea to production",
+ "external_url": "https://help.github.com/en/actions",
+ "html_url": "https://github.com/apps/github-actions",
+ "created_at": "2018-07-30T09:30:17Z",
+ "updated_at": "2025-12-02T18:13:15Z",
+ "permissions": {
+ "actions": "write",
+ "administration": "read",
+ "artifact_metadata": "write",
+ "attestations": "write",
+ "checks": "write",
+ "contents": "write",
+ "copilot_requests": "write",
+ "deployments": "write",
+ "discussions": "write",
+ "issues": "write",
+ "merge_queues": "write",
+ "metadata": "read",
+ "models": "read",
+ "packages": "write",
+ "pages": "write",
+ "pull_requests": "write",
+ "repository_hooks": "write",
+ "repository_projects": "write",
+ "security_events": "write",
+ "statuses": "write",
+ "vulnerability_alerts": "read"
+ },
+ "events": [
+ "branch_protection_rule",
+ "check_run",
+ "check_suite",
+ "create",
+ "delete",
+ "deployment",
+ "deployment_status",
+ "discussion",
+ "discussion_comment",
+ "fork",
+ "gollum",
+ "issues",
+ "issue_comment",
+ "label",
+ "merge_group",
+ "milestone",
+ "page_build",
+ "public",
+ "pull_request",
+ "pull_request_review",
+ "pull_request_review_comment",
+ "push",
+ "registry_package",
+ "release",
+ "repository",
+ "repository_dispatch",
+ "status",
+ "watch",
+ "workflow_dispatch",
+ "workflow_run"
+ ]
+ },
+ "pull_requests": []
+ },
+ "repository": {
+ "id": 1124674998,
+ "node_id": "R_kgDOQwkttg",
+ "name": "test-repo",
+ "full_name": "Pritesh-30/test-repo",
+ "private": false,
+ "owner": {
+ "login": "Pritesh-30",
+ "id": 190011583,
+ "node_id": "U_kgDOC1NYvw",
+ "avatar_url": "https://avatars.githubusercontent.com/u/190011583?v=4",
+ "gravatar_id": "",
+ "url": "https://api.github.com/users/Pritesh-30",
+ "html_url": "https://github.com/Pritesh-30",
+ "followers_url": "https://api.github.com/users/Pritesh-30/followers",
+ "following_url": "https://api.github.com/users/Pritesh-30/following{/other_user}",
+ "gists_url": "https://api.github.com/users/Pritesh-30/gists{/gist_id}",
+ "starred_url": "https://api.github.com/users/Pritesh-30/starred{/owner}{/repo}",
+ "subscriptions_url": "https://api.github.com/users/Pritesh-30/subscriptions",
+ "organizations_url": "https://api.github.com/users/Pritesh-30/orgs",
+ "repos_url": "https://api.github.com/users/Pritesh-30/repos",
+ "events_url": "https://api.github.com/users/Pritesh-30/events{/privacy}",
+ "received_events_url": "https://api.github.com/users/Pritesh-30/received_events",
+ "type": "User",
+ "user_view_type": "public",
+ "site_admin": false
+ },
+ "html_url": "https://github.com/Pritesh-30/test-repo",
+ "description": null,
+ "fork": false,
+ "url": "https://api.github.com/repos/Pritesh-30/test-repo",
+ "forks_url": "https://api.github.com/repos/Pritesh-30/test-repo/forks",
+ "keys_url": "https://api.github.com/repos/Pritesh-30/test-repo/keys{/key_id}",
+ "collaborators_url": "https://api.github.com/repos/Pritesh-30/test-repo/collaborators{/collaborator}",
+ "teams_url": "https://api.github.com/repos/Pritesh-30/test-repo/teams",
+ "hooks_url": "https://api.github.com/repos/Pritesh-30/test-repo/hooks",
+ "issue_events_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/events{/number}",
+ "events_url": "https://api.github.com/repos/Pritesh-30/test-repo/events",
+ "assignees_url": "https://api.github.com/repos/Pritesh-30/test-repo/assignees{/user}",
+ "branches_url": "https://api.github.com/repos/Pritesh-30/test-repo/branches{/branch}",
+ "tags_url": "https://api.github.com/repos/Pritesh-30/test-repo/tags",
+ "blobs_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/blobs{/sha}",
+ "git_tags_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/tags{/sha}",
+ "git_refs_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/refs{/sha}",
+ "trees_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/trees{/sha}",
+ "statuses_url": "https://api.github.com/repos/Pritesh-30/test-repo/statuses/{sha}",
+ "languages_url": "https://api.github.com/repos/Pritesh-30/test-repo/languages",
+ "stargazers_url": "https://api.github.com/repos/Pritesh-30/test-repo/stargazers",
+ "contributors_url": "https://api.github.com/repos/Pritesh-30/test-repo/contributors",
+ "subscribers_url": "https://api.github.com/repos/Pritesh-30/test-repo/subscribers",
+ "subscription_url": "https://api.github.com/repos/Pritesh-30/test-repo/subscription",
+ "commits_url": "https://api.github.com/repos/Pritesh-30/test-repo/commits{/sha}",
+ "git_commits_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/commits{/sha}",
+ "comments_url": "https://api.github.com/repos/Pritesh-30/test-repo/comments{/number}",
+ "issue_comment_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/comments{/number}",
+ "contents_url": "https://api.github.com/repos/Pritesh-30/test-repo/contents/{+path}",
+ "compare_url": "https://api.github.com/repos/Pritesh-30/test-repo/compare/{base}...{head}",
+ "merges_url": "https://api.github.com/repos/Pritesh-30/test-repo/merges",
+ "archive_url": "https://api.github.com/repos/Pritesh-30/test-repo/{archive_format}{/ref}",
+ "downloads_url": "https://api.github.com/repos/Pritesh-30/test-repo/downloads",
+ "issues_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues{/number}",
+ "pulls_url": "https://api.github.com/repos/Pritesh-30/test-repo/pulls{/number}",
+ "milestones_url": "https://api.github.com/repos/Pritesh-30/test-repo/milestones{/number}",
+ "notifications_url": "https://api.github.com/repos/Pritesh-30/test-repo/notifications{?since,all,participating}",
+ "labels_url": "https://api.github.com/repos/Pritesh-30/test-repo/labels{/name}",
+ "releases_url": "https://api.github.com/repos/Pritesh-30/test-repo/releases{/id}",
+ "deployments_url": "https://api.github.com/repos/Pritesh-30/test-repo/deployments",
+ "created_at": "2025-12-29T12:22:21Z",
+ "updated_at": "2026-01-29T15:41:59Z",
+ "pushed_at": "2026-01-29T15:41:55Z",
+ "git_url": "git://github.com/Pritesh-30/test-repo.git",
+ "ssh_url": "[email protected]:Pritesh-30/test-repo.git",
+ "clone_url": "https://github.com/Pritesh-30/test-repo.git",
+ "svn_url": "https://github.com/Pritesh-30/test-repo",
+ "homepage": null,
+ "size": 2,
+ "stargazers_count": 0,
+ "watchers_count": 0,
+ "language": "CSS",
+ "has_issues": true,
+ "has_projects": true,
+ "has_downloads": true,
+ "has_wiki": true,
+ "has_pages": false,
+ "has_discussions": false,
+ "forks_count": 0,
+ "mirror_url": null,
+ "archived": false,
+ "disabled": false,
+ "open_issues_count": 6,
+ "license": null,
+ "allow_forking": true,
+ "is_template": false,
+ "web_commit_signoff_required": false,
+ "topics": [],
+ "visibility": "public",
+ "forks": 0,
+ "open_issues": 6,
+ "watchers": 0,
+ "default_branch": "feature"
+ },
+ "sender": {
+ "login": "Pritesh-30",
+ "id": 190011583,
+ "node_id": "U_kgDOC1NYvw",
+ "avatar_url": "https://avatars.githubusercontent.com/u/190011583?v=4",
+ "gravatar_id": "",
+ "url": "https://api.github.com/users/Pritesh-30",
+ "html_url": "https://github.com/Pritesh-30",
+ "followers_url": "https://api.github.com/users/Pritesh-30/followers",
+ "following_url": "https://api.github.com/users/Pritesh-30/following{/other_user}",
+ "gists_url": "https://api.github.com/users/Pritesh-30/gists{/gist_id}",
+ "starred_url": "https://api.github.com/users/Pritesh-30/starred{/owner}{/repo}",
+ "subscriptions_url": "https://api.github.com/users/Pritesh-30/subscriptions",
+ "organizations_url": "https://api.github.com/users/Pritesh-30/orgs",
+ "repos_url": "https://api.github.com/users/Pritesh-30/repos",
+ "events_url": "https://api.github.com/users/Pritesh-30/events{/privacy}",
+ "received_events_url": "https://api.github.com/users/Pritesh-30/received_events",
+ "type": "User",
+ "user_view_type": "public",
+ "site_admin": false
+ }
+}
diff --git a/zerver/webhooks/github/fixtures/check_run__completed.json b/zerver/webhooks/github/fixtures/check_run__completed_success.json
similarity index 100%
rename from zerver/webhooks/github/fixtures/check_run__completed.json
rename to zerver/webhooks/github/fixtures/check_run__completed_success.json
diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.py
index ecf988b095c..5bdb5676dcf 100644
--- a/zerver/webhooks/github/tests.py
+++ b/zerver/webhooks/github/tests.py
@@ -560,12 +560,16 @@ class GitHubWebhookTest(WebhookTestCase):
expected_message,
)
- def test_check_run(self) -> None:
+ 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))
""".strip()
- self.check_webhook("check_run__completed", expected_topic_name, expected_message)
+ 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))"
+ self.check_webhook("check_run__completed_failure", "test-repo / checks", expected_message)
def test_team_edited_description(self) -> None:
expected_topic_name = "team Testing"