mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 18:06:44 +00:00
webhook/github: Support check_run events.
We only support notifications for events where a check run has completed. Notifications for when a check run has been queued or is in progress are not very informative and may be too noisy.
This commit is contained in:
230
zerver/webhooks/github/fixtures/check_run_completed.json
Normal file
230
zerver/webhooks/github/fixtures/check_run_completed.json
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
{
|
||||||
|
"action": "rerequested",
|
||||||
|
"check_run": {
|
||||||
|
"id": 4,
|
||||||
|
"head_sha": "d6fde92930d4715a2b49857d24b940956b26d2d3",
|
||||||
|
"external_id": "",
|
||||||
|
"url": "https://api.github.com/repos/github/hello-world/check-runs/4",
|
||||||
|
"html_url": "http://github.com/github/hello-world/runs/4",
|
||||||
|
"status": "completed",
|
||||||
|
"conclusion": "success",
|
||||||
|
"started_at": "2018-05-04T01:14:52Z",
|
||||||
|
"completed_at": "2018-05-04T01:14:52Z",
|
||||||
|
"output": {
|
||||||
|
"title": "Report",
|
||||||
|
"summary": "It's all good.",
|
||||||
|
"text": "Minus odio facilis repudiandae. Soluta odit aut amet magni nobis. Et voluptatibus ex dolorem et eum.",
|
||||||
|
"annotations_count": 2,
|
||||||
|
"annotations_url": "https://api.github.com/repos/github/hello-world/check-runs/4/annotations"
|
||||||
|
},
|
||||||
|
"name": "randscape",
|
||||||
|
"check_suite": {
|
||||||
|
"id": 5,
|
||||||
|
"head_branch": "master",
|
||||||
|
"head_sha": "d6fde92930d4715a2b49857d24b940956b26d2d3",
|
||||||
|
"status": "completed",
|
||||||
|
"conclusion": "neutral",
|
||||||
|
"url": "https://api.github.com/repos/github/hello-world/check-suites/5",
|
||||||
|
"before": "146e867f55c26428e5f9fade55a9bbf5e95a7912",
|
||||||
|
"after": "d6fde92930d4715a2b49857d24b940956b26d2d3",
|
||||||
|
"pull_requests": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"app": {
|
||||||
|
"id": 2,
|
||||||
|
"node_id": "MDExOkludGVncmF0aW9uMQ==",
|
||||||
|
"owner": {
|
||||||
|
"login": "github",
|
||||||
|
"id": 340,
|
||||||
|
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
|
||||||
|
"avatar_url": "http://alambic.github.com/avatars/u/340?",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/github",
|
||||||
|
"html_url": "http://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",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"name": "Super Duper",
|
||||||
|
"description": null,
|
||||||
|
"external_url": "http://super-duper.example.com",
|
||||||
|
"html_url": "http://github.com/apps/super-duper",
|
||||||
|
"created_at": "2018-04-25 20:42:10",
|
||||||
|
"updated_at": "2018-04-25 20:42:10"
|
||||||
|
},
|
||||||
|
"created_at": "2018-05-04T01:14:52Z",
|
||||||
|
"updated_at": "2018-05-04T01:14:52Z"
|
||||||
|
},
|
||||||
|
"app": {
|
||||||
|
"id": 2,
|
||||||
|
"node_id": "MDExOkludGVncmF0aW9uMQ==",
|
||||||
|
"owner": {
|
||||||
|
"login": "github",
|
||||||
|
"id": 340,
|
||||||
|
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
|
||||||
|
"avatar_url": "http://alambic.github.com/avatars/u/340?",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/github",
|
||||||
|
"html_url": "http://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",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"name": "Super Duper",
|
||||||
|
"description": null,
|
||||||
|
"external_url": "http://super-duper.example.com",
|
||||||
|
"html_url": "http://github.com/apps/super-duper",
|
||||||
|
"created_at": "2018-04-25 20:42:10",
|
||||||
|
"updated_at": "2018-04-25 20:42:10"
|
||||||
|
},
|
||||||
|
"pull_requests": [
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"id": 526,
|
||||||
|
"node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=",
|
||||||
|
"name": "hello-world",
|
||||||
|
"full_name": "github/hello-world",
|
||||||
|
"owner": {
|
||||||
|
"login": "github",
|
||||||
|
"id": 340,
|
||||||
|
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
|
||||||
|
"avatar_url": "http://alambic.github.com/avatars/u/340?",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/github",
|
||||||
|
"html_url": "http://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",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"private": false,
|
||||||
|
"html_url": "http://github.com/github/hello-world",
|
||||||
|
"description": null,
|
||||||
|
"fork": false,
|
||||||
|
"url": "https://api.github.com/repos/github/hello-world",
|
||||||
|
"forks_url": "https://api.github.com/repos/github/hello-world/forks",
|
||||||
|
"keys_url": "https://api.github.com/repos/github/hello-world/keys{/key_id}",
|
||||||
|
"collaborators_url": "https://api.github.com/repos/github/hello-world/collaborators{/collaborator}",
|
||||||
|
"teams_url": "https://api.github.com/repos/github/hello-world/teams",
|
||||||
|
"hooks_url": "https://api.github.com/repos/github/hello-world/hooks",
|
||||||
|
"issue_events_url": "https://api.github.com/repos/github/hello-world/issues/events{/number}",
|
||||||
|
"events_url": "https://api.github.com/repos/github/hello-world/events",
|
||||||
|
"assignees_url": "https://api.github.com/repos/github/hello-world/assignees{/user}",
|
||||||
|
"branches_url": "https://api.github.com/repos/github/hello-world/branches{/branch}",
|
||||||
|
"tags_url": "https://api.github.com/repos/github/hello-world/tags",
|
||||||
|
"blobs_url": "https://api.github.com/repos/github/hello-world/git/blobs{/sha}",
|
||||||
|
"git_tags_url": "https://api.github.com/repos/github/hello-world/git/tags{/sha}",
|
||||||
|
"git_refs_url": "https://api.github.com/repos/github/hello-world/git/refs{/sha}",
|
||||||
|
"trees_url": "https://api.github.com/repos/github/hello-world/git/trees{/sha}",
|
||||||
|
"statuses_url": "https://api.github.com/repos/github/hello-world/statuses/{sha}",
|
||||||
|
"languages_url": "https://api.github.com/repos/github/hello-world/languages",
|
||||||
|
"stargazers_url": "https://api.github.com/repos/github/hello-world/stargazers",
|
||||||
|
"contributors_url": "https://api.github.com/repos/github/hello-world/contributors",
|
||||||
|
"subscribers_url": "https://api.github.com/repos/github/hello-world/subscribers",
|
||||||
|
"subscription_url": "https://api.github.com/repos/github/hello-world/subscription",
|
||||||
|
"commits_url": "https://api.github.com/repos/github/hello-world/commits{/sha}",
|
||||||
|
"git_commits_url": "https://api.github.com/repos/github/hello-world/git/commits{/sha}",
|
||||||
|
"comments_url": "https://api.github.com/repos/github/hello-world/comments{/number}",
|
||||||
|
"issue_comment_url": "https://api.github.com/repos/github/hello-world/issues/comments{/number}",
|
||||||
|
"contents_url": "https://api.github.com/repos/github/hello-world/contents/{+path}",
|
||||||
|
"compare_url": "https://api.github.com/repos/github/hello-world/compare/{base}...{head}",
|
||||||
|
"merges_url": "https://api.github.com/repos/github/hello-world/merges",
|
||||||
|
"archive_url": "https://api.github.com/repos/github/hello-world/{archive_format}{/ref}",
|
||||||
|
"downloads_url": "https://api.github.com/repos/github/hello-world/downloads",
|
||||||
|
"issues_url": "https://api.github.com/repos/github/hello-world/issues{/number}",
|
||||||
|
"pulls_url": "https://api.github.com/repos/github/hello-world/pulls{/number}",
|
||||||
|
"milestones_url": "https://api.github.com/repos/github/hello-world/milestones{/number}",
|
||||||
|
"notifications_url": "https://api.github.com/repos/github/hello-world/notifications{?since,all,participating}",
|
||||||
|
"labels_url": "https://api.github.com/repos/github/hello-world/labels{/name}",
|
||||||
|
"releases_url": "https://api.github.com/repos/github/hello-world/releases{/id}",
|
||||||
|
"deployments_url": "https://api.github.com/repos/github/hello-world/deployments",
|
||||||
|
"created_at": "2018-04-25T20:42:10Z",
|
||||||
|
"updated_at": "2018-04-25T20:43:34Z",
|
||||||
|
"pushed_at": "2018-05-04T01:14:47Z",
|
||||||
|
"git_url": "git://github.com/github/hello-world.git",
|
||||||
|
"ssh_url": "ssh://git@localhost:3035/github/hello-world.git",
|
||||||
|
"clone_url": "http://github.com/github/hello-world.git",
|
||||||
|
"svn_url": "http://github.com/github/hello-world",
|
||||||
|
"homepage": null,
|
||||||
|
"size": 0,
|
||||||
|
"stargazers_count": 0,
|
||||||
|
"watchers_count": 0,
|
||||||
|
"language": null,
|
||||||
|
"has_issues": true,
|
||||||
|
"has_projects": true,
|
||||||
|
"has_downloads": true,
|
||||||
|
"has_wiki": true,
|
||||||
|
"has_pages": false,
|
||||||
|
"forks_count": 0,
|
||||||
|
"mirror_url": null,
|
||||||
|
"archived": false,
|
||||||
|
"open_issues_count": 3,
|
||||||
|
"license": null,
|
||||||
|
"forks": 0,
|
||||||
|
"open_issues": 3,
|
||||||
|
"watchers": 0,
|
||||||
|
"default_branch": "master"
|
||||||
|
},
|
||||||
|
"organization": {
|
||||||
|
"login": "github",
|
||||||
|
"id": 340,
|
||||||
|
"node_id": "MDEyOk9yZ2FuaXphdGlvbjM4MzAyODk5",
|
||||||
|
"url": "https://api.github.com/orgs/github",
|
||||||
|
"repos_url": "https://api.github.com/orgs/github/repos",
|
||||||
|
"events_url": "https://api.github.com/orgs/github/events",
|
||||||
|
"hooks_url": "https://api.github.com/orgs/github/hooks",
|
||||||
|
"issues_url": "https://api.github.com/orgs/github/issues",
|
||||||
|
"members_url": "https://api.github.com/orgs/github/members{/member}",
|
||||||
|
"public_members_url": "https://api.github.com/orgs/github/public_members{/member}",
|
||||||
|
"avatar_url": "http://alambic.github.com/avatars/u/340?",
|
||||||
|
"description": "How people build software."
|
||||||
|
},
|
||||||
|
"sender": {
|
||||||
|
"login": "octocat",
|
||||||
|
"id": 5346,
|
||||||
|
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
|
||||||
|
"avatar_url": "http://alambic.github.com/avatars/u/5346?",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/octocat",
|
||||||
|
"html_url": "http://github.com/octocat",
|
||||||
|
"followers_url": "https://api.github.com/users/octocat/followers",
|
||||||
|
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
||||||
|
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
||||||
|
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
||||||
|
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
||||||
|
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
||||||
|
"repos_url": "https://api.github.com/users/octocat/repos",
|
||||||
|
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
||||||
|
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
||||||
|
"type": "User",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"installation": {
|
||||||
|
"id": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
230
zerver/webhooks/github/fixtures/check_run_in_progress.json
Normal file
230
zerver/webhooks/github/fixtures/check_run_in_progress.json
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
{
|
||||||
|
"action": "created",
|
||||||
|
"check_run": {
|
||||||
|
"id": 4,
|
||||||
|
"head_sha": "d6fde92930d4715a2b49857d24b940956b26d2d3",
|
||||||
|
"external_id": "",
|
||||||
|
"url": "https://api.github.com/repos/github/hello-world/check-runs/4",
|
||||||
|
"html_url": "http://github.com/github/hello-world/runs/4",
|
||||||
|
"status": "in_progress",
|
||||||
|
"conclusion": "neutral",
|
||||||
|
"started_at": "2018-05-04T01:14:52Z",
|
||||||
|
"completed_at": "2018-05-04T01:14:52Z",
|
||||||
|
"output": {
|
||||||
|
"title": "Report",
|
||||||
|
"summary": "It's all good.",
|
||||||
|
"text": "Minus odio facilis repudiandae. Soluta odit aut amet magni nobis. Et voluptatibus ex dolorem et eum.",
|
||||||
|
"annotations_count": 2,
|
||||||
|
"annotations_url": "https://api.github.com/repos/github/hello-world/check-runs/4/annotations"
|
||||||
|
},
|
||||||
|
"name": "randscape",
|
||||||
|
"check_suite": {
|
||||||
|
"id": 5,
|
||||||
|
"head_branch": "master",
|
||||||
|
"head_sha": "d6fde92930d4715a2b49857d24b940956b26d2d3",
|
||||||
|
"status": "completed",
|
||||||
|
"conclusion": "neutral",
|
||||||
|
"url": "https://api.github.com/repos/github/hello-world/check-suites/5",
|
||||||
|
"before": "146e867f55c26428e5f9fade55a9bbf5e95a7912",
|
||||||
|
"after": "d6fde92930d4715a2b49857d24b940956b26d2d3",
|
||||||
|
"pull_requests": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"app": {
|
||||||
|
"id": 2,
|
||||||
|
"node_id": "MDExOkludGVncmF0aW9uMQ==",
|
||||||
|
"owner": {
|
||||||
|
"login": "github",
|
||||||
|
"id": 340,
|
||||||
|
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
|
||||||
|
"avatar_url": "http://alambic.github.com/avatars/u/340?",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/github",
|
||||||
|
"html_url": "http://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",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"name": "Super Duper",
|
||||||
|
"description": null,
|
||||||
|
"external_url": "http://super-duper.example.com",
|
||||||
|
"html_url": "http://github.com/apps/super-duper",
|
||||||
|
"created_at": "2018-04-25 20:42:10",
|
||||||
|
"updated_at": "2018-04-25 20:42:10"
|
||||||
|
},
|
||||||
|
"created_at": "2018-05-04T01:14:52Z",
|
||||||
|
"updated_at": "2018-05-04T01:14:52Z"
|
||||||
|
},
|
||||||
|
"app": {
|
||||||
|
"id": 2,
|
||||||
|
"node_id": "MDExOkludGVncmF0aW9uMQ==",
|
||||||
|
"owner": {
|
||||||
|
"login": "github",
|
||||||
|
"id": 340,
|
||||||
|
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
|
||||||
|
"avatar_url": "http://alambic.github.com/avatars/u/340?",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/github",
|
||||||
|
"html_url": "http://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",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"name": "Super Duper",
|
||||||
|
"description": null,
|
||||||
|
"external_url": "http://super-duper.example.com",
|
||||||
|
"html_url": "http://github.com/apps/super-duper",
|
||||||
|
"created_at": "2018-04-25 20:42:10",
|
||||||
|
"updated_at": "2018-04-25 20:42:10"
|
||||||
|
},
|
||||||
|
"pull_requests": [
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"id": 526,
|
||||||
|
"node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=",
|
||||||
|
"name": "hello-world",
|
||||||
|
"full_name": "github/hello-world",
|
||||||
|
"owner": {
|
||||||
|
"login": "github",
|
||||||
|
"id": 340,
|
||||||
|
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
|
||||||
|
"avatar_url": "http://alambic.github.com/avatars/u/340?",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/github",
|
||||||
|
"html_url": "http://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",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"private": false,
|
||||||
|
"html_url": "http://github.com/github/hello-world",
|
||||||
|
"description": null,
|
||||||
|
"fork": false,
|
||||||
|
"url": "https://api.github.com/repos/github/hello-world",
|
||||||
|
"forks_url": "https://api.github.com/repos/github/hello-world/forks",
|
||||||
|
"keys_url": "https://api.github.com/repos/github/hello-world/keys{/key_id}",
|
||||||
|
"collaborators_url": "https://api.github.com/repos/github/hello-world/collaborators{/collaborator}",
|
||||||
|
"teams_url": "https://api.github.com/repos/github/hello-world/teams",
|
||||||
|
"hooks_url": "https://api.github.com/repos/github/hello-world/hooks",
|
||||||
|
"issue_events_url": "https://api.github.com/repos/github/hello-world/issues/events{/number}",
|
||||||
|
"events_url": "https://api.github.com/repos/github/hello-world/events",
|
||||||
|
"assignees_url": "https://api.github.com/repos/github/hello-world/assignees{/user}",
|
||||||
|
"branches_url": "https://api.github.com/repos/github/hello-world/branches{/branch}",
|
||||||
|
"tags_url": "https://api.github.com/repos/github/hello-world/tags",
|
||||||
|
"blobs_url": "https://api.github.com/repos/github/hello-world/git/blobs{/sha}",
|
||||||
|
"git_tags_url": "https://api.github.com/repos/github/hello-world/git/tags{/sha}",
|
||||||
|
"git_refs_url": "https://api.github.com/repos/github/hello-world/git/refs{/sha}",
|
||||||
|
"trees_url": "https://api.github.com/repos/github/hello-world/git/trees{/sha}",
|
||||||
|
"statuses_url": "https://api.github.com/repos/github/hello-world/statuses/{sha}",
|
||||||
|
"languages_url": "https://api.github.com/repos/github/hello-world/languages",
|
||||||
|
"stargazers_url": "https://api.github.com/repos/github/hello-world/stargazers",
|
||||||
|
"contributors_url": "https://api.github.com/repos/github/hello-world/contributors",
|
||||||
|
"subscribers_url": "https://api.github.com/repos/github/hello-world/subscribers",
|
||||||
|
"subscription_url": "https://api.github.com/repos/github/hello-world/subscription",
|
||||||
|
"commits_url": "https://api.github.com/repos/github/hello-world/commits{/sha}",
|
||||||
|
"git_commits_url": "https://api.github.com/repos/github/hello-world/git/commits{/sha}",
|
||||||
|
"comments_url": "https://api.github.com/repos/github/hello-world/comments{/number}",
|
||||||
|
"issue_comment_url": "https://api.github.com/repos/github/hello-world/issues/comments{/number}",
|
||||||
|
"contents_url": "https://api.github.com/repos/github/hello-world/contents/{+path}",
|
||||||
|
"compare_url": "https://api.github.com/repos/github/hello-world/compare/{base}...{head}",
|
||||||
|
"merges_url": "https://api.github.com/repos/github/hello-world/merges",
|
||||||
|
"archive_url": "https://api.github.com/repos/github/hello-world/{archive_format}{/ref}",
|
||||||
|
"downloads_url": "https://api.github.com/repos/github/hello-world/downloads",
|
||||||
|
"issues_url": "https://api.github.com/repos/github/hello-world/issues{/number}",
|
||||||
|
"pulls_url": "https://api.github.com/repos/github/hello-world/pulls{/number}",
|
||||||
|
"milestones_url": "https://api.github.com/repos/github/hello-world/milestones{/number}",
|
||||||
|
"notifications_url": "https://api.github.com/repos/github/hello-world/notifications{?since,all,participating}",
|
||||||
|
"labels_url": "https://api.github.com/repos/github/hello-world/labels{/name}",
|
||||||
|
"releases_url": "https://api.github.com/repos/github/hello-world/releases{/id}",
|
||||||
|
"deployments_url": "https://api.github.com/repos/github/hello-world/deployments",
|
||||||
|
"created_at": "2018-04-25T20:42:10Z",
|
||||||
|
"updated_at": "2018-04-25T20:43:34Z",
|
||||||
|
"pushed_at": "2018-05-04T01:14:47Z",
|
||||||
|
"git_url": "git://github.com/github/hello-world.git",
|
||||||
|
"ssh_url": "ssh://git@localhost:3035/github/hello-world.git",
|
||||||
|
"clone_url": "http://github.com/github/hello-world.git",
|
||||||
|
"svn_url": "http://github.com/github/hello-world",
|
||||||
|
"homepage": null,
|
||||||
|
"size": 0,
|
||||||
|
"stargazers_count": 0,
|
||||||
|
"watchers_count": 0,
|
||||||
|
"language": null,
|
||||||
|
"has_issues": true,
|
||||||
|
"has_projects": true,
|
||||||
|
"has_downloads": true,
|
||||||
|
"has_wiki": true,
|
||||||
|
"has_pages": false,
|
||||||
|
"forks_count": 0,
|
||||||
|
"mirror_url": null,
|
||||||
|
"archived": false,
|
||||||
|
"open_issues_count": 3,
|
||||||
|
"license": null,
|
||||||
|
"forks": 0,
|
||||||
|
"open_issues": 3,
|
||||||
|
"watchers": 0,
|
||||||
|
"default_branch": "master"
|
||||||
|
},
|
||||||
|
"organization": {
|
||||||
|
"login": "github",
|
||||||
|
"id": 340,
|
||||||
|
"node_id": "MDEyOk9yZ2FuaXphdGlvbjM4MzAyODk5",
|
||||||
|
"url": "https://api.github.com/orgs/github",
|
||||||
|
"repos_url": "https://api.github.com/orgs/github/repos",
|
||||||
|
"events_url": "https://api.github.com/orgs/github/events",
|
||||||
|
"hooks_url": "https://api.github.com/orgs/github/hooks",
|
||||||
|
"issues_url": "https://api.github.com/orgs/github/issues",
|
||||||
|
"members_url": "https://api.github.com/orgs/github/members{/member}",
|
||||||
|
"public_members_url": "https://api.github.com/orgs/github/public_members{/member}",
|
||||||
|
"avatar_url": "http://alambic.github.com/avatars/u/340?",
|
||||||
|
"description": "How people build software."
|
||||||
|
},
|
||||||
|
"sender": {
|
||||||
|
"login": "octocat",
|
||||||
|
"id": 5346,
|
||||||
|
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
|
||||||
|
"avatar_url": "http://alambic.github.com/avatars/u/5346?",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/octocat",
|
||||||
|
"html_url": "http://github.com/octocat",
|
||||||
|
"followers_url": "https://api.github.com/users/octocat/followers",
|
||||||
|
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
||||||
|
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
||||||
|
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
||||||
|
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
||||||
|
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
||||||
|
"repos_url": "https://api.github.com/users/octocat/repos",
|
||||||
|
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
||||||
|
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
||||||
|
"type": "User",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"installation": {
|
||||||
|
"id": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -303,6 +303,26 @@ class GithubWebhookTest(WebhookTestCase):
|
|||||||
expected_message,
|
expected_message,
|
||||||
HTTP_X_GITHUB_EVENT='pull_request')
|
HTTP_X_GITHUB_EVENT='pull_request')
|
||||||
|
|
||||||
|
def test_check_run(self) -> None:
|
||||||
|
expected_topic = u"hello-world / checks"
|
||||||
|
expected_message = u"""
|
||||||
|
Check [randscape](http://github.com/github/hello-world/runs/4) completed (success). ([d6fde92](http://github.com/github/hello-world/commit/d6fde92930d4715a2b49857d24b940956b26d2d3))
|
||||||
|
""".strip()
|
||||||
|
self.send_and_test_stream_message('check_run_completed',
|
||||||
|
expected_topic,
|
||||||
|
expected_message,
|
||||||
|
HTTP_X_GITHUB_EVENT='check_run')
|
||||||
|
|
||||||
|
@patch('zerver.webhooks.github.view.check_send_webhook_message')
|
||||||
|
def test_check_run_in_progress_ignore(
|
||||||
|
self, check_send_webhook_message_mock: MagicMock) -> None:
|
||||||
|
payload = self.get_body('check_run_in_progress')
|
||||||
|
result = self.client_post(self.url, payload,
|
||||||
|
HTTP_X_GITHUB_EVENT='check_run',
|
||||||
|
content_type="application/json")
|
||||||
|
self.assertFalse(check_send_webhook_message_mock.called)
|
||||||
|
self.assert_json_success(result)
|
||||||
|
|
||||||
@patch('zerver.webhooks.github.view.check_send_webhook_message')
|
@patch('zerver.webhooks.github.view.check_send_webhook_message')
|
||||||
def test_pull_request_labeled_ignore(
|
def test_pull_request_labeled_ignore(
|
||||||
self, check_send_webhook_message_mock: MagicMock) -> None:
|
self, check_send_webhook_message_mock: MagicMock) -> None:
|
||||||
|
|||||||
@@ -335,6 +335,25 @@ def get_pull_request_review_requested_body(payload: Dict[str, Any],
|
|||||||
title=payload['pull_request']['title'] if include_title else None
|
title=payload['pull_request']['title'] if include_title else None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_check_run_body(payload: Dict[str, Any]) -> str:
|
||||||
|
template = """
|
||||||
|
Check [{name}]({html_url}) {status} ({conclusion}). ([{short_hash}]({commit_url}))
|
||||||
|
""".strip()
|
||||||
|
|
||||||
|
kwargs = {
|
||||||
|
'name': payload['check_run']['name'],
|
||||||
|
'html_url': payload['check_run']['html_url'],
|
||||||
|
'status': payload['check_run']['status'],
|
||||||
|
'short_hash': payload['check_run']['head_sha'][:7],
|
||||||
|
'commit_url': "{}/commit/{}".format(
|
||||||
|
payload['repository']['html_url'],
|
||||||
|
payload['check_run']['head_sha']
|
||||||
|
),
|
||||||
|
'conclusion': payload['check_run']['conclusion']
|
||||||
|
}
|
||||||
|
|
||||||
|
return template.format(**kwargs)
|
||||||
|
|
||||||
def get_ping_body(payload: Dict[str, Any]) -> str:
|
def get_ping_body(payload: Dict[str, Any]) -> str:
|
||||||
return get_setup_webhook_message('GitHub', get_sender_name(payload))
|
return get_setup_webhook_message('GitHub', get_sender_name(payload))
|
||||||
|
|
||||||
@@ -391,6 +410,9 @@ def get_subject_based_on_type(payload: Dict[str, Any], event: str) -> str:
|
|||||||
elif event == 'ping':
|
elif event == 'ping':
|
||||||
if payload.get('repository') is None:
|
if payload.get('repository') is None:
|
||||||
return get_organization_name(payload)
|
return get_organization_name(payload)
|
||||||
|
elif event == 'check_run':
|
||||||
|
return u"{} / checks".format(get_repository_name(payload))
|
||||||
|
|
||||||
return get_repository_name(payload)
|
return get_repository_name(payload)
|
||||||
|
|
||||||
EVENT_FUNCTION_MAPPER = {
|
EVENT_FUNCTION_MAPPER = {
|
||||||
@@ -398,6 +420,7 @@ EVENT_FUNCTION_MAPPER = {
|
|||||||
'commit_comment': get_commit_comment_body,
|
'commit_comment': get_commit_comment_body,
|
||||||
'closed_pull_request': get_closed_pull_request_body,
|
'closed_pull_request': get_closed_pull_request_body,
|
||||||
'create': partial(get_create_or_delete_body, action='created'),
|
'create': partial(get_create_or_delete_body, action='created'),
|
||||||
|
'check_run': get_check_run_body,
|
||||||
'delete': partial(get_create_or_delete_body, action='deleted'),
|
'delete': partial(get_create_or_delete_body, action='deleted'),
|
||||||
'deployment': get_deployment_body,
|
'deployment': get_deployment_body,
|
||||||
'deployment_status': get_change_deployment_status_body,
|
'deployment_status': get_change_deployment_status_body,
|
||||||
@@ -473,6 +496,10 @@ def get_event(request: HttpRequest, payload: Dict[str, Any], branches: str) -> O
|
|||||||
return "push_commits"
|
return "push_commits"
|
||||||
else:
|
else:
|
||||||
return "push_tags"
|
return "push_tags"
|
||||||
|
elif event == 'check_run':
|
||||||
|
if payload['check_run']['status'] != 'completed':
|
||||||
|
return None
|
||||||
|
return event
|
||||||
elif event in list(EVENT_FUNCTION_MAPPER.keys()) or event == 'ping':
|
elif event in list(EVENT_FUNCTION_MAPPER.keys()) or event == 'ping':
|
||||||
return event
|
return event
|
||||||
elif event in IGNORED_EVENTS:
|
elif event in IGNORED_EVENTS:
|
||||||
|
|||||||
Reference in New Issue
Block a user