Skip to content

Commit ba27e6c

Browse files
authored
Merge pull request #12255 from 0xc0170/dev_mergify
add mergify to automate our workflow
2 parents 22042e5 + 55d51a9 commit ba27e6c

File tree

1 file changed

+182
-0
lines changed

1 file changed

+182
-0
lines changed

.mergify.yml

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
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+
- base~=feature-mergify
29+
# Reviewers
30+
- "#changes-requested-reviews-by>0"
31+
actions:
32+
label:
33+
add:
34+
- "needs: work"
35+
remove:
36+
- "needs: review"
37+
38+
# From needs: review to needs: work - CI failure
39+
- name: "label needs: work when travis-ci failed"
40+
conditions:
41+
- base~=feature-mergify
42+
# Travis failing
43+
- status-failure~=continuous-integration/travis-ci/pr
44+
actions:
45+
label:
46+
add:
47+
- "needs: work"
48+
remove:
49+
- "needs: review"
50+
51+
# From needs: review to needs: work - CI failure
52+
- name: "label needs: work when Jenkins CI failed - pr head"
53+
conditions:
54+
- base~=feature-mergify
55+
# Jenkins CI failing
56+
- status-failure~=continuous-integration/jenkins/pr-head
57+
actions:
58+
label:
59+
add:
60+
- "needs: work"
61+
remove:
62+
- "needs: review"
63+
64+
# From needs: review to needs: work - CI failure
65+
- name: "label needs: work when Jenkins CI failed - any of the pipeline"
66+
conditions:
67+
- base~=feature-mergify
68+
# Jenkins CI failing - any of the pipeline
69+
- status-failure~=^jenkins-ci
70+
actions:
71+
label:
72+
add:
73+
- "needs: work"
74+
remove:
75+
- "needs: review"
76+
77+
# From needs: review to needs: CI
78+
- name: "label needs: CI when at least one reviewers approval"
79+
conditions:
80+
- base~=feature-mergify
81+
# Labels
82+
- "label!=needs: work"
83+
- "label!=needs: preceding PR"
84+
85+
# Reviewers
86+
- "#changes-requested-reviews-by=0"
87+
- "#approved-reviews-by>=1"
88+
89+
# CI green policy, at least Travis should be green
90+
- status-success~=continuous-integration/travis-ci/pr
91+
# new CI needs to be done
92+
- status-neutral~=continuous-integration/jenkins/pr-head
93+
actions:
94+
label:
95+
add:
96+
- "needs: CI"
97+
remove:
98+
- "needs: review"
99+
100+
# Conflict in the PR - needs: work and a comment to notify a user
101+
- name: "label needs: work when there is a conflict"
102+
conditions:
103+
- base~=feature-mergify
104+
- conflict
105+
actions:
106+
label:
107+
add:
108+
- "needs: work"
109+
remove:
110+
- "needs: review"
111+
- "needs: CI"
112+
comment:
113+
message: This PR cannot be merged due to conflicts. Please rebase to resolve them.
114+
115+
- name: "add label feature branch for feature branch additions"
116+
conditions:
117+
- base~=feature-mergify
118+
- base~=^feature
119+
actions:
120+
label:
121+
add:
122+
- "release-version: feature branch"
123+
124+
# Ready for integration. Not yet auto merge, will be enabled once carefuly tested
125+
- name: label "ready for merge" when ready
126+
conditions:
127+
- base~=feature-mergify
128+
# Labels
129+
- label!=do not merge
130+
- "label=needs: CI"
131+
132+
# Reviewers
133+
- "#approved-reviews-by>=1"
134+
- "#changes-requested-reviews-by=0"
135+
136+
# CI green policy
137+
- status-success~=continuous-integration/travis-ci/pr
138+
# Internal Jenkins - we rely on PR head to provide status
139+
- status-success~=continuous-integration/jenkins/pr-head
140+
# any of the jenkins pipeline needs to be green
141+
- status-success~=^jenkins-ci
142+
actions:
143+
label:
144+
add:
145+
- ready for merge
146+
remove:
147+
- "needs: CI"
148+
149+
# Clean-up after merge
150+
- name: remove ready for merge when merged
151+
conditions:
152+
- base~=feature-mergify
153+
- merged
154+
- label=ready for merge
155+
actions:
156+
label:
157+
remove:
158+
- ready for merge
159+
160+
- name: add "do not merge" label when WIP is in title
161+
conditions:
162+
- base~=feature-mergify
163+
- title~=^(\[wip\]( |:) |\[WIP\]( |:) |wip( |:) |WIP( |:)).*
164+
actions:
165+
label:
166+
add:
167+
- do not merge
168+
169+
# Check if version label is applied
170+
- name: release version is a must for merged PRs
171+
conditions:
172+
- base~=feature-mergify
173+
- merged
174+
- -label~=^(release-version)
175+
actions:
176+
label:
177+
add:
178+
- Release review required
179+
comment:
180+
message: This PR does not contain release version label after merging.
181+
182+

0 commit comments

Comments
 (0)