Skip to content

Commit 1ac7676

Browse files
authored
Update mergify config generator and config (#4654)
1 parent 48f676b commit 1ac7676

File tree

3 files changed

+97
-92
lines changed

3 files changed

+97
-92
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ Please be sure to elaborate on any API changes or deprecations and any impact on
4545
- [ ] Did you review?
4646
- [ ] Did you check whether all relevant Contributor checkboxes have been checked?
4747
- [ ] Did you do one of the following when ready to merge:
48-
- [ ] Squash: You/ the contributor `Enable auto-merge (squash)`, clean up the commit message, and label with `Please Merge`.
48+
- [ ] Squash: You/ the contributor `Enable auto-merge (squash)` and clean up the commit message.
4949
- [ ] Merge: Ensure that contributor has cleaned up their commit history, then merge with `Create a merge commit`.

.github/mergify/gen-config.sc

Lines changed: 46 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,56 @@
11
#!/usr/bin/env -S scala-cli shebang
22
// SPDX-License-Identifier: Apache-2.0
33
//> using scala "2.13"
4-
//> using dep "io.circe::circe-yaml:0.15.1"
5-
//> using dep "com.lihaoyi::os-lib:0.9.1"
4+
//> using dep "io.circe::circe-yaml:0.16.0"
5+
//> using dep "com.lihaoyi::os-lib:0.11.3"
66

77
/* Generates a Mergify config YAML (to STDOUT) based on input config
88
*
99
* There are built-in conditions, but different CI requires different conditions
1010
* Listed branches should be stable branches that we want to backport to, in ascending order
11-
* {{{
11+
*
1212
* conditions:
13-
- status-success=Travis CI - Pull Request
13+
- status-success=all tests passed
1414
branches:
15-
- 1.2.x
16-
- 1.3.x
17-
- 1.4.x
18-
* }}}
15+
- 3.6.x
16+
- 5.x
17+
- 6.x
18+
*
1919
*/
2020

2121
import io.circe._
2222
import io.circe.syntax._ // for .asJson
2323
import io.circe.yaml.parser
2424
import io.circe.yaml.syntax._ // for .asYaml
2525

26-
def mergeQueue(conditions: List[String]) = Json.obj(
27-
"name" -> "default".asJson,
28-
"conditions" -> conditions.asJson,
29-
"draft_bot_account" -> "chiselbot".asJson,
30-
"update_bot_account" -> "chiselbot".asJson,
31-
"merge_bot_account" -> "chiselbot".asJson
32-
)
33-
34-
val queueAction = Json.obj(
35-
"queue" -> Json.obj(
36-
"name" -> "default".asJson,
37-
"method" -> "squash".asJson,
38-
"update_method" -> "merge".asJson,
39-
"update_bot_account" -> "chiselbot".asJson,
40-
"merge_bot_account" -> "chiselbot".asJson
41-
)
42-
)
43-
44-
def mergeToMain(conditions: List[String]) = Json.obj(
45-
"name" -> "automatic squash-and-merge on CI success and review".asJson,
46-
"conditions" -> (conditions ++ List(
47-
"#approved-reviews-by>=1",
26+
def mergeQueue(branch: String, conditions: List[String]) = Json.obj(
27+
"name" -> s"$branch merge queue".asJson,
28+
"queue_conditions" -> (conditions ++ List(
29+
s"base=$branch",
4830
"#changes-requested-reviews-by=0",
49-
"base=main",
50-
"label=\"Please Merge\"",
31+
"label=\"Backport\"",
5132
"label!=\"DO NOT MERGE\"",
5233
"label!=\"bp-conflict\""
5334
)).asJson,
54-
"actions" -> queueAction
35+
"merge_conditions" -> conditions.asJson,
36+
"draft_bot_account" -> "chiselbot".asJson,
37+
"update_bot_account" -> "chiselbot".asJson,
38+
"merge_bot_account" -> "chiselbot".asJson
5539
)
5640

5741
def makeBackportRule(branches: List[String]): Json = {
5842
Json.obj(
5943
"name" -> s"""backport to ${branches.mkString(", ")}""".asJson,
60-
"conditions" -> List("merged", "base=main", s"milestone=${branches.head}").asJson,
44+
"conditions" -> List("merged", s"milestone=${branches.head}").asJson,
6145
"actions" -> Json.obj(
6246
"backport" -> Json.obj(
6347
"branches" -> branches.asJson,
6448
"labels" -> List("Backport").asJson,
6549
"ignore_conflicts" -> true.asJson,
66-
"label_conflicts" -> "bp-conflict".asJson
50+
"merge_conflict_style" -> "diff3".asJson,
51+
"label_conflicts" -> "bp-conflict".asJson,
52+
"bot_account" -> "chiselbot".asJson,
53+
"report_mode" -> List("comment").asJson
6754
),
6855
"label" -> Json.obj(
6956
"add" -> List("Backported").asJson
@@ -73,34 +60,40 @@ def makeBackportRule(branches: List[String]): Json = {
7360
}
7461

7562
def backportMergeRule(conditions: List[String])(branch: String): Json = Json.obj(
76-
"name" -> s"automatic squash-and-mege of $branch backport PRs".asJson,
63+
"name" -> s"queue $branch backport PRs".asJson,
7764
"conditions" -> (conditions ++ List(
7865
"#changes-requested-reviews-by=0",
7966
s"base=$branch",
8067
"label=\"Backport\"",
8168
"label!=\"DO NOT MERGE\"",
8269
"label!=\"bp-conflict\""
8370
)).asJson,
84-
"actions" -> queueAction
71+
"actions" -> Json.obj(
72+
"queue" -> Json.obj(
73+
"name" -> s"$branch merge queue".asJson
74+
)
75+
)
8576
)
8677

87-
8878
def error(msg: String) = throw new Exception(msg) with scala.util.control.NoStackTrace
8979

9080
def processTemplate(path: os.Path): (List[String], List[String]) = {
9181
val contents = os.read(path)
92-
val parsed = parser.parse(contents)
93-
.getOrElse(error(s"Invalid YAML $path"))
82+
val parsed = parser
83+
.parse(contents)
84+
.getOrElse(error(s"Invalid YAML $path"))
9485

9586
val cursor: HCursor = parsed.hcursor
9687

97-
val conditions = cursor.downField("conditions")
98-
.as[List[String]]
99-
.getOrElse(error(s"Invalid template, expected field 'conditions': List[String]"))
88+
val conditions = cursor
89+
.downField("conditions")
90+
.as[List[String]]
91+
.getOrElse(error(s"Invalid template, expected field 'conditions': List[String]"))
10092

101-
val branches = cursor.downField("branches")
102-
.as[List[String]]
103-
.getOrElse(error(s"Invalid template, expected field 'branches': List[String]"))
93+
val branches = cursor
94+
.downField("branches")
95+
.as[List[String]]
96+
.getOrElse(error(s"Invalid template, expected field 'branches': List[String]"))
10497
(conditions, branches)
10598
}
10699

@@ -112,15 +105,13 @@ val (conditions, branches) = processTemplate(template)
112105
val branchSets = branches.scanRight(List.empty[String])(_ :: _).init.reverse
113106

114107
val config = Json.obj(
115-
"queue_rules" -> Json.fromValues(
116-
mergeQueue(conditions) ::
117-
Nil
118-
),
119-
"pull_request_rules" -> Json.fromValues(
120-
mergeToMain(conditions) ::
121-
branchSets.map(makeBackportRule) :::
122-
branches.map(backportMergeRule(conditions))
123-
)
108+
"queue_rules" -> Json.fromValues(
109+
branches.map(mergeQueue(_, conditions))
110+
),
111+
"pull_request_rules" -> Json.fromValues(
112+
branchSets.map(makeBackportRule) :::
113+
branches.map(backportMergeRule(conditions))
114+
)
124115
)
125116

126117
println(s"# Generated by $scriptPath")

.mergify.yml

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,48 @@
11
# Generated by .github/mergify/gen-config.sc
22
queue_rules:
3-
- name: default
4-
conditions:
3+
- name: 3.6.x merge queue
4+
queue_conditions:
5+
- status-success=all tests passed
6+
- base=3.6.x
7+
- '#changes-requested-reviews-by=0'
8+
- label="Backport"
9+
- label!="DO NOT MERGE"
10+
- label!="bp-conflict"
11+
merge_conditions:
512
- status-success=all tests passed
613
draft_bot_account: chiselbot
714
update_bot_account: chiselbot
815
merge_bot_account: chiselbot
9-
pull_request_rules:
10-
- name: automatic squash-and-merge on CI success and review
11-
conditions:
16+
- name: 5.x merge queue
17+
queue_conditions:
1218
- status-success=all tests passed
13-
- '#approved-reviews-by>=1'
19+
- base=5.x
1420
- '#changes-requested-reviews-by=0'
15-
- base=main
16-
- label="Please Merge"
21+
- label="Backport"
1722
- label!="DO NOT MERGE"
1823
- label!="bp-conflict"
19-
actions:
20-
queue:
21-
name: default
22-
method: squash
23-
update_method: merge
24-
update_bot_account: chiselbot
25-
merge_bot_account: chiselbot
24+
merge_conditions:
25+
- status-success=all tests passed
26+
draft_bot_account: chiselbot
27+
update_bot_account: chiselbot
28+
merge_bot_account: chiselbot
29+
- name: 6.x merge queue
30+
queue_conditions:
31+
- status-success=all tests passed
32+
- base=6.x
33+
- '#changes-requested-reviews-by=0'
34+
- label="Backport"
35+
- label!="DO NOT MERGE"
36+
- label!="bp-conflict"
37+
merge_conditions:
38+
- status-success=all tests passed
39+
draft_bot_account: chiselbot
40+
update_bot_account: chiselbot
41+
merge_bot_account: chiselbot
42+
pull_request_rules:
2643
- name: backport to 6.x
2744
conditions:
2845
- merged
29-
- base=main
3046
- milestone=6.x
3147
actions:
3248
backport:
@@ -35,14 +51,17 @@ pull_request_rules:
3551
labels:
3652
- Backport
3753
ignore_conflicts: true
54+
merge_conflict_style: diff3
3855
label_conflicts: bp-conflict
56+
bot_account: chiselbot
57+
report_mode:
58+
- comment
3959
label:
4060
add:
4161
- Backported
4262
- name: backport to 5.x, 6.x
4363
conditions:
4464
- merged
45-
- base=main
4665
- milestone=5.x
4766
actions:
4867
backport:
@@ -52,14 +71,17 @@ pull_request_rules:
5271
labels:
5372
- Backport
5473
ignore_conflicts: true
74+
merge_conflict_style: diff3
5575
label_conflicts: bp-conflict
76+
bot_account: chiselbot
77+
report_mode:
78+
- comment
5679
label:
5780
add:
5881
- Backported
5982
- name: backport to 3.6.x, 5.x, 6.x
6083
conditions:
6184
- merged
62-
- base=main
6385
- milestone=3.6.x
6486
actions:
6587
backport:
@@ -70,11 +92,15 @@ pull_request_rules:
7092
labels:
7193
- Backport
7294
ignore_conflicts: true
95+
merge_conflict_style: diff3
7396
label_conflicts: bp-conflict
97+
bot_account: chiselbot
98+
report_mode:
99+
- comment
74100
label:
75101
add:
76102
- Backported
77-
- name: automatic squash-and-mege of 3.6.x backport PRs
103+
- name: queue 3.6.x backport PRs
78104
conditions:
79105
- status-success=all tests passed
80106
- '#changes-requested-reviews-by=0'
@@ -84,12 +110,8 @@ pull_request_rules:
84110
- label!="bp-conflict"
85111
actions:
86112
queue:
87-
name: default
88-
method: squash
89-
update_method: merge
90-
update_bot_account: chiselbot
91-
merge_bot_account: chiselbot
92-
- name: automatic squash-and-mege of 5.x backport PRs
113+
name: 3.6.x merge queue
114+
- name: queue 5.x backport PRs
93115
conditions:
94116
- status-success=all tests passed
95117
- '#changes-requested-reviews-by=0'
@@ -99,12 +121,8 @@ pull_request_rules:
99121
- label!="bp-conflict"
100122
actions:
101123
queue:
102-
name: default
103-
method: squash
104-
update_method: merge
105-
update_bot_account: chiselbot
106-
merge_bot_account: chiselbot
107-
- name: automatic squash-and-mege of 6.x backport PRs
124+
name: 5.x merge queue
125+
- name: queue 6.x backport PRs
108126
conditions:
109127
- status-success=all tests passed
110128
- '#changes-requested-reviews-by=0'
@@ -114,9 +132,5 @@ pull_request_rules:
114132
- label!="bp-conflict"
115133
actions:
116134
queue:
117-
name: default
118-
method: squash
119-
update_method: merge
120-
update_bot_account: chiselbot
121-
merge_bot_account: chiselbot
135+
name: 6.x merge queue
122136

0 commit comments

Comments
 (0)