Skip to content

Commit 9ace2ec

Browse files
alxmythfusion-bot[bot]
authored and
fusion-bot[bot]
committed
Skip required buildkite check for pre-release pull requests
#136 Co-authored-by: Alexander Smith <amsmith@uber.com>
1 parent f2136db commit 9ace2ec

4 files changed

+531
-2
lines changed

src/__tests__/auto-approve-and-land-prereleases.test.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import app from '../auto-approve-and-land-prereleases.js';
33

44
import nonReleasePayload from './fixtures/non-release-payload.json';
55
import prereleasePayload from './fixtures/prerelease-payload.json';
6+
import statusPendingBuildPayload from './fixtures/status-pending-build-payload.json';
7+
import statusPendingNonBuildPayload from './fixtures/status-pending-non-build-payload.json';
68

79
describe('auto-approve-and-land-prereleases', () => {
810
let robot;
@@ -78,4 +80,44 @@ describe('auto-approve-and-land-prereleases', () => {
7880
expect(createReviewCalls.length).toBe(0);
7981
expect(mergeCalls.length).toBe(0);
8082
});
83+
84+
it('skip required build check', async () => {
85+
github = {
86+
repos: {
87+
createStatus: jest.fn().mockReturnValue(Promise.resolve(true)),
88+
},
89+
};
90+
// Passes the mocked out GitHub API into out robot instance
91+
robot.auth = () => Promise.resolve(github);
92+
93+
await robot.receive({
94+
event: 'status',
95+
payload: statusPendingBuildPayload,
96+
});
97+
98+
// Should immediately set success
99+
const statusCalls = github.repos.createStatus.mock.calls;
100+
expect(github.repos.createStatus).toHaveBeenCalled();
101+
expect(statusCalls.length).toBe(1);
102+
expect(statusCalls[0][0].state).toBe('success');
103+
});
104+
105+
it('no op on non-build status checks', async () => {
106+
github = {
107+
repos: {
108+
createStatus: jest.fn().mockReturnValue(Promise.resolve(true)),
109+
},
110+
};
111+
// Passes the mocked out GitHub API into out robot instance
112+
robot.auth = () => Promise.resolve(github);
113+
114+
await robot.receive({
115+
event: 'status',
116+
payload: statusPendingNonBuildPayload,
117+
});
118+
119+
// Should be a no-op
120+
const statusCalls = github.repos.createStatus.mock.calls;
121+
expect(github.repos.createStatus).not.toHaveBeenCalled();
122+
});
81123
});
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
{
2+
"id": 6216527622,
3+
"sha": "a754d7072c822c94da15ee7e4e1dfcac065b2774",
4+
"name": "AlexMSmithCA/probot-app-label-dependency-pr",
5+
"target_url": null,
6+
"context": "buildkite/probot-app-label-dependency-pr",
7+
"description": "Release label has been set (or unset)",
8+
"state": "pending",
9+
"commit": {
10+
"sha": "a754d7072c822c94da15ee7e4e1dfcac065b2774",
11+
"node_id": "MDY6Q29tbWl0MTQ2NjcxNTAzOmE3NTRkNzA3MmM4MjJjOTRkYTE1ZWU3ZTRlMWRmY2FjMDY1YjI3NzQ=",
12+
"commit": {
13+
"author": {
14+
"name": "Alexander Smith",
15+
"email": "AlexMSmithCA@gmail.com",
16+
"date": "2019-02-07T05:39:25Z"
17+
},
18+
"committer": {
19+
"name": "GitHub",
20+
"email": "noreply@github.com",
21+
"date": "2019-02-07T05:39:25Z"
22+
},
23+
"message": "Release v1.0.0-0",
24+
"tree": {
25+
"sha": "4fa1c254fa5b9eff880e52e3d635a735fe1f1efa",
26+
"url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/git/trees/4fa1c254fa5b9eff880e52e3d635a735fe1f1efa"
27+
},
28+
"url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/git/commits/a754d7072c822c94da15ee7e4e1dfcac065b2774",
29+
"comment_count": 0,
30+
"verification": {
31+
"verified": true,
32+
"reason": "valid",
33+
"signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJcW8SNCRBK7hj4Ov3rIwAAdHIIAA+SLYW7PxxgO6E4z0UV0R1r\n2cCXSEVe/IFuCtWtpTZsYjcgSkia3PeX9rJAFttWk3fBIQKyYKnTp/9rqO9G6QnC\ngmc21h5fwbvxfgmxhlwQeSbOyI4KoOdLHnHG9IMak/4bVvBSJPF0SVv7m/powh63\nG2dQZlhQkx6x/DWoGK8GfRLzqZQwXPWn2rZbubomhzo+ddt/zojZtJRbjwEnXCcK\nmg6TsUWzEtp19VvZ4GQx0UEoxrXD9WHZC1w7VIqWnFeTkLoF+1ydB2ldLezCaWgC\nFuEpy4SP7EaqMgC1fIzRR+zRw2PkxqwS/LZ0ivwk9U5ykWkGAEGGgOBghloNbqY=\n=halt\n-----END PGP SIGNATURE-----\n",
34+
"payload": "tree 4fa1c254fa5b9eff880e52e3d635a735fe1f1efa\nparent 244ac3fd88c730496b8e4c38ee7e6aa404538942\nauthor Alexander Smith <AlexMSmithCA@gmail.com> 1549517965 -0800\ncommitter GitHub <noreply@github.com> 1549517965 -0800\n\nRelease v1.0.0-0"
35+
}
36+
},
37+
"url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/commits/a754d7072c822c94da15ee7e4e1dfcac065b2774",
38+
"html_url": "https://github.com/AlexMSmithCA/probot-app-label-dependency-pr/commit/a754d7072c822c94da15ee7e4e1dfcac065b2774",
39+
"comments_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/commits/a754d7072c822c94da15ee7e4e1dfcac065b2774/comments",
40+
"author": {
41+
"login": "AlexMSmithCA",
42+
"id": 3497835,
43+
"node_id": "MDQ6VXNlcjM0OTc4MzU=",
44+
"avatar_url": "https://avatars3.githubusercontent.com/u/3497835?v=4",
45+
"gravatar_id": "",
46+
"url": "https://api.github.com/users/AlexMSmithCA",
47+
"html_url": "https://github.com/AlexMSmithCA",
48+
"followers_url": "https://api.github.com/users/AlexMSmithCA/followers",
49+
"following_url": "https://api.github.com/users/AlexMSmithCA/following{/other_user}",
50+
"gists_url": "https://api.github.com/users/AlexMSmithCA/gists{/gist_id}",
51+
"starred_url": "https://api.github.com/users/AlexMSmithCA/starred{/owner}{/repo}",
52+
"subscriptions_url": "https://api.github.com/users/AlexMSmithCA/subscriptions",
53+
"organizations_url": "https://api.github.com/users/AlexMSmithCA/orgs",
54+
"repos_url": "https://api.github.com/users/AlexMSmithCA/repos",
55+
"events_url": "https://api.github.com/users/AlexMSmithCA/events{/privacy}",
56+
"received_events_url": "https://api.github.com/users/AlexMSmithCA/received_events",
57+
"type": "User",
58+
"site_admin": false
59+
},
60+
"committer": {
61+
"login": "web-flow",
62+
"id": 19864447,
63+
"node_id": "MDQ6VXNlcjE5ODY0NDQ3",
64+
"avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4",
65+
"gravatar_id": "",
66+
"url": "https://api.github.com/users/web-flow",
67+
"html_url": "https://github.com/web-flow",
68+
"followers_url": "https://api.github.com/users/web-flow/followers",
69+
"following_url": "https://api.github.com/users/web-flow/following{/other_user}",
70+
"gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}",
71+
"starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}",
72+
"subscriptions_url": "https://api.github.com/users/web-flow/subscriptions",
73+
"organizations_url": "https://api.github.com/users/web-flow/orgs",
74+
"repos_url": "https://api.github.com/users/web-flow/repos",
75+
"events_url": "https://api.github.com/users/web-flow/events{/privacy}",
76+
"received_events_url": "https://api.github.com/users/web-flow/received_events",
77+
"type": "User",
78+
"site_admin": false
79+
},
80+
"parents": [
81+
{
82+
"sha": "244ac3fd88c730496b8e4c38ee7e6aa404538942",
83+
"url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/commits/244ac3fd88c730496b8e4c38ee7e6aa404538942",
84+
"html_url": "https://github.com/AlexMSmithCA/probot-app-label-dependency-pr/commit/244ac3fd88c730496b8e4c38ee7e6aa404538942"
85+
}
86+
]
87+
},
88+
"branches": [
89+
{
90+
"name": "AlexMSmithCA-patch-5",
91+
"commit": {
92+
"sha": "a754d7072c822c94da15ee7e4e1dfcac065b2774",
93+
"url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/commits/a754d7072c822c94da15ee7e4e1dfcac065b2774"
94+
},
95+
"protected": false
96+
}
97+
],
98+
"created_at": "2019-02-07T22:57:16+00:00",
99+
"updated_at": "2019-02-07T22:57:16+00:00",
100+
"repository": {
101+
"id": 146671503,
102+
"node_id": "MDEwOlJlcG9zaXRvcnkxNDY2NzE1MDM=",
103+
"name": "probot-app-label-dependency-pr",
104+
"full_name": "AlexMSmithCA/probot-app-label-dependency-pr",
105+
"private": false,
106+
"owner": {
107+
"login": "AlexMSmithCA",
108+
"id": 3497835,
109+
"node_id": "MDQ6VXNlcjM0OTc4MzU=",
110+
"avatar_url": "https://avatars3.githubusercontent.com/u/3497835?v=4",
111+
"gravatar_id": "",
112+
"url": "https://api.github.com/users/AlexMSmithCA",
113+
"html_url": "https://github.com/AlexMSmithCA",
114+
"followers_url": "https://api.github.com/users/AlexMSmithCA/followers",
115+
"following_url": "https://api.github.com/users/AlexMSmithCA/following{/other_user}",
116+
"gists_url": "https://api.github.com/users/AlexMSmithCA/gists{/gist_id}",
117+
"starred_url": "https://api.github.com/users/AlexMSmithCA/starred{/owner}{/repo}",
118+
"subscriptions_url": "https://api.github.com/users/AlexMSmithCA/subscriptions",
119+
"organizations_url": "https://api.github.com/users/AlexMSmithCA/orgs",
120+
"repos_url": "https://api.github.com/users/AlexMSmithCA/repos",
121+
"events_url": "https://api.github.com/users/AlexMSmithCA/events{/privacy}",
122+
"received_events_url": "https://api.github.com/users/AlexMSmithCA/received_events",
123+
"type": "User",
124+
"site_admin": false
125+
},
126+
"html_url": "https://github.com/AlexMSmithCA/probot-app-label-dependency-pr",
127+
"description": "Applies a 'dependencies' label to PRs that change package dependencies",
128+
"fork": true,
129+
"url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr",
130+
"forks_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/forks",
131+
"keys_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/keys{/key_id}",
132+
"collaborators_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/collaborators{/collaborator}",
133+
"teams_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/teams",
134+
"hooks_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/hooks",
135+
"issue_events_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/issues/events{/number}",
136+
"events_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/events",
137+
"assignees_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/assignees{/user}",
138+
"branches_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/branches{/branch}",
139+
"tags_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/tags",
140+
"blobs_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/git/blobs{/sha}",
141+
"git_tags_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/git/tags{/sha}",
142+
"git_refs_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/git/refs{/sha}",
143+
"trees_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/git/trees{/sha}",
144+
"statuses_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/statuses/{sha}",
145+
"languages_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/languages",
146+
"stargazers_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/stargazers",
147+
"contributors_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/contributors",
148+
"subscribers_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/subscribers",
149+
"subscription_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/subscription",
150+
"commits_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/commits{/sha}",
151+
"git_commits_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/git/commits{/sha}",
152+
"comments_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/comments{/number}",
153+
"issue_comment_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/issues/comments{/number}",
154+
"contents_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/contents/{+path}",
155+
"compare_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/compare/{base}...{head}",
156+
"merges_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/merges",
157+
"archive_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/{archive_format}{/ref}",
158+
"downloads_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/downloads",
159+
"issues_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/issues{/number}",
160+
"pulls_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/pulls{/number}",
161+
"milestones_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/milestones{/number}",
162+
"notifications_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/notifications{?since,all,participating}",
163+
"labels_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/labels{/name}",
164+
"releases_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/releases{/id}",
165+
"deployments_url": "https://api.github.com/repos/AlexMSmithCA/probot-app-label-dependency-pr/deployments",
166+
"created_at": "2018-08-29T23:51:16Z",
167+
"updated_at": "2019-02-07T05:02:18Z",
168+
"pushed_at": "2019-02-07T05:39:37Z",
169+
"git_url": "git://github.com/AlexMSmithCA/probot-app-label-dependency-pr.git",
170+
"ssh_url": "git@github.com:AlexMSmithCA/probot-app-label-dependency-pr.git",
171+
"clone_url": "https://github.com/AlexMSmithCA/probot-app-label-dependency-pr.git",
172+
"svn_url": "https://github.com/AlexMSmithCA/probot-app-label-dependency-pr",
173+
"homepage": null,
174+
"size": 64,
175+
"stargazers_count": 0,
176+
"watchers_count": 0,
177+
"language": "JavaScript",
178+
"has_issues": false,
179+
"has_projects": true,
180+
"has_downloads": true,
181+
"has_wiki": true,
182+
"has_pages": false,
183+
"forks_count": 0,
184+
"mirror_url": null,
185+
"archived": false,
186+
"open_issues_count": 1,
187+
"license": {
188+
"key": "mit",
189+
"name": "MIT License",
190+
"spdx_id": "MIT",
191+
"url": "https://api.github.com/licenses/mit",
192+
"node_id": "MDc6TGljZW5zZTEz"
193+
},
194+
"forks": 0,
195+
"open_issues": 1,
196+
"watchers": 0,
197+
"default_branch": "master"
198+
},
199+
"sender": {
200+
"login": "alexmsmithca-probot-dev[bot]",
201+
"id": 42192675,
202+
"node_id": "MDM6Qm90NDIxOTI2NzU=",
203+
"avatar_url": "https://avatars3.githubusercontent.com/u/3497835?v=4",
204+
"gravatar_id": "",
205+
"url": "https://api.github.com/users/alexmsmithca-probot-dev%5Bbot%5D",
206+
"html_url": "https://github.com/apps/alexmsmithca-probot-dev",
207+
"followers_url": "https://api.github.com/users/alexmsmithca-probot-dev%5Bbot%5D/followers",
208+
"following_url": "https://api.github.com/users/alexmsmithca-probot-dev%5Bbot%5D/following{/other_user}",
209+
"gists_url": "https://api.github.com/users/alexmsmithca-probot-dev%5Bbot%5D/gists{/gist_id}",
210+
"starred_url": "https://api.github.com/users/alexmsmithca-probot-dev%5Bbot%5D/starred{/owner}{/repo}",
211+
"subscriptions_url": "https://api.github.com/users/alexmsmithca-probot-dev%5Bbot%5D/subscriptions",
212+
"organizations_url": "https://api.github.com/users/alexmsmithca-probot-dev%5Bbot%5D/orgs",
213+
"repos_url": "https://api.github.com/users/alexmsmithca-probot-dev%5Bbot%5D/repos",
214+
"events_url": "https://api.github.com/users/alexmsmithca-probot-dev%5Bbot%5D/events{/privacy}",
215+
"received_events_url": "https://api.github.com/users/alexmsmithca-probot-dev%5Bbot%5D/received_events",
216+
"type": "Bot",
217+
"site_admin": false
218+
},
219+
"installation": {
220+
"id": 278691,
221+
"node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uMjc4Njkx"
222+
}
223+
}

0 commit comments

Comments
 (0)