Read about our upcoming Code of Conduct on this issue

rules.gitlab-ci.yml 15.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
##############
# Conditions #
##############
.if-not-canonical-namespace: &if-not-canonical-namespace
  if: '$CI_PROJECT_NAMESPACE !~ /^gitlab(-org)?($|\/)/'

.if-not-ee: &if-not-ee
  if: '$CI_PROJECT_NAME !~ /^gitlab(-ee)?$/'

.if-not-foss: &if-not-foss
  if: '$CI_PROJECT_NAME != "gitlab-foss" && $CI_PROJECT_NAME != "gitlab-ce" && $CI_PROJECT_NAME != "gitlabhq"'

.if-default-refs: &if-default-refs
  if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable(-ee)?$/ || $CI_COMMIT_REF_NAME =~ /^\d+-\d+-auto-deploy-\d+$/ || $CI_COMMIT_REF_NAME =~ /^security\// || $CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG'

.if-master-refs: &if-master-refs
  if: '$CI_COMMIT_REF_NAME == "master"'

19
20
21
.if-auto-deploy-branches: &if-auto-deploy-branches
  if: '$CI_COMMIT_BRANCH =~ /^\d+-\d+-auto-deploy-\d+$/'

22
23
24
25
26
27
.if-master-or-tag: &if-master-or-tag
  if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_TAG'

.if-merge-request: &if-merge-request
  if: '$CI_MERGE_REQUEST_IID'

28
29
30
.if-nightly-master-schedule: &if-nightly-master-schedule
  if: '$NIGHTLY && $CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "schedule"'

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
.if-dot-com-gitlab-org-schedule: &if-dot-com-gitlab-org-schedule
  if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_PIPELINE_SOURCE == "schedule"'

.if-dot-com-gitlab-org-master: &if-dot-com-gitlab-org-master
  if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_COMMIT_REF_NAME == "master"'

.if-dot-com-gitlab-org-merge-request: &if-dot-com-gitlab-org-merge-request
  if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_MERGE_REQUEST_IID'

.if-dot-com-gitlab-org-and-security-merge-request: &if-dot-com-gitlab-org-and-security-merge-request
  if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE =~ /^gitlab-org($|\/security$)/ && $CI_MERGE_REQUEST_IID'

.if-dot-com-gitlab-org-and-security-tag: &if-dot-com-gitlab-org-and-security-tag
  if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE =~ /^gitlab-org($|\/security$)/ && $CI_COMMIT_TAG'

.if-dot-com-ee-schedule: &if-dot-com-ee-schedule
  if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_PATH == "gitlab-org/gitlab" && $CI_PIPELINE_SOURCE == "schedule"'

.if-cache-credentials-schedule: &if-cache-credentials-schedule
  if: '$CI_REPO_CACHE_CREDENTIALS && $CI_PIPELINE_SOURCE == "schedule"'

####################
# Changes patterns #
####################
.yaml-patterns: &yaml-patterns
  - "**/*.yml"

.docs-patterns: &docs-patterns
  - ".gitlab/route-map.yml"
  - "doc/**/*"
  - ".markdownlint.json"

63
64
65
66
67
68
69
70
71
72
73
.frontend-dependency-patterns: &frontend-dependency-patterns
  - "{package.json,yarn.lock}"

.frontend-patterns: &frontend-patterns
  - "{package.json,yarn.lock}"
  - "{babel.config,jest.config}.js"
  - ".csscomb.json"
  - "Dockerfile.assets"
  - "vendor/assets/**/*"
  - "{,ee/}{app/assets,app/helpers,app/presenters,app/views,locale,public,symbol}/**/*"

74
75
76
77
78
79
80
81
82
.backstage-patterns: &backstage-patterns
  - "Dangerfile"
  - "danger/**/*"
  - "{,ee/}fixtures/**/*"
  - "{,ee/}rubocop/**/*"
  - "{,ee/}spec/**/*"
  - "doc/README.md"  # Some RSpec test rely on this file

.code-patterns: &code-patterns
83
84
85
86
87
  - "{package.json,yarn.lock}"
  - "{babel.config,jest.config}.js"
  - ".csscomb.json"
  - "Dockerfile.assets"
  - "vendor/assets/**/*"
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
  - ".gitlab/ci/**/*"
  - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
  - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
  - "*_VERSION"
  - "Gemfile{,.lock}"
  - "Rakefile"
  - "config.ru"
  - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
  - "doc/api/graphql/reference/*"  # Files in this folder are auto-generated

.qa-patterns: &qa-patterns
  - ".dockerignore"
  - "qa/**/*"

.code-backstage-patterns: &code-backstage-patterns
103
104
105
106
107
  - "{package.json,yarn.lock}"
  - "{babel.config,jest.config}.js"
  - ".csscomb.json"
  - "Dockerfile.assets"
  - "vendor/assets/**/*"
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
  - ".gitlab/ci/**/*"
  - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
  - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
  - "*_VERSION"
  - "Gemfile{,.lock}"
  - "Rakefile"
  - "config.ru"
  - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
  - "doc/api/graphql/reference/*"  # Files in this folder are auto-generated
  # Backstage changes
  - "Dangerfile"
  - "danger/**/*"
  - "{,ee/}fixtures/**/*"
  - "{,ee/}rubocop/**/*"
  - "{,ee/}spec/**/*"
  - "doc/README.md"  # Some RSpec test rely on this file

.code-qa-patterns: &code-qa-patterns
126
127
128
129
130
  - "{package.json,yarn.lock}"
  - "{babel.config,jest.config}.js"
  - ".csscomb.json"
  - "Dockerfile.assets"
  - "vendor/assets/**/*"
131
132
133
134
135
136
137
138
139
140
141
142
143
144
  - ".gitlab/ci/**/*"
  - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
  - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
  - "*_VERSION"
  - "Gemfile{,.lock}"
  - "Rakefile"
  - "config.ru"
  - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
  - "doc/api/graphql/reference/*"  # Files in this folder are auto-generated
  # QA changes
  - ".dockerignore"
  - "qa/**/*"

.code-backstage-qa-patterns: &code-backstage-qa-patterns
145
146
147
148
149
  - "{package.json,yarn.lock}"
  - "{babel.config,jest.config}.js"
  - ".csscomb.json"
  - "Dockerfile.assets"
  - "vendor/assets/**/*"
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
  - ".gitlab/ci/**/*"
  - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
  - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
  - "*_VERSION"
  - "Gemfile{,.lock}"
  - "Rakefile"
  - "config.ru"
  - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
  - "doc/api/graphql/reference/*"  # Files in this folder are auto-generated
  # Backstage changes
  - "Dangerfile"
  - "danger/**/*"
  - "{,ee/}fixtures/**/*"
  - "{,ee/}rubocop/**/*"
  - "{,ee/}spec/**/*"
  - "doc/README.md"  # Some RSpec test rely on this file
  # QA changes
  - ".dockerignore"
  - "qa/**/*"

####################
# Cache repo rules #
####################
.cache-repo:rules:
  rules:
    - <<: *if-cache-credentials-schedule
      when: on_success

#############
# CNG rules #
#############
.cng:rules:
  rules:
    - <<: *if-dot-com-gitlab-org-and-security-tag
      when: manual

######################
# Dev fixtures rules #
######################
.dev-fixtures:rules:ee-and-foss:
  rules:
    - <<: *if-default-refs
      changes: *code-backstage-patterns
      when: on_success

.dev-fixtures:rules:ee-only:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-default-refs
      changes: *code-backstage-patterns
      when: on_success

##############
# Docs rules #
##############
.docs:rules:review-docs:
  rules:
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *docs-patterns
      when: manual

.docs:rules:docs-lint:
  rules:
    - <<: *if-default-refs
      changes: *docs-patterns
      when: on_success

.docs:rules:graphql-reference-verify:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-default-refs
      changes: *code-backstage-qa-patterns
      when: on_success

##################
# Frontend rules #
##################
.frontend:rules:gitlab-assets-compile-pull-push-cache:
  rules:
    - <<: *if-not-canonical-namespace
      when: never
    - <<: *if-master-refs
      changes: *code-backstage-qa-patterns
      when: on_success

.frontend:rules:gitlab-assets-compile-pull-cache:
  rules:
    - <<: *if-not-canonical-namespace
      when: never
    - <<: *if-default-refs
      changes: *code-backstage-qa-patterns
      when: on_success

.frontend:rules:compile-assets-pull-push-cache:
  rules:
    - <<: *if-master-refs
      changes: *code-backstage-qa-patterns
      when: on_success

.frontend:rules:compile-assets-pull-push-cache-as-if-foss:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-master-refs
      changes: *code-backstage-qa-patterns
      when: on_success

.frontend:rules:compile-assets-pull-cache:
  rules:
    - <<: *if-default-refs
      changes: *code-backstage-qa-patterns
      when: on_success

.frontend:rules:compile-assets-pull-cache-as-if-foss:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-default-refs
      changes: *code-backstage-qa-patterns
      when: on_success

.frontend:rules:default-frontend-jobs:
  rules:
    - <<: *if-default-refs
      changes: *code-backstage-patterns
      when: on_success

279
.frontend:rules:default-frontend-jobs-no-foss:
280
281
282
283
284
285
286
287
288
289
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-default-refs
      changes: *code-backstage-patterns
      when: on_success

.frontend:rules:qa-frontend-node:
  rules:
    - <<: *if-master-refs
290
      changes: *frontend-dependency-patterns
291
      when: on_success
292
293
294
    - <<: *if-merge-request
      changes: *frontend-dependency-patterns
      when: on_success
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309

################
# Memory rules #
################
.memory:rules:
  rules:
    - <<: *if-default-refs
      changes: *code-patterns
      when: on_success

###############
# Pages rules #
###############
.pages:rules:
  rules:
310
311
    - <<: *if-not-ee
      when: never
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
    - <<: *if-dot-com-gitlab-org-master
      changes: *code-backstage-qa-patterns
      when: on_success

############
# QA rules #
############
.qa:rules:ee-and-foss:
  rules:
    - <<: *if-default-refs
      changes: *code-qa-patterns
      when: on_success

.qa:rules:ee-only:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-default-refs
      changes: *code-qa-patterns
      when: on_success

.qa:rules:package-and-qa:
  rules:
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *qa-patterns
      when: on_success
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-patterns
      when: manual
    - <<: *if-dot-com-gitlab-org-schedule
      when: on_success

###############
# Rails rules #
###############
.rails:rules:ee-and-foss:
  rules:
    - <<: *if-default-refs
      changes: *code-backstage-patterns
      when: on_success

.rails:rules:default-refs-code-backstage-qa:
  rules:
    - <<: *if-default-refs
      changes: *code-backstage-qa-patterns
      when: on_success

.rails:rules:master-refs-code-backstage:
  rules:
    - <<: *if-master-refs
      changes: *code-backstage-patterns
      when: on_success
364
    - changes: [".gitlab/ci/rails.gitlab-ci.yml"]
365

366
367
368
369
370
.rails:rules:nightly-master-refs-code-backstage:
  rules:
    - <<: *if-nightly-master-schedule
      changes: *code-backstage-patterns
      when: on_success
371
372
373
374
375
376
377
378
379
380
    - changes: [".gitlab/ci/rails.gitlab-ci.yml"]

.rails:rules:nightly-master-refs-code-backstage-ee-only:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-nightly-master-schedule
      changes: *code-backstage-patterns
      when: on_success
    - changes: [".gitlab/ci/rails.gitlab-ci.yml"]
381

382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
.rails:rules:ee-only:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-default-refs
      changes: *code-backstage-patterns
      when: on_success

.rails:rules:downtime_check:
  rules:
    - <<: *if-merge-request
      changes: *code-backstage-patterns
      when: on_success

##################
# Releases rules #
##################
.releases:rules:canonical-dot-com-gitlab-stable-branch-only:
  rules:
401
    - if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_PATH == "gitlab-org/gitlab" && $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable-ee$/'
402
403
404

.releases:rules:canonical-dot-com-security-gitlab-stable-branch-only:
  rules:
405
    - if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_PATH == "gitlab-org/security/gitlab" && $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable-ee$/'
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437

#################
# Reports rules #
#################
.reports:rules:code_quality:
  rules:
    - if: '$CODE_QUALITY_DISABLED'
      when: never
    # - <<: *if-master-refs  # To be done in a later iteration: https://gitlab.com/gitlab-org/gitlab/issues/31160#note_278188255
    - <<: *if-default-refs
      changes: *code-backstage-patterns

.reports:rules:sast:
  rules:
    - if: '$SAST_DISABLED || $GITLAB_FEATURES !~ /\bsast\b/'
      when: never
    # - <<: *if-master-refs  # To be done in a later iteration: https://gitlab.com/gitlab-org/gitlab/issues/31160#note_278188255
    - <<: *if-default-refs
      changes: *code-backstage-qa-patterns

.reports:rules:dependency_scanning:
  rules:
    - if: '$DEPENDENCY_SCANNING_DISABLED || $GITLAB_FEATURES !~ /\bdependency_scanning\b/'
      when: never
    # - <<: *if-master-refs  # To be done in a later iteration: https://gitlab.com/gitlab-org/gitlab/issues/31160#note_278188255
    - <<: *if-default-refs
      changes: *code-backstage-qa-patterns

.reports:rules:dast:
  rules:
    - if: '$DAST_DISABLED || $GITLAB_FEATURES !~ /\bdast\b/'
      when: never
438
439
440
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *frontend-patterns
      when: on_success
441
442
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
443
      when: manual
444
445
446
447
448
449
450
451
452
453

.reports:schedule-dast:
  rules:
    - if: '$DAST_DISABLED || $GITLAB_FEATURES !~ /\bdast\b/'
      when: never
    - <<: *if-dot-com-gitlab-org-schedule

################
# Review rules #
################
454
.review:rules:mr-and-schedule-auto:
455
456
457
458
459
460
461
  rules:
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
      when: on_success
    - <<: *if-dot-com-gitlab-org-schedule
      when: on_success

462
463
464
465
466
467
468
469
470
471
472
473
.review:rules:mr-and-schedule-auto-if-frontend-manual-otherwise:
  rules:
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *frontend-patterns
      when: on_success
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
      when: manual
      allow_failure: true
    - <<: *if-dot-com-gitlab-org-schedule
      when: on_success

474
475
476
477
478
479
.review:rules:mr-only-auto:
  rules:
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
      when: on_success

480
481
482
483
484
485
486
487
488
.review:rules:mr-only-auto-if-frontend-manual-otherwise:
  rules:
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *frontend-patterns
      when: on_success
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
      when: manual

489
490
491
492
493
494
495
496
497
498
499
500
501
502
.review:rules:mr-only-manual:
  rules:
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
      when: manual

.review:rules:review-cleanup:
  rules:
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
      when: manual
    - <<: *if-dot-com-gitlab-org-schedule
      when: on_success

503
504
505
.review:rules:review-gcp-cleanup:
  rules:
    - <<: *if-dot-com-gitlab-org-merge-request
506
      changes: *code-qa-patterns
507
508
509
510
      when: manual
    - <<: *if-dot-com-gitlab-org-schedule
      when: on_success

511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
.review:rules:danger:
  rules:
    - if: '$DANGER_GITLAB_API_TOKEN && $CI_MERGE_REQUEST_IID'
      when: on_success

###############
# Setup rules #
###############
.setup:rules:cache-gems:
  rules:
    - <<: *if-not-canonical-namespace
      when: never
    - <<: *if-master-or-tag
      changes: *code-backstage-qa-patterns
      when: on_success

527
528
529
530
531
532
533
534
.setup:rules:dont-interrupt-me:
  rules:
    - <<: *if-master-or-tag
      when: on_success
    - <<: *if-auto-deploy-branches
      when: on_success
    - when: manual

535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
.setup:rules:gitlab_git_test:
  rules:
    - <<: *if-default-refs
      changes: *code-backstage-patterns
      when: on_success

.setup:rules:no_ee_check:
  rules:
    - <<: *if-not-foss
      when: never
    - <<: *if-default-refs
      changes: *code-backstage-patterns
      when: on_success

#######################
# Test metadata rules #
#######################
.test-metadata:rules:retrieve-tests-metadata:
  rules:
    - <<: *if-default-refs
      changes: *code-backstage-patterns
      when: on_success

.test-metadata:rules:update-tests-metadata:
  rules:
    - <<: *if-dot-com-ee-schedule
      changes: *code-backstage-patterns
      when: on_success

##############
# YAML rules #
##############
.yaml:rules:
  rules:
    - <<: *if-default-refs
      changes: *yaml-patterns