1 # Mix-in definitions to inherit a standardized *rules* parameter.
3 # * https://docs.gitlab.com/ee/ci/yaml/#rules
4 # * https://docs.gitlab.com/ee/ci/variables/README.html#syntax-of-environment-variable-expressions
6 # GitLab CI uses a YAML array for the *rules* job parameter, but neither YAML
7 # nor GitLab CI syntax provide a way to merge arrays. However, elements of
8 # *rules* are mappings, and we can at least reduce the amount of copy-paste
9 # syntax by providing anchors and example arrays.
10 # The following YAML objects may be referenced through "anchors" as elements of
11 # the *rules* array in mix-in jobs (defined later in the file).
12 # The &<name> annotation is a YAML anchor that allows the annotated {"if", "when"} hash
13 # to be inserted with a *<name> alias in a `rules` arrays in the current file.
14 # Commonly reusable elements have anchors defined for easy copy-paste templating
15 # of new rule sets. Rule elements that are unique to a single *rules* mix-in may
16 # be defined with the rule set for readability, particularly when the element is
17 # the main distinguishing characteristic of the mix-in.
19 # Exclude from pipelines launched outside the "gromacs" GitLab project namespace.
20 .rules-element:if-not-gromacs-then-never: &if-not-gromacs-then-never
21 if: '$CI_PROJECT_NAMESPACE != "gromacs"'
24 # Exclude if the GROMACS_RELEASE variable is set.
25 .rules-element:if-release-then-never: &if-release-then-never
26 if: '$GROMACS_RELEASE'
29 # Exclude unless the GROMACS_RELEASE variable is set (through the web interface).
30 .rules-element:if-not-release-then-never: &if-not-release-then-never
31 if: '$GROMACS_RELEASE == null'
34 # Include in pipelines triggered through the web interface.
35 .rules-element:if-web-then-always: &if-web-then-always
36 if: '$CI_PIPELINE_SOURCE == "web"'
39 # Exclude from pipelines triggered by "push" events.
40 .rules-element:if-push-then-never: &if-push-then-never
41 if: '$CI_PIPELINE_SOURCE == "push"'
44 # Include in pipelines triggered by "push" events to any branch.
45 .rules-element:if-push-then-always: &if-push-then-always
46 if: '$CI_PIPELINE_SOURCE == "push"'
49 # Include in "schedule" pipelines (e.g. nightly jobs)
50 .rules-element:if-schedule-then-always: &if-schedule-then-always
51 if: '$CI_PIPELINE_SOURCE == "schedule"'
54 # Exclude from selective "schedule" pipelines, e.g. just those
55 # that should run the post-merge-acceptance jobs.
56 .rules-element:if-post-merge-acceptance-then-never: &if-post-merge-acceptance-then-never
57 if: '$POST_MERGE_ACCEPTANCE'
60 # Include in pipelines triggered in the merge request process.
61 .rules-element:if-mr-then-always: &if-mr-then-always
62 if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
65 # Exclude from pipelines triggered in the merge request process, such as for
66 # jobs that duplicate checks already performed for "push" events or that we
67 # only want to run in scheduled / manually triggered pipelines.
68 .rules-element:if-mr-then-never: &if-mr-then-never
69 if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
72 # Include job when running for merge request or when pushing to protected branch.
73 .rules-element:if-post-merge-acceptance-or-mr-then-always: &if-post-merge-acceptance-or-mr-then-always
74 if: '$CI_PIPELINE_SOURCE == "merge_request_event" ||
75 ($CI_PIPELINE_SOURCE == "push" &&
76 $CI_COMMIT_REF_NAME == "master")'
79 # Include job only for post submit push
80 .rules-element:if-post-merge-acceptance-then-always: &if-post-merge-acceptance-then-always
81 if: '$CI_PIPELINE_SOURCE == "push" &&
82 $CI_COMMIT_REF_NAME == "master"'
85 # When composing a rule set, note that the first matching rule is applied.
86 # If you want later rules to be evaluated, you must make sure that the *if*
87 # clause of the earlier rules does not match. This may require inverting the
88 # logic of a rule element *if* and *when* clause in a new element definition
89 # (above) in order to construct new rule sets.
91 # Jobs that run for new commits and pipelines triggered by schedules or
92 # through the web interface, unless GROMACS_RELEASE is set. Excluded from
93 # extra pipelines generated by merge request events.
94 # Includes non-gromacs projects. Note that jobs using this rule are
95 # eligible to run on non-gromacs project infrastructure, and should therefore
96 # override the default *tag* parameter to exclude tags specific to the GROMACS
97 # GitLab Runner infrastructure. I.e. in the job definition, set `tags: []`
100 - *if-release-then-never
102 - *if-post-merge-acceptance-then-never
103 - *if-web-then-always
104 - *if-push-then-always
105 - *if-schedule-then-always
107 # Jobs to run after successful merge of a new commit.
108 # Only run on GROMACS infrastructure and only when merging into
109 # the master or release branches.
110 .rules:post-merge-acceptance:
112 - *if-not-gromacs-then-never
113 - *if-release-then-never
115 - *if-post-merge-acceptance-then-always
116 - *if-web-then-always
117 - *if-schedule-then-always
119 # Jobs that run for merge requests and schedules, but not when GROMACS_RELEASE
120 # is set. Excludes non-GROMACS projects.
121 # More elaborate rule sets for merge requests should be based on the same sequence.
122 .rules:merge-requests:
124 - *if-not-gromacs-then-never
125 - *if-release-then-never
126 - *if-push-then-never
127 - *if-post-merge-acceptance-then-never
128 - *if-web-then-always
129 - *if-schedule-then-always
132 # Jobs running both in post submit and for merge requests
133 # Excludes non-GROMACS projects.
134 .rules:merge-and-post-merge-acceptance:
136 - *if-not-gromacs-then-never
137 - *if-release-then-never
138 - *if-web-then-always
139 - *if-schedule-then-always
140 - *if-post-merge-acceptance-or-mr-then-always
142 # Jobs that run for merge requests and schedules for branch `master`,
143 # but not when GROMACS_RELEASE is set.
144 # Excludes non-gromacs projects.
145 .rules:merge-requests:master:
147 - *if-not-gromacs-then-never
148 - *if-release-then-never
149 - *if-post-merge-acceptance-then-never
150 - *if-web-then-always
151 # This rule catches "push" and other events in branches other than `master`
152 # but allows merge_request_events for merge requests targeting master.
153 - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "master" && $CI_COMMIT_REF_NAME != "master"'
155 - *if-schedule-then-always
158 # Jobs that run for merge requests and schedules for branch `release-2021`,
159 # but not when GROMACS_RELEASE is set.
160 # Excludes non-gromacs projects.
161 .rules:merge-requests:release-2021:
163 - *if-not-gromacs-then-never
164 - *if-release-then-never
165 - *if-post-merge-acceptance-then-never
166 # This next rule catches "push" and other events in branches other than `release-2021`
167 # but allows merge_request_events for merge requests targeting `release-2021`.
168 # This rule is before "web" so the web interface won't include jobs that can't succeed
169 # (and would not ordinarily be run). Such jobs are hard to identify in a way that is
170 # sufficiently general for a global rules definition.
171 # If extra coverage is needed through a web-triggered job in merge request branches,
172 # we could provide an additional short-circuiting rule based on an environment variable
173 # to be provided through the web interface.
174 - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "release-2021" && $CI_COMMIT_REF_NAME != "release-2021"'
176 - *if-web-then-always
177 - *if-schedule-then-always
180 # Jobs that run for merge requests and schedules for branch `release-2020`,
181 # but not when GROMACS_RELEASE is set.
182 # Excludes non-gromacs projects.
183 .rules:merge-requests:release-2020:
185 - *if-not-gromacs-then-never
186 - *if-release-then-never
187 - *if-post-merge-acceptance-then-never
188 # This next rule catches "push" and other events in branches other than `release-2020`
189 # but allows merge_request_events for merge requests targeting `release-2020`.
190 # This rule is before "web" so the web interface won't include jobs that can't succeed
191 # (and would not ordinarily be run). Such jobs are hard to identify in a way that is
192 # sufficiently general for a global rules definition.
193 # If extra coverage is needed through a web-triggered job in merge request branches,
194 # we could provide an additional short-circuiting rule based on an environment variable
195 # to be provided through the web interface.
196 - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "release-2020" && $CI_COMMIT_REF_NAME != "release-2020"'
198 - *if-web-then-always
199 - *if-schedule-then-always
202 # Rule to run a job only in nightly release-preparation pipelines.
203 # Checks if the GROMACS_RELEASE variable was set (typically through the GitLab web interface).
204 # Excludes merge_requests and non-gromacs projects.
205 .rules:nightly-only-for-release:
207 - *if-not-gromacs-then-never
208 - *if-not-release-then-never
209 - *if-post-merge-acceptance-then-never
210 - *if-web-then-always
211 - *if-schedule-then-always
213 # Jobs that run on schedules, but not for merge requests or when GROMACS_RELEASE
214 # is set. Excludes non-gromacs projects.
215 .rules:nightly-not-for-release:
217 - *if-not-gromacs-then-never
218 - *if-release-then-never
219 - *if-post-merge-acceptance-then-never
220 - *if-web-then-always
221 - *if-schedule-then-always