Skip to content

Commit d983684

Browse files
committed
tests: add cases that check repo-specific config loading behavior
`push.multi_repo_custom_repo_secrets` The correct repo-specific secrets configuration should be loaded for the given payload repo. `status.multi_repo_disallowed_repo` If `allowed_repositories` excludes the payload repo, it should be ignored. `status.multi_repo_independent_status_state` The status rules should be evaluated for the correct repo. In this test case, it should correctly detect that `master`'s last build status was a failure for the given payload repo, and issue a success notification.
1 parent 6adbf96 commit d983684

11 files changed

+415
-9
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"main_branch_name": "develop",
3+
"status_rules": {
4+
"rules": []
5+
},
6+
"prefix_rules": {
7+
"default_channel": "default",
8+
"rules": [{ "channel": "all-push-events" }]
9+
},
10+
"label_rules": {
11+
"default_channel": "default",
12+
"rules": []
13+
}
14+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"ref": "refs/heads/master",
3+
"before": "fb245e2a6d52d10025c8bd4f36f6e3134d85ae18",
4+
"after": "e2173f38ae43865433a182c1fc1b5442d9763b54",
5+
"created": false,
6+
"deleted": false,
7+
"forced": false,
8+
"base_ref": null,
9+
"compare": "https://github.com/acme/runner/compare/fb245e2a6d52...e2173f38ae43",
10+
"commits": [
11+
{
12+
"id": "80452f696a8988e7234063d47720a62e902f2afc",
13+
"tree_id": "bf7530bb0b13d0b9f471ff5d1951c59488b5704c",
14+
"distinct": true,
15+
"message": "Update readme",
16+
"timestamp": "2019-07-06T11:47:56+01:00",
17+
"url": "https://github.com/acme/runner/commit/80452f696a8988e7234063d47720a62e902f2afc",
18+
"author": {
19+
"name": "wile e coyote",
20+
"email": "[email protected]",
21+
"username": "wileecoyote"
22+
},
23+
"committer": {
24+
"name": "wile e coyote",
25+
"email": "[email protected]",
26+
"username": "wileecoyote"
27+
},
28+
"added": [],
29+
"removed": [],
30+
"modified": [
31+
"README.md"
32+
]
33+
},
34+
{
35+
"id": "e2173f38ae43865433a182c1fc1b5442d9763b54",
36+
"tree_id": "6dc065fdfacfc72cd7b1f5e7a9391c238e4fb74e",
37+
"distinct": true,
38+
"message": "Add TESTING.md",
39+
"timestamp": "2019-07-06T11:48:38+01:00",
40+
"url": "https://github.com/acme/runner/commit/e2173f38ae43865433a182c1fc1b5442d9763b54",
41+
"author": {
42+
"name": "wile e coyote",
43+
"email": "[email protected]",
44+
"username": "wileecoyote"
45+
},
46+
"committer": {
47+
"name": "wile e coyote",
48+
"email": "[email protected]",
49+
"username": "wileecoyote"
50+
},
51+
"added": [
52+
"TESTING.md",
53+
"backend/api/longest/test.ml"
54+
],
55+
"removed": [],
56+
"modified": []
57+
}
58+
],
59+
"head_commit": {
60+
"id": "e2173f38ae43865433a182c1fc1b5442d9763b54",
61+
"tree_id": "6dc065fdfacfc72cd7b1f5e7a9391c238e4fb74e",
62+
"distinct": true,
63+
"message": "Add TESTING.md",
64+
"timestamp": "2019-07-06T11:48:38+01:00",
65+
"url": "https://github.com/acme/runner/commit/e2173f38ae43865433a182c1fc1b5442d9763b54",
66+
"author": {
67+
"name": "wile e coyote",
68+
"email": "[email protected]",
69+
"username": "wileecoyote"
70+
},
71+
"committer": {
72+
"name": "wile e coyote",
73+
"email": "[email protected]",
74+
"username": "wileecoyote"
75+
},
76+
"added": [
77+
"TESTING.md"
78+
],
79+
"removed": [],
80+
"modified": []
81+
},
82+
"pusher": {
83+
"name": "wileecoyote",
84+
"email": "[email protected]"
85+
},
86+
"sender": {
87+
"login": "wileecoyote",
88+
"id": 8755205,
89+
"node_id": "MDQ6VXNlcjg3NTUyMDU=",
90+
"avatar_url": "https://avatars1.githubusercontent.com/u/8755205?v=4",
91+
"gravatar_id": "",
92+
"url": "https://api.github.com/users/wileecoyote",
93+
"html_url": "https://github.com/wileecoyote",
94+
"followers_url": "https://api.github.com/users/wileecoyote/followers",
95+
"following_url": "https://api.github.com/users/wileecoyote/following{/other_user}",
96+
"gists_url": "https://api.github.com/users/wileecoyote/gists{/gist_id}",
97+
"starred_url": "https://api.github.com/users/wileecoyote/starred{/owner}{/repo}",
98+
"subscriptions_url": "https://api.github.com/users/wileecoyote/subscriptions",
99+
"organizations_url": "https://api.github.com/users/wileecoyote/orgs",
100+
"repos_url": "https://api.github.com/users/wileecoyote/repos",
101+
"events_url": "https://api.github.com/users/wileecoyote/events{/privacy}",
102+
"received_events_url": "https://api.github.com/users/wileecoyote/received_events",
103+
"type": "User",
104+
"site_admin": false
105+
},
106+
"repository": {
107+
"name": "runner",
108+
"full_name": "acme/runner",
109+
"html_url": "https://github.com/acme/runner",
110+
"contents_url": "https://api.github.com/repos/acme/runner/contents/{+path}",
111+
"commits_url": "https://api.github.com/repos/acme/runner/commits{/sha}"
112+
}
113+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"sha": "0d95302addd66c1816bce1b1d495ed1c93ccd478",
3+
"context": "buildkite/notabot-test/build",
4+
"state": "pending",
5+
"commit": {
6+
"sha": "0d95302addd66c1816bce1b1d495ed1c93ccd478",
7+
"node_id": "MDY6Q29tbWl0MTgyOjBkOTUzMDJhZGRkNjZjMTgxNmJjZTFiMWQ0OTVlZDFjOTNjY2Q0Nzg=",
8+
"commit": {
9+
"author": {
10+
"name": "Louis Roché",
11+
"email": "[email protected]",
12+
"date": "2020-06-02T03:14:51Z"
13+
},
14+
"committer": {
15+
"name": "GitHub Enterprise",
16+
"email": "[email protected]",
17+
"date": "2020-06-02T03:14:51Z"
18+
},
19+
"message": "Update README.md",
20+
"tree": {
21+
"sha": "ee5c539cad37c77348ce7a55756acc542b41cfc7",
22+
"url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/trees/ee5c539cad37c77348ce7a55756acc542b41cfc7"
23+
},
24+
"url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478",
25+
"comment_count": 0,
26+
"verification": {
27+
"verified": false,
28+
"reason": "unsigned",
29+
"signature": null,
30+
"payload": null
31+
}
32+
},
33+
"url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478",
34+
"html_url": "https://git.ahrefs.com/ahrefs/notabot_test/commit/0d95302addd66c1816bce1b1d495ed1c93ccd478",
35+
"comments_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478/comments",
36+
"author": {
37+
"login": "louis",
38+
"id": 34,
39+
"node_id": "MDQ6VXNlcjM0",
40+
"avatar_url": "https://git.ahrefs.com/avatars/u/34?",
41+
"gravatar_id": "",
42+
"url": "https://git.ahrefs.com/api/v3/users/louis",
43+
"html_url": "https://git.ahrefs.com/louis",
44+
"followers_url": "https://git.ahrefs.com/api/v3/users/louis/followers",
45+
"following_url": "https://git.ahrefs.com/api/v3/users/louis/following{/other_user}",
46+
"gists_url": "https://git.ahrefs.com/api/v3/users/louis/gists{/gist_id}",
47+
"starred_url": "https://git.ahrefs.com/api/v3/users/louis/starred{/owner}{/repo}",
48+
"subscriptions_url": "https://git.ahrefs.com/api/v3/users/louis/subscriptions",
49+
"organizations_url": "https://git.ahrefs.com/api/v3/users/louis/orgs",
50+
"repos_url": "https://git.ahrefs.com/api/v3/users/louis/repos",
51+
"events_url": "https://git.ahrefs.com/api/v3/users/louis/events{/privacy}",
52+
"received_events_url": "https://git.ahrefs.com/api/v3/users/louis/received_events",
53+
"type": "User",
54+
"site_admin": false
55+
},
56+
"committer": null,
57+
"parents": [
58+
{
59+
"sha": "04cb72d6dc8d92131282a7eff57f6caf632f0a39",
60+
"url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/04cb72d6dc8d92131282a7eff57f6caf632f0a39",
61+
"html_url": "https://git.ahrefs.com/ahrefs/notabot_test/commit/04cb72d6dc8d92131282a7eff57f6caf632f0a39"
62+
}
63+
]
64+
},
65+
"branches": [
66+
{
67+
"name": "master",
68+
"commit": {
69+
"sha": "0d95302addd66c1816bce1b1d495ed1c93ccd478",
70+
"url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478"
71+
},
72+
"protected": false
73+
}
74+
],
75+
"created_at": "2020-06-02T03:20:35+00:00",
76+
"updated_at": "2020-06-02T03:20:35+00:00",
77+
"repository": {
78+
"name": "runner",
79+
"full_name": "acme/runner",
80+
"html_url": "https://github.com/acme/runner",
81+
"contents_url": "https://api.github.com/repos/acme/runner/contents/{+path}",
82+
"commits_url": "https://api.github.com/repos/acme/runner/commits{/sha}"
83+
}
84+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"id": 1437427,
3+
"sha": "0d95302addd66c1816bce1b1d495ed1c93ccd478",
4+
"name": "ahrefs/notabot_test",
5+
"target_url": "https://buildkite.com/ahrefs/notabot-test/builds/2",
6+
"avatar_url": "https://git.ahrefs.com/avatars/oa/6?",
7+
"context": "buildkite/notabot-test",
8+
"description": "Build #2 passed (5 minutes, 19 seconds)",
9+
"state": "success",
10+
"commit": {
11+
"sha": "0d95302addd66c1816bce1b1d495ed1c93ccd478",
12+
"node_id": "MDY6Q29tbWl0MTgyOjBkOTUzMDJhZGRkNjZjMTgxNmJjZTFiMWQ0OTVlZDFjOTNjY2Q0Nzg=",
13+
"commit": {
14+
"author": {
15+
"name": "Louis Roché",
16+
"email": "[email protected]",
17+
"date": "2020-06-02T03:14:51Z"
18+
},
19+
"committer": {
20+
"name": "GitHub Enterprise",
21+
"email": "[email protected]",
22+
"date": "2020-06-02T03:14:51Z"
23+
},
24+
"message": "Update README.md",
25+
"tree": {
26+
"sha": "ee5c539cad37c77348ce7a55756acc542b41cfc7",
27+
"url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/trees/ee5c539cad37c77348ce7a55756acc542b41cfc7"
28+
},
29+
"url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478",
30+
"comment_count": 0,
31+
"verification": {
32+
"verified": false,
33+
"reason": "unsigned",
34+
"signature": null,
35+
"payload": null
36+
}
37+
},
38+
"url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478",
39+
"html_url": "https://git.ahrefs.com/ahrefs/notabot_test/commit/0d95302addd66c1816bce1b1d495ed1c93ccd478",
40+
"comments_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478/comments",
41+
"author": {
42+
"login": "louis",
43+
"id": 34,
44+
"node_id": "MDQ6VXNlcjM0",
45+
"avatar_url": "https://git.ahrefs.com/avatars/u/34?",
46+
"gravatar_id": "",
47+
"url": "https://git.ahrefs.com/api/v3/users/louis",
48+
"html_url": "https://git.ahrefs.com/louis",
49+
"followers_url": "https://git.ahrefs.com/api/v3/users/louis/followers",
50+
"following_url": "https://git.ahrefs.com/api/v3/users/louis/following{/other_user}",
51+
"gists_url": "https://git.ahrefs.com/api/v3/users/louis/gists{/gist_id}",
52+
"starred_url": "https://git.ahrefs.com/api/v3/users/louis/starred{/owner}{/repo}",
53+
"subscriptions_url": "https://git.ahrefs.com/api/v3/users/louis/subscriptions",
54+
"organizations_url": "https://git.ahrefs.com/api/v3/users/louis/orgs",
55+
"repos_url": "https://git.ahrefs.com/api/v3/users/louis/repos",
56+
"events_url": "https://git.ahrefs.com/api/v3/users/louis/events{/privacy}",
57+
"received_events_url": "https://git.ahrefs.com/api/v3/users/louis/received_events",
58+
"type": "User",
59+
"site_admin": false
60+
},
61+
"committer": null,
62+
"parents": [
63+
{
64+
"sha": "04cb72d6dc8d92131282a7eff57f6caf632f0a39",
65+
"url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/04cb72d6dc8d92131282a7eff57f6caf632f0a39",
66+
"html_url": "https://git.ahrefs.com/ahrefs/notabot_test/commit/04cb72d6dc8d92131282a7eff57f6caf632f0a39"
67+
}
68+
]
69+
},
70+
"branches": [
71+
{
72+
"name": "master",
73+
"commit": {
74+
"sha": "0d95302addd66c1816bce1b1d495ed1c93ccd478",
75+
"url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478"
76+
},
77+
"protected": false
78+
}
79+
],
80+
"created_at": "2020-06-02T03:21:39+00:00",
81+
"updated_at": "2020-06-02T03:21:39+00:00",
82+
"repository": {
83+
"id": 182,
84+
"node_id": "MDEwOlJlcG9zaXRvcnkxODI=",
85+
"name": "notabot_test",
86+
"full_name": "ahrefs/notabot_test",
87+
"private": true,
88+
"html_url": "https://git.ahrefs.com/ahrefs/notabot_test",
89+
"description": null,
90+
"fork": false,
91+
"commits_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits{/sha}",
92+
"contents_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/contents/{+path}",
93+
"created_at": "2020-06-01T18:44:17Z",
94+
"updated_at": "2020-06-02T03:14:53Z",
95+
"pushed_at": "2020-06-02T03:14:51Z"
96+
}
97+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"repositories": {
3+
"https://github.com/acme/runner": {
4+
"gh_token": "XXX"
5+
},
6+
"https://git.ahrefs.com/ahrefs/notabot_test": {
7+
"gh_token": "XXX",
8+
"gh_hook_token": "XXX"
9+
}
10+
},
11+
"slack_hooks": [
12+
{
13+
"url": "https://slack_webhook_url",
14+
"channel": "all-push-events"
15+
}
16+
]
17+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"allowed_repositories": ["https://git.ahrefs.com/ahrefs/notabot_test"],
3+
"slack_hooks": []
4+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"https://github.com/acme/runner": {
3+
"pipeline_statuses": {
4+
"buildkite/notabot-test": {
5+
"master": "success"
6+
}
7+
}
8+
},
9+
"https://git.ahrefs.com/ahrefs/notabot_test": {
10+
"pipeline_statuses": {
11+
"buildkite/notabot-test": {
12+
"master": "failure"
13+
}
14+
}
15+
}
16+
}

mock_states/status.state_hide_success_test.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
{
32
"https://git.ahrefs.com/ahrefs/notabot_test": {
43
"pipeline_statuses": {
@@ -10,4 +9,4 @@
109
}
1110
}
1211
}
13-
}
12+
}

mock_states/status.state_hide_success_test_disallowed_pipeline.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
}
77
}
88
}
9-
}
9+
}

0 commit comments

Comments
 (0)