Skip to content

Commit ec0c69c

Browse files
committed
PR workflow: add mergify
This config should always follow our worklof and other way around. They should both be in sync. What can mergify do? Check PR status (labels, reviewers) and act on it. First step would be to not merge anything, just use labels and help us to keep PRs up to date. Less manual work. If this works, we can get CI to check specific labels to trigger CI (or use commands) and other things, this needs more work.
1 parent dc63202 commit ec0c69c

File tree

1 file changed

+170
-0
lines changed

1 file changed

+170
-0
lines changed

.mergify.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
#
2+
# Copyright (c) 2020, Arm Limited and affiliates.
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Mergify follow our workflow: https://os.mbed.com/docs/mbed-os/latest/contributing/workflow.html
18+
# Inital state (needs: review) is done by internal reviewer bot
19+
20+
# Notes: conditions do not check if label is already there if we add or remove later, this is to limit Github API access to
21+
# minimum. If a label is already there and we add it again, nothing should happen (we do 1 less access to Github).
22+
# For instance for needs: work if CI failed, we just add a label as action, don't check if needs: works is already there
23+
24+
pull_request_rules:
25+
# From needs: review to needs: work - reviewers request
26+
- name: "label needs: work when changes were requested"
27+
conditions:
28+
# Reviewers
29+
- "#changes-requested-reviews-by>0"
30+
actions:
31+
label:
32+
add:
33+
- "needs: work"
34+
remove:
35+
- "needs: review"
36+
37+
# From needs: review to needs: work - CI failure
38+
- name: "label needs: work when travis-ci failed"
39+
conditions:
40+
# Travis failing
41+
- status-failure~=continuous-integration/travis-ci/pr
42+
actions:
43+
label:
44+
add:
45+
- "needs: work"
46+
remove:
47+
- "needs: review"
48+
49+
# From needs: review to needs: work - CI failure
50+
- name: "label needs: work when Jenkins CI failed - pr head"
51+
conditions:
52+
# Jenkins CI failing
53+
- status-failure~=continuous-integration/jenkins/pr-head
54+
actions:
55+
label:
56+
add:
57+
- "needs: work"
58+
remove:
59+
- "needs: review"
60+
61+
# From needs: review to needs: work - CI failure
62+
- name: "label needs: work when Jenkins CI failed - any of the pipeline"
63+
conditions:
64+
# Jenkins CI failing - any of the pipeline
65+
- status-failure~=^jenkins-ci
66+
actions:
67+
label:
68+
add:
69+
- "needs: work"
70+
remove:
71+
- "needs: review"
72+
73+
# From needs: review to needs: CI
74+
- name: "label needs: CI when at least one reviewers approval"
75+
conditions:
76+
# Labels
77+
- "label!=needs: work"
78+
- "label!=needs: preceding PR"
79+
80+
# Reviewers
81+
- "#changes-requested-reviews-by=0"
82+
- "#approved-reviews-by>=1"
83+
84+
# CI green policy, at least Travis should be green
85+
- status-success~=continuous-integration/travis-ci/pr
86+
# new CI needs to be done
87+
- status-neutral~=continuous-integration/jenkins/pr-head
88+
actions:
89+
label:
90+
add:
91+
- "needs: CI"
92+
remove:
93+
- "needs: review"
94+
95+
# Conflict in the PR - needs: work and a comment to notify a user
96+
- name: "label needs: work when there is a conflict"
97+
conditions:
98+
- conflict
99+
actions:
100+
label:
101+
add:
102+
- "needs: work"
103+
remove:
104+
- "needs: review"
105+
comment:
106+
message: This PR cannot be merged due to conflicts. Please rebase to resolve them.
107+
108+
- name: "add label feature branch for feature branch additions"
109+
conditions:
110+
- base~=^feature
111+
actions:
112+
label:
113+
add:
114+
- "release-version: feature branch"
115+
116+
# Ready for integration. Not yet auto merge, will be enabled once carefuly tested
117+
- name: label "ready for merge" when ready
118+
conditions:
119+
# Labels
120+
- label!=do not merge
121+
- "label=needs: CI"
122+
123+
# Reviewers
124+
- "#approved-reviews-by>=1"
125+
- "#changes-requested-reviews-by=0"
126+
127+
# CI green policy
128+
- status-success~=continuous-integration/travis-ci/pr
129+
# Internal Jenkins - we rely on PR head to provide status
130+
- status-success~=continuous-integration/jenkins/pr-head
131+
# any of the jenkins pipeline needs to be green
132+
- status-success~=^jenkins-ci
133+
actions:
134+
label:
135+
add:
136+
- ready for merge
137+
remove:
138+
- "needs: CI"
139+
140+
# Clean-up after merge
141+
- name: remove ready for merge when merged
142+
conditions:
143+
- merged
144+
- label=ready for merge
145+
actions:
146+
label:
147+
remove:
148+
- ready for merge
149+
150+
- name: add "do not merge" label when WIP is in title
151+
conditions:
152+
- title~=^(\[wip\]( |:) |\[WIP\]( |:) |wip( |:) |WIP( |:)).*
153+
actions:
154+
label:
155+
add:
156+
- do not merge
157+
158+
# Check if version label is applied
159+
- name: release version is a must for merged PRs
160+
conditions:
161+
- merged
162+
- -label~=^(release-version)
163+
actions:
164+
label:
165+
add:
166+
- Release review required
167+
comment:
168+
message: This PR does not contain release version label after merging.
169+
170+

0 commit comments

Comments
 (0)