mirror of https://github.com/zulip/zulip.git
integrations: Ignore merge queue push events for GitHub Integration.
Previosuly, the server would send a 500 whenever a merge queue push event was encountered. Fixes #25629.
This commit is contained in:
parent
3e2d5b3c86
commit
cae02dbca4
|
@ -0,0 +1,144 @@
|
|||
{
|
||||
"ref": "refs/heads/gh-readonly-queue/main/pr-3072-287d30540ac5a1acc57d0bdc138fa81dee315f48",
|
||||
"before": "a6bd77bbe77ee6ae8f9686621b192d70fcf83e2b",
|
||||
"after": "0000000000000000000000000000000000000000",
|
||||
"repository": {
|
||||
"id": 353322834,
|
||||
"node_id": "MDEwOJllG9zcXaRcvknzNYyTzM4OUQD=",
|
||||
"name": "infra-core",
|
||||
"full_name": "some-organization/infra-core",
|
||||
"private": true,
|
||||
"owner": {
|
||||
"name": "some-organization",
|
||||
"email": null,
|
||||
"login": "some-organization",
|
||||
"id": 52709322,
|
||||
"node_id": "MDEyO9ky2ZuaXpFdhlGvjbzNzczMTO3Y",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/52709322?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/some-organization",
|
||||
"html_url": "https://github.com/some-organization",
|
||||
"followers_url": "https://api.github.com/users/some-organization/followers",
|
||||
"following_url": "https://api.github.com/users/some-organization/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/some-organization/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/some-organization/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/some-organization/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/some-organization/orgs",
|
||||
"repos_url": "https://api.github.com/users/some-organization/repos",
|
||||
"events_url": "https://api.github.com/users/some-organization/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/some-organization/received_events",
|
||||
"type": "Organization",
|
||||
"site_admin": false
|
||||
},
|
||||
"html_url": "https://github.com/some-organization/infra-core",
|
||||
"description": "Homo sapiens non urinat in ventum",
|
||||
"fork": false,
|
||||
"url": "https://github.com/some-organization/infra-core",
|
||||
"forks_url": "https://api.github.com/repos/some-organization/infra-core/forks",
|
||||
"keys_url": "https://api.github.com/repos/some-organization/infra-core/keys{/key_id}",
|
||||
"collaborators_url": "https://api.github.com/repos/some-organization/infra-core/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.github.com/repos/some-organization/infra-core/teams",
|
||||
"hooks_url": "https://api.github.com/repos/some-organization/infra-core/hooks",
|
||||
"issue_events_url": "https://api.github.com/repos/some-organization/infra-core/issues/events{/number}",
|
||||
"events_url": "https://api.github.com/repos/some-organization/infra-core/events",
|
||||
"assignees_url": "https://api.github.com/repos/some-organization/infra-core/assignees{/user}",
|
||||
"branches_url": "https://api.github.com/repos/some-organization/infra-core/branches{/branch}",
|
||||
"tags_url": "https://api.github.com/repos/some-organization/infra-core/tags",
|
||||
"blobs_url": "https://api.github.com/repos/some-organization/infra-core/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.github.com/repos/some-organization/infra-core/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.github.com/repos/some-organization/infra-core/git/refs{/sha}",
|
||||
"trees_url": "https://api.github.com/repos/some-organization/infra-core/git/trees{/sha}",
|
||||
"statuses_url": "https://api.github.com/repos/some-organization/infra-core/statuses/{sha}",
|
||||
"languages_url": "https://api.github.com/repos/some-organization/infra-core/languages",
|
||||
"stargazers_url": "https://api.github.com/repos/some-organization/infra-core/stargazers",
|
||||
"contributors_url": "https://api.github.com/repos/some-organization/infra-core/contributors",
|
||||
"subscribers_url": "https://api.github.com/repos/some-organization/infra-core/subscribers",
|
||||
"subscription_url": "https://api.github.com/repos/some-organization/infra-core/subscription",
|
||||
"commits_url": "https://api.github.com/repos/some-organization/infra-core/commits{/sha}",
|
||||
"git_commits_url": "https://api.github.com/repos/some-organization/infra-core/git/commits{/sha}",
|
||||
"comments_url": "https://api.github.com/repos/some-organization/infra-core/comments{/number}",
|
||||
"issue_comment_url": "https://api.github.com/repos/some-organization/infra-core/issues/comments{/number}",
|
||||
"contents_url": "https://api.github.com/repos/some-organization/infra-core/contents/{+path}",
|
||||
"compare_url": "https://api.github.com/repos/some-organization/infra-core/compare/{base}...{head}",
|
||||
"merges_url": "https://api.github.com/repos/some-organization/infra-core/merges",
|
||||
"archive_url": "https://api.github.com/repos/some-organization/infra-core/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.github.com/repos/some-organization/infra-core/downloads",
|
||||
"issues_url": "https://api.github.com/repos/some-organization/infra-core/issues{/number}",
|
||||
"pulls_url": "https://api.github.com/repos/some-organization/infra-core/pulls{/number}",
|
||||
"milestones_url": "https://api.github.com/repos/some-organization/infra-core/milestones{/number}",
|
||||
"notifications_url": "https://api.github.com/repos/some-organization/infra-core/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.github.com/repos/some-organization/infra-core/labels{/name}",
|
||||
"releases_url": "https://api.github.com/repos/some-organization/infra-core/releases{/id}",
|
||||
"deployments_url": "https://api.github.com/repos/some-organization/infra-core/deployments",
|
||||
"created_at": 1618165822,
|
||||
"updated_at": "2022-11-07T17:04:28Z",
|
||||
"pushed_at": 1670262117,
|
||||
"git_url": "git://github.com/some-organization/infra-core.git",
|
||||
"ssh_url": "git@github.com:some-organization/infra-core.git",
|
||||
"clone_url": "https://github.com/some-organization/infra-core.git",
|
||||
"svn_url": "https://github.com/some-organization/infra-core",
|
||||
"homepage": "https://github.com/orgs/some-organization/projects/7",
|
||||
"size": 23932,
|
||||
"stargazers_count": 4,
|
||||
"watchers_count": 4,
|
||||
"language": "Brainfuck",
|
||||
"has_issues": true,
|
||||
"has_projects": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"has_discussions": true,
|
||||
"forks_count": 1,
|
||||
"mirror_url": null,
|
||||
"archived": false,
|
||||
"disabled": false,
|
||||
"open_issues_count": 130,
|
||||
"license": {
|
||||
"key": "other",
|
||||
"name": "Other",
|
||||
"spdx_id": "NOASSERTION",
|
||||
"url": null,
|
||||
"node_id": "MDc6GTjlW5ZZzAT="
|
||||
},
|
||||
"allow_forking": false,
|
||||
"is_template": false,
|
||||
"web_commit_signoff_required": false,
|
||||
"topics": [],
|
||||
"visibility": "private",
|
||||
"forks": 1,
|
||||
"open_issues": 130,
|
||||
"watchers": 4,
|
||||
"default_branch": "main",
|
||||
"stargazers": 4,
|
||||
"master_branch": "main",
|
||||
"organization": "some-organization"
|
||||
},
|
||||
"pusher": {
|
||||
"name": "none"
|
||||
},
|
||||
"organization": {
|
||||
"login": "some-organization",
|
||||
"id": 52709322,
|
||||
"node_id": "MDEyO9kZyFua2pXhGlvdjbzNcMzOTYz3",
|
||||
"url": "https://api.github.com/orgs/some-organization",
|
||||
"repos_url": "https://api.github.com/orgs/some-organization/repos",
|
||||
"events_url": "https://api.github.com/orgs/some-organization/events",
|
||||
"hooks_url": "https://api.github.com/orgs/some-organization/hooks",
|
||||
"issues_url": "https://api.github.com/orgs/some-organization/issues",
|
||||
"members_url": "https://api.github.com/orgs/some-organization/members{/member}",
|
||||
"public_members_url": "https://api.github.com/orgs/some-organization/public_members{/member}",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/52709322?v=4",
|
||||
"description": "Plurality Media"
|
||||
},
|
||||
"installation": {
|
||||
"id": 17816238,
|
||||
"node_id": "MDIzklOdGunVcFm0WauSW9z5GFdsGb0FW9uaTMgM3zcNjg4="
|
||||
},
|
||||
"created": false,
|
||||
"deleted": true,
|
||||
"forced": false,
|
||||
"base_ref": null,
|
||||
"compare": "https://github.com/some-organization/infra-core/compare/a6bd77bbe77e...000000000000",
|
||||
"commits": [],
|
||||
"head_commit": null
|
||||
}
|
|
@ -51,6 +51,11 @@ class GitHubWebhookTest(WebhookTestCase):
|
|||
"push__local_branch_without_commits", "public-repo / feature", expected_message
|
||||
)
|
||||
|
||||
def test_push_merege_queue_ignore(self) -> None:
|
||||
self.url = self.build_webhook_url()
|
||||
payload = self.get_body("push__merge_queue")
|
||||
self.verify_post_is_ignored(payload, "push")
|
||||
|
||||
def test_push_1_commit(self) -> None:
|
||||
expected_message = "baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 1 commit to branch changes.\n\n* Update README.md ([0d1a26e67d8](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))"
|
||||
self.check_webhook("push__1_commit", TOPIC_BRANCH, expected_message)
|
||||
|
|
|
@ -639,6 +639,10 @@ def is_commit_push_event(payload: WildValue) -> bool:
|
|||
return bool(re.match(r"^refs/heads/", payload["ref"].tame(check_string)))
|
||||
|
||||
|
||||
def is_merge_queue_push_event(payload: WildValue) -> bool:
|
||||
return bool(re.match(r"^refs/heads/gh-readonly-queue/", payload["ref"].tame(check_string)))
|
||||
|
||||
|
||||
def get_subject_based_on_type(payload: WildValue, event: str) -> str:
|
||||
if "pull_request" in event:
|
||||
return TOPIC_WITH_PR_OR_ISSUE_INFO_TEMPLATE.format(
|
||||
|
@ -733,6 +737,7 @@ IGNORED_EVENTS = [
|
|||
"milestone",
|
||||
"organization",
|
||||
"project_card",
|
||||
"push__merge_queue",
|
||||
"repository_vulnerability_alert",
|
||||
]
|
||||
|
||||
|
@ -827,6 +832,8 @@ def get_zulip_event_name(
|
|||
if action in IGNORED_PULL_REQUEST_ACTIONS:
|
||||
return None
|
||||
elif header_event == "push":
|
||||
if is_merge_queue_push_event(payload):
|
||||
return None
|
||||
if is_commit_push_event(payload):
|
||||
if branches is not None:
|
||||
branch = get_branch_name_from_ref(payload["ref"].tame(check_string))
|
||||
|
|
Loading…
Reference in New Issue