Skip to content

Commit 0ea5b5e

Browse files
squalrusgithub-actions[bot]
authored andcommitted
Validate checks before merging PRs (#20)
Fix #15
1 parent 6d65b54 commit 0ea5b5e

24 files changed

+469
-17
lines changed

.github/workflows/merge-bot.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@ name: Merge Bot
22

33
on:
44
pull_request:
5-
types: [labeled, unlabeled, review_request_removed]
5+
types:
6+
- labeled
7+
- review_request_removed
8+
- review_requested
9+
- unlabeled
610
pull_request_review:
11+
types:
12+
- dismissed
13+
- submitted
14+
status:
715

816
jobs:
917
merge:
1018
runs-on: ubuntu-latest
1119
name: Merge
1220
steps:
1321
- name: Integration check
14-
uses: squalrus/merge-bot@v0.3.1
22+
uses: squalrus/merge-bot@master
1523
with:
1624
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1725
test: false

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This action manages pull request integrations by allowing a structured workflow to be defined.
44

5-
The workflow can use required labels, blocking labels, and require that reviewers sign-off.
5+
The workflow can use required labels, blocking labels, and require that reviewers sign-off for determining if a pull request should be integrated. By default the pull request will be blocked by incomplete/failing checks.
66

77
Once conditions are met the pull request will be integrated and branch deleted.
88

@@ -34,6 +34,10 @@ One or more labels that block the integration. Default is `"do not merge"`.
3434

3535
![do not merge GitHub label](./assets/blocking-label.png)
3636

37+
### `checks_enabled`
38+
39+
All checks must be completed to be eligible to integrate. Default is `true`.
40+
3741
### `method`
3842

3943
Merge method to use. Possible values are `merge`, `squash` or `rebase`. Default is `merge`.
@@ -47,8 +51,16 @@ name: Merge Bot
4751

4852
on:
4953
pull_request:
50-
types: [labeled, unlabeled, review_request_removed]
54+
types:
55+
- labeled
56+
- review_request_removed
57+
- review_requested
58+
- unlabeled
5159
pull_request_review:
60+
types:
61+
- dismissed
62+
- submitted
63+
status:
5264

5365
jobs:
5466
merge:
@@ -63,5 +75,6 @@ jobs:
6375
reviewers: true
6476
labels: ready, merge
6577
blocking-labels: do not merge
78+
checks: true
6679
method: squash
6780
```

__mocks__/checks/check-0.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
"data": {
3+
"total_count": 0,
4+
"check_runs": [
5+
]
6+
}
7+
};

__mocks__/checks/check-1a.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
"data": {
3+
"total_count": 3,
4+
"check_runs": [
5+
{
6+
"id": 12345678,
7+
"status": "queued",
8+
"conclusion": null,
9+
"started_at": null,
10+
"completed_at": null
11+
},
12+
{
13+
"id": 23456789,
14+
"status": "in_progress",
15+
"conclusion": null,
16+
"started_at": "2020-01-26T00:26:45Z",
17+
"completed_at": null
18+
},
19+
{
20+
"id": 34567890,
21+
"status": "completed",
22+
"conclusion": "success",
23+
"started_at": "2020-01-26T00:26:03Z",
24+
"completed_at": "2020-01-26T00:26:39Z"
25+
}
26+
]
27+
}
28+
};

__mocks__/checks/check-1b.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
"data": {
3+
"total_count": 3,
4+
"check_runs": [
5+
{
6+
"id": 12345678,
7+
"status": "queued",
8+
"conclusion": null,
9+
"started_at": null,
10+
"completed_at": null
11+
},
12+
{
13+
"id": 23456789,
14+
"status": "in_progress",
15+
"conclusion": null,
16+
"started_at": "2020-01-26T00:26:45Z",
17+
"completed_at": null
18+
},
19+
{
20+
"id": 34567890,
21+
"status": "completed",
22+
"conclusion": "failure",
23+
"started_at": "2020-01-26T00:26:03Z",
24+
"completed_at": "2020-01-26T00:26:39Z"
25+
}
26+
]
27+
}
28+
};

__mocks__/checks/check-2a.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
"data": {
3+
"total_count": 3,
4+
"check_runs": [
5+
{
6+
"id": 12345678,
7+
"status": "in_progress",
8+
"conclusion": null,
9+
"started_at": "2020-01-26T00:26:45Z",
10+
"completed_at": null
11+
},
12+
{
13+
"id": 23456789,
14+
"status": "completed",
15+
"conclusion": "success",
16+
"started_at": "2020-01-26T00:26:03Z",
17+
"completed_at": "2020-01-26T00:26:39Z"
18+
},
19+
{
20+
"id": 34567890,
21+
"status": "completed",
22+
"conclusion": "success",
23+
"started_at": "2020-01-26T00:26:03Z",
24+
"completed_at": "2020-01-26T00:26:39Z"
25+
}
26+
]
27+
}
28+
};

__mocks__/checks/check-2b.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
"data": {
3+
"total_count": 3,
4+
"check_runs": [
5+
{
6+
"id": 12345678,
7+
"status": "in_progress",
8+
"conclusion": null,
9+
"started_at": "2020-01-26T00:26:45Z",
10+
"completed_at": null
11+
},
12+
{
13+
"id": 23456789,
14+
"status": "completed",
15+
"conclusion": "success",
16+
"started_at": "2020-01-26T00:26:03Z",
17+
"completed_at": "2020-01-26T00:26:39Z"
18+
},
19+
{
20+
"id": 34567890,
21+
"status": "completed",
22+
"conclusion": "failure",
23+
"started_at": "2020-01-26T00:26:03Z",
24+
"completed_at": "2020-01-26T00:26:39Z"
25+
}
26+
]
27+
}
28+
};

__mocks__/checks/check-2c.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
"data": {
3+
"total_count": 3,
4+
"check_runs": [
5+
{
6+
"id": 12345678,
7+
"status": "in_progress",
8+
"conclusion": null,
9+
"started_at": "2020-01-26T00:26:45Z",
10+
"completed_at": null
11+
},
12+
{
13+
"id": 23456789,
14+
"status": "completed",
15+
"conclusion": "failure",
16+
"started_at": "2020-01-26T00:26:03Z",
17+
"completed_at": "2020-01-26T00:26:39Z"
18+
},
19+
{
20+
"id": 34567890,
21+
"status": "completed",
22+
"conclusion": "failure",
23+
"started_at": "2020-01-26T00:26:03Z",
24+
"completed_at": "2020-01-26T00:26:39Z"
25+
}
26+
]
27+
}
28+
};

__mocks__/checks/check-3a.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
"data": {
3+
"total_count": 3,
4+
"check_runs": [
5+
{
6+
"id": 12345678,
7+
"status": "completed",
8+
"conclusion": "success",
9+
"started_at": "2020-01-26T00:26:03Z",
10+
"completed_at": "2020-01-26T00:26:39Z"
11+
},
12+
{
13+
"id": 23456789,
14+
"status": "completed",
15+
"conclusion": "success",
16+
"started_at": "2020-01-26T00:26:03Z",
17+
"completed_at": "2020-01-26T00:26:39Z"
18+
},
19+
{
20+
"id": 34567890,
21+
"status": "completed",
22+
"conclusion": "success",
23+
"started_at": "2020-01-26T00:26:03Z",
24+
"completed_at": "2020-01-26T00:26:39Z"
25+
}
26+
]
27+
}
28+
};

__mocks__/checks/check-3b.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
"data": {
3+
"total_count": 3,
4+
"check_runs": [
5+
{
6+
"id": 12345678,
7+
"status": "completed",
8+
"conclusion": "failure",
9+
"started_at": "2020-01-26T00:26:03Z",
10+
"completed_at": "2020-01-26T00:26:39Z"
11+
},
12+
{
13+
"id": 23456789,
14+
"status": "completed",
15+
"conclusion": "failure",
16+
"started_at": "2020-01-26T00:26:03Z",
17+
"completed_at": "2020-01-26T00:26:39Z"
18+
},
19+
{
20+
"id": 34567890,
21+
"status": "completed",
22+
"conclusion": "failure",
23+
"started_at": "2020-01-26T00:26:03Z",
24+
"completed_at": "2020-01-26T00:26:39Z"
25+
}
26+
]
27+
}
28+
};

0 commit comments

Comments
 (0)