Read about our upcoming Code of Conduct on this issue

rules.gitlab-ci.yml 26 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
##############
# 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
14
  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 || $FORCE_GITLAB_CI'
15
16
17
18

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

19
20
21
22
23
24
25
26
27
.if-master-push: &if-master-push
  if: '$CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "push"'

.if-master-schedule-2-hourly: &if-master-schedule-2-hourly
  if: '$CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "schedule" && $FREQUENCY == "2-hourly"'

.if-master-schedule-nightly: &if-master-schedule-nightly
  if: '$CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "schedule" && $FREQUENCY == "nightly"'

28
29
30
.if-auto-deploy-branches: &if-auto-deploy-branches
  if: '$CI_COMMIT_BRANCH =~ /^\d+-\d+-auto-deploy-\d+$/'

31
32
33
34
35
36
.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'

37
38
39
.if-merge-request-title-as-if-foss: &if-merge-request-title-as-if-foss
  if: '$CI_MERGE_REQUEST_TITLE =~ /RUN AS-IF-FOSS/'

40
41
42
.if-merge-request-title-update-caches: &if-merge-request-title-update-caches
  if: '$CI_MERGE_REQUEST_TITLE =~ /UPDATE CACHE/'

43
44
45
.if-merge-request-title-run-all-rspec: &if-merge-request-title-run-all-rspec
  if: '$CI_MERGE_REQUEST_TITLE =~ /RUN ALL RSPEC/'

46
47
.if-security-merge-request: &if-security-merge-request
  if: '$CI_PROJECT_NAMESPACE == "gitlab-org/security" && $CI_MERGE_REQUEST_IID'
48

49
50
51
52
53
54
55
56
57
.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'

58
59
60
.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'

61
62
63
64
65
66
67
68
69
.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"'

70
71
72
73
74
75
.if-rspec-fail-fast-disabled: &if-rspec-fail-fast-disabled
  if: '$RSPEC_FAIL_FAST_ENABLED != "true"'

.if-rspec-fail-fast-skipped: &if-rspec-fail-fast-skipped
  if: '$CI_MERGE_REQUEST_TITLE =~ /SKIP RSPEC FAIL-FAST/'

76
77
78
79
80
81
# For Security merge requests, the gitlab-release-tools-bot triggers a new
# pipeline for the "Pipelines for merged results" feature. If the pipeline
# fails, we notify release managers.
.if-security-pipeline-merge-result: &if-security-pipeline-merge-result
  if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH && $CI_PROJECT_NAMESPACE == "gitlab-org/security" && $GITLAB_USER_LOGIN == "gitlab-release-tools-bot"'

82
83
84
####################
# Changes patterns #
####################
85
86
87
88
.ci-patterns: &ci-patterns
  - ".gitlab-ci.yml"
  - ".gitlab/ci/**/*"

89
90
91
92
93
94
95
96
97
.ci-build-images-patterns: &ci-build-images-patterns
  - ".gitlab-ci.yml"
  - ".gitlab/ci/build-images.gitlab-ci.yml"

.ci-review-patterns: &ci-review-patterns
  - ".gitlab-ci.yml"
  - ".gitlab/ci/frontend.gitlab-ci.yml"
  - ".gitlab/ci/build-images.gitlab-ci.yml"
  - ".gitlab/ci/review.gitlab-ci.yml"
98
  - "scripts/trigger-build"
99
100
101
102
103
104
105

.ci-qa-patterns: &ci-qa-patterns
  - ".gitlab-ci.yml"
  - ".gitlab/ci/frontend.gitlab-ci.yml"
  - ".gitlab/ci/build-images.gitlab-ci.yml"
  - ".gitlab/ci/qa.gitlab-ci.yml"

106
107
108
109
110
111
112
113
.yaml-patterns: &yaml-patterns
  - "**/*.yml"

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

114
115
116
117
118
.frontend-dependency-patterns: &frontend-dependency-patterns
  - "{package.json,yarn.lock}"

.frontend-patterns: &frontend-patterns
  - "{package.json,yarn.lock}"
119
120
  - "babel.config.js"
  - "jest.config.{base,integration,unit}.js"
121
122
  - ".csscomb.json"
  - "Dockerfile.assets"
123
  - "config/**/*.js"
124
125
126
  - "vendor/assets/**/*"
  - "{,ee/}{app/assets,app/helpers,app/presenters,app/views,locale,public,symbol}/**/*"

127
128
129
130
131
132
133
134
135
136
.backend-patterns: &backend-patterns
  - "Gemfile{,.lock}"
  - "Rakefile"
  - "config.ru"
  # List explicitly all the app/ dirs that are backend (i.e. all except app/assets).
  - "{,ee/}{app/channels,app/controllers,app/finders,app/graphql,app/helpers,app/mailers,app/models,app/policies,app/presenters,app/serializers,app/services,app/uploaders,app/validators,app/views,app/workers}/**/*"
  - "{,ee/}{bin,cable,config,db,lib}/**/*"
  - "{,ee/}spec/**/*.rb"
  - ".gitlab-ci.yml"
  - ".gitlab/ci/**/*"
137
  - "*_VERSION"
138
139
140

.db-patterns: &db-patterns
  - "{,ee/}{,spec/}{db,migrations}/**/*"
141
142
  - "{,ee/}{,spec/}lib/{,ee/}gitlab/database/**/*"
  - "{,ee/}{,spec/}lib/{,ee/}gitlab/database{,_spec}.rb"
143
  - "{,ee/}{,spec/}lib/{,ee/}gitlab/background_migration/**/*"
144
  - "{,ee/}{,spec/}lib/{,ee/}gitlab/background_migration{,_spec}.rb"
145
  - "config/prometheus/common_metrics.yml" # Used by Gitlab::DatabaseImporters::CommonMetrics::Importer
146
  - "{,ee/}app/models/project_statistics.rb" # Used to calculate sizes in migration specs
147

148
149
150
151
152
153
154
155
.backstage-patterns: &backstage-patterns
  - "Dangerfile"
  - "danger/**/*"
  - "{,ee/}fixtures/**/*"
  - "{,ee/}rubocop/**/*"
  - "{,ee/}spec/**/*"

.code-patterns: &code-patterns
156
  - "{package.json,yarn.lock}"
157
158
  - "babel.config.js"
  - "jest.config.{base,integration,unit}.js"
159
160
161
  - ".csscomb.json"
  - "Dockerfile.assets"
  - "vendor/assets/**/*"
162
163
164
165
166
167
  - ".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"
168
  - "tests.yml"
169
170
171
172
173
174
175
176
177
  - "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
178
  - "{package.json,yarn.lock}"
179
180
  - "babel.config.js"
  - "jest.config.{base,integration,unit}.js"
181
182
183
  - ".csscomb.json"
  - "Dockerfile.assets"
  - "vendor/assets/**/*"
184
185
186
187
188
189
  - ".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"
190
  - "tests.yml"
191
192
193
194
195
196
197
198
199
200
201
  - "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/**/*"

.code-qa-patterns: &code-qa-patterns
202
  - "{package.json,yarn.lock}"
203
204
  - "babel.config.js"
  - "jest.config.{base,integration,unit}.js"
205
206
207
  - ".csscomb.json"
  - "Dockerfile.assets"
  - "vendor/assets/**/*"
208
209
210
211
212
213
  - ".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"
214
  - "tests.yml"
215
216
217
218
219
220
221
222
  - "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
223
  - "{package.json,yarn.lock}"
224
225
  - "babel.config.js"
  - "jest.config.{base,integration,unit}.js"
226
227
228
  - ".csscomb.json"
  - "Dockerfile.assets"
  - "vendor/assets/**/*"
229
230
231
232
233
234
  - ".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"
235
  - "tests.yml"
236
237
238
239
240
241
242
243
244
245
246
247
248
  - "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/**/*"
  # QA changes
  - ".dockerignore"
  - "qa/**/*"

249
250
251
252
253
254
255
256
################
# Shared rules #
################
.shared:rules:update-cache:
  rules:
    - <<: *if-master-schedule-2-hourly
    - <<: *if-merge-request-title-update-caches

257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
######################
# Build images rules #
######################
.build-images:rules:build-qa-image:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-dot-com-gitlab-org-and-security-merge-request
      changes: *ci-build-images-patterns
    - <<: *if-dot-com-gitlab-org-and-security-merge-request
      changes: *code-qa-patterns
    - <<: *if-dot-com-gitlab-org-schedule

.build-images:rules:build-assets-image:
  rules:
    - <<: *if-not-canonical-namespace
      when: never
    - changes: *ci-build-images-patterns
    - changes: *code-qa-patterns

277
278
279
280
281
282
####################
# Cache repo rules #
####################
.cache-repo:rules:
  rules:
    - <<: *if-cache-credentials-schedule
283
      allow_failure: true
284
285
286
287
288
289
290
291

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

294
295
296
297
298
299
300
301
##################
# Delivery rules #
##################
.delivery:rules:security-pipeline-merge-result-failure:
  rules:
    - <<: *if-security-pipeline-merge-result
      when: on_failure

302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
######################
# 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
327
      allow_failure: true
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345

.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 #
##################
346
.frontend:rules:compile-production-assets:
347
348
349
350
  rules:
    - <<: *if-not-canonical-namespace
      when: never
    - <<: *if-default-refs
351
      changes: *code-qa-patterns
352

353
.frontend:rules:compile-test-assets:
354
  rules:
355
    - changes: *code-backstage-qa-patterns
356
    - <<: *if-merge-request-title-run-all-rspec
357

358
.frontend:rules:compile-test-assets-as-if-foss:
359
360
361
  rules:
    - <<: *if-not-ee
      when: never
362
    - <<: *if-merge-request  # Always run for MRs since `compile-test-assets as-if-foss` is either needed by `rspec foss-impact` or the `rspec * as-if-foss` jobs.
363
      changes: *code-backstage-qa-patterns
364
365
366
367
368
369

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

370
.frontend:rules:default-frontend-jobs-as-if-foss:
371
372
373
  rules:
    - <<: *if-not-ee
      when: never
374
375
376
377
378
379
    - <<: *if-security-merge-request
      changes: *code-backstage-patterns
    - <<: *if-merge-request-title-as-if-foss
    - <<: *if-merge-request
      changes: *ci-patterns

380
381
382
383
384
385
386
387
388
.frontend:rules:eslint-as-if-foss:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-merge-request-title-as-if-foss
      when: never
    - <<: *if-merge-request
      changes: *frontend-patterns

389
390
391
392
393
394
395
.frontend:rules:ee-mr-and-master-only:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-merge-request
      changes: *code-backstage-patterns
    - <<: *if-master-refs
396
397
398
399
400
      changes: *code-backstage-patterns

.frontend:rules:qa-frontend-node:
  rules:
    - <<: *if-master-refs
401
      changes: *frontend-dependency-patterns
402
403
    - <<: *if-merge-request
      changes: *frontend-dependency-patterns
404

405
406
407
408
409
410
411
412
413
.frontend:rules:qa-frontend-node-latest:
  rules:
    - <<: *if-master-refs
      changes: *frontend-dependency-patterns
      allow_failure: true
    - <<: *if-merge-request
      changes: *frontend-dependency-patterns
      allow_failure: true

414
415
416
417
418
419
.frontend:rules:bundle-size-review:
  rules:
    - if: '$DANGER_GITLAB_API_TOKEN && $CI_MERGE_REQUEST_IID && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"'
      changes: *frontend-patterns
      allow_failure: true

420
421
422
423
424
425
426
427
428
429
430
431
432
433
################
# Memory rules #
################
.memory:rules:
  rules:
    - <<: *if-default-refs
      changes: *code-patterns
      when: on_success

###############
# Pages rules #
###############
.pages:rules:
  rules:
434
435
    - <<: *if-not-ee
      when: never
436
    - <<: *if-master-schedule-2-hourly
437
438
439
440
441
442
443
444
445
446

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

447
.qa:rules:as-if-foss:
448
449
450
  rules:
    - <<: *if-not-ee
      when: never
451
452
453
454
455
    - <<: *if-security-merge-request
      changes: *code-qa-patterns
    - <<: *if-merge-request-title-as-if-foss
    - <<: *if-merge-request
      changes: *ci-patterns
456
457
458

.qa:rules:package-and-qa:
  rules:
459
    - <<: *if-dot-com-gitlab-org-and-security-merge-request
460
      changes: *ci-qa-patterns
461
      allow_failure: true
462
    - <<: *if-dot-com-gitlab-org-and-security-merge-request
463
      changes: *qa-patterns
464
      allow_failure: true
465
    - <<: *if-dot-com-gitlab-org-and-security-merge-request
466
467
      changes: *code-patterns
      when: manual
468
      allow_failure: true
469
    - <<: *if-dot-com-gitlab-org-schedule
470
      allow_failure: true
471
472
473
474

###############
# Rails rules #
###############
475
.rails:rules:ee-and-foss-migration:
476
  rules:
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
    - changes: *db-patterns
    - <<: *if-merge-request-title-run-all-rspec

.rails:rules:ee-and-foss-unit:
  rules:
    - changes: *backend-patterns
    - <<: *if-merge-request-title-run-all-rspec

.rails:rules:ee-and-foss-integration:
  rules:
    - changes: *backend-patterns
    - <<: *if-merge-request-title-run-all-rspec

.rails:rules:ee-and-foss-system:
  rules:
    - changes: *code-backstage-patterns
    - <<: *if-merge-request-title-run-all-rspec

.rails:rules:ee-and-foss-fast_spec_helper:
  rules:
    - changes: ["config/**/*"]
    - <<: *if-merge-request-title-run-all-rspec
499
500
501
502
503

.rails:rules:default-refs-code-backstage-qa:
  rules:
    - <<: *if-default-refs
      changes: *code-backstage-qa-patterns
504
    - <<: *if-merge-request-title-run-all-rspec
505

506
.rails:rules:ee-only-migration:
507
  rules:
508
509
    - <<: *if-not-ee
      when: never
510
511
    - changes: *db-patterns
    - <<: *if-merge-request-title-run-all-rspec
512

513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
.rails:rules:ee-only-unit:
  rules:
    - <<: *if-not-ee
      when: never
    - changes: *backend-patterns
    - <<: *if-merge-request-title-run-all-rspec

.rails:rules:ee-only-integration:
  rules:
    - <<: *if-not-ee
      when: never
    - changes: *backend-patterns
    - <<: *if-merge-request-title-run-all-rspec

.rails:rules:ee-only-system:
  rules:
    - <<: *if-not-ee
      when: never
    - changes: *code-backstage-patterns
    - <<: *if-merge-request-title-run-all-rspec

.rails:rules:as-if-foss-migration:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-security-merge-request
      changes: *db-patterns
    - <<: *if-merge-request-title-as-if-foss
541
      changes: *db-patterns
542
543
544
545
546
547
548
549
550
551
    - <<: *if-merge-request
      changes: *ci-patterns

.rails:rules:as-if-foss-unit:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-security-merge-request
      changes: *backend-patterns
    - <<: *if-merge-request-title-as-if-foss
552
      changes: *backend-patterns
553
554
555
556
557
558
559
560
561
562
    - <<: *if-merge-request
      changes: *ci-patterns

.rails:rules:as-if-foss-integration:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-security-merge-request
      changes: *backend-patterns
    - <<: *if-merge-request-title-as-if-foss
563
      changes: *backend-patterns
564
565
566
567
    - <<: *if-merge-request
      changes: *ci-patterns

.rails:rules:as-if-foss-system:
568
569
570
  rules:
    - <<: *if-not-ee
      when: never
571
572
573
    - <<: *if-security-merge-request
      changes: *code-backstage-patterns
    - <<: *if-merge-request-title-as-if-foss
574
      changes: *code-backstage-patterns
575
576
    - <<: *if-merge-request
      changes: *ci-patterns
577

578
.rails:rules:ee-mr-and-master-only:
579
580
581
  rules:
    - <<: *if-not-ee
      when: never
582
    - <<: *if-merge-request-title-run-all-rspec
583
584
585
    - <<: *if-merge-request
      changes: *code-backstage-patterns
    - <<: *if-master-refs
586
587
      changes: *code-backstage-patterns

588
589
590
591
592
593
594
595
596
597
.rails:rules:detect-tests:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-security-merge-request
      changes: *code-backstage-patterns
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-backstage-patterns

.rails:rules:rspec-foss-impact:
598
599
600
601
602
603
604
605
606
607
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-merge-request-title-as-if-foss
      when: never
    - <<: *if-security-merge-request
      changes: *code-backstage-patterns
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-backstage-patterns

608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
.rails:rules:rspec fail-fast:
  rules:
    - <<: *if-rspec-fail-fast-disabled
      when: never
    - <<: *if-rspec-fail-fast-skipped
      when: never
    - <<: *if-not-ee
      when: never
    - <<: *if-security-merge-request
      changes: *code-backstage-patterns
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-backstage-patterns

.rails:rules:fail-pipeline-early:
  rules:
    - <<: *if-rspec-fail-fast-disabled
      when: never
    - <<: *if-rspec-fail-fast-skipped
      when: never
    - <<: *if-not-ee
      when: never
    - <<: *if-security-merge-request
      changes: *code-backstage-patterns
      when: on_failure
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-backstage-patterns
      when: on_failure

636
637
638
639
640
.rails:rules:downtime_check:
  rules:
    - <<: *if-merge-request
      changes: *code-backstage-patterns

641
642
643
644
.rails:rules:rspec-coverage:
  rules:
    - <<: *if-not-ee
      when: never
645
646
    - <<: *if-merge-request
      changes: *code-backstage-patterns
647
648
649
    - <<: *if-master-schedule-2-hourly
    - <<: *if-merge-request-title-run-all-rspec

650
651
652
653
654
655
656
.rails:rules:rspec-feature-flags:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-master-schedule-2-hourly
    - <<: *if-merge-request-title-run-all-rspec

657
658
659
660
661
662
663
664
665
666
667
668
669
670
.rails:rules:master-schedule-nightly--code-backstage:
  rules:
    - <<: *if-master-schedule-nightly
    - <<: *if-merge-request
      changes: [".gitlab/ci/rails.gitlab-ci.yml"]

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

671
672
673
674
675
##################
# Releases rules #
##################
.releases:rules:canonical-dot-com-gitlab-stable-branch-only:
  rules:
676
    - if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_PATH == "gitlab-org/gitlab" && $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable-ee$/'
677
678
679

.releases:rules:canonical-dot-com-security-gitlab-stable-branch-only:
  rules:
680
    - if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_PATH == "gitlab-org/security/gitlab" && $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable-ee$/'
681
682
683
684
685
686
687
688
689
690
691

#################
# 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
692
      allow_failure: true
693
694
695
696
697
698
699
700

.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
701
      allow_failure: true
702
703
704
705
706
707
708
709

.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
710
      allow_failure: true
711
712
713
714
715

.reports:rules:dast:
  rules:
    - if: '$DAST_DISABLED || $GITLAB_FEATURES !~ /\bdast\b/'
      when: never
716
717
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *frontend-patterns
718
      allow_failure: true
719
720
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
721
      when: manual
722
      allow_failure: true
723
724
725
726
727

.reports:schedule-dast:
  rules:
    - if: '$DAST_DISABLED || $GITLAB_FEATURES !~ /\bdast\b/'
      when: never
728
729
    - <<: *if-master-schedule-nightly
      allow_failure: true
730

731
732
733
734
735
736
737
738
.reports:rules:license_scanning:
  rules:
    - if: '$LICENSE_SCANNING_DISABLED || $GITLAB_FEATURES !~ /\blicense_scanning\b/'
      when: never
    - <<: *if-default-refs
      changes: *code-backstage-qa-patterns
      allow_failure: true

739
740
741
################
# Review rules #
################
742
.review:rules:review-build-cng:
743
  rules:
744
745
746
    - <<: *if-not-ee
      when: never
    - <<: *if-dot-com-gitlab-org-merge-request
747
      changes: *ci-review-patterns
748
749
750
751
752
753
754
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *frontend-patterns
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
      when: manual
      allow_failure: true
    - <<: *if-dot-com-gitlab-org-schedule
755

756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
.review:rules:review-deploy:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *ci-review-patterns
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *frontend-patterns
      allow_failure: true
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
      when: manual
      allow_failure: true
    - <<: *if-dot-com-gitlab-org-schedule
      allow_failure: true

.review:rules:review-performance:
773
  rules:
774
775
    - if: '$DAST_RUN == "true"' # Skip this job when DAST is run
      when: never
776
777
778
    - <<: *if-not-ee
      when: never
    - <<: *if-dot-com-gitlab-org-merge-request
779
      changes: *ci-review-patterns
780
781
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *frontend-patterns
782
      allow_failure: true
783
784
785
786
787
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
      when: manual
      allow_failure: true
    - <<: *if-dot-com-gitlab-org-schedule
788
      allow_failure: true
789

790
.review:rules:review-stop-failed-deployment:
791
  rules:
792
793
    - <<: *if-not-ee
      when: never
794
795
796
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns

797
.review:rules:review-qa-smoke:
798
  rules:
799
800
801
    - <<: *if-not-ee
      when: never
    - <<: *if-dot-com-gitlab-org-merge-request
802
      changes: *ci-review-patterns
803
804
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *frontend-patterns
805
      allow_failure: true
806
807
808
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
      when: manual
809
      allow_failure: true
810

811
812
.review:rules:mr-only-manual:
  rules:
813
814
    - <<: *if-not-ee
      when: never
815
816
817
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
      when: manual
818
      allow_failure: true
819
820
821

.review:rules:review-cleanup:
  rules:
822
823
    - <<: *if-not-ee
      when: never
824
825
826
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
      when: manual
827
      allow_failure: true
828
    - <<: *if-dot-com-gitlab-org-schedule
829
      allow_failure: true
830

831
832
833
834
835
836
837
838
839
840
841
.review:rules:review-stop:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-dot-com-gitlab-org-merge-request
      changes: *code-qa-patterns
      when: manual
      allow_failure: true
    - <<: *if-dot-com-gitlab-org-schedule
      allow_failure: true

842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
.review:rules:danger:
  rules:
    - if: '$DANGER_GITLAB_API_TOKEN && $CI_MERGE_REQUEST_IID'

###############
# 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

857
858
859
.setup:rules:dont-interrupt-me:
  rules:
    - <<: *if-master-or-tag
860
      allow_failure: true
861
    - <<: *if-auto-deploy-branches
862
      allow_failure: true
863
    - when: manual
864
      allow_failure: true
865

866
867
868
869
870
871
872
873
874
875
876
877
878
879
.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

880
881
882
883
884
885
886
887
.setup:rules:verify-tests-yml:
  rules:
    - <<: *if-not-ee
      when: never
    - <<: *if-default-refs
      changes: *code-backstage-patterns
      when: on_success

888
889
890
891
892
893
894
895
#######################
# Test metadata rules #
#######################
.test-metadata:rules:retrieve-tests-metadata:
  rules:
    - <<: *if-default-refs
      changes: *code-backstage-patterns
      when: on_success
896
    - <<: *if-merge-request-title-run-all-rspec
897
898
899

.test-metadata:rules:update-tests-metadata:
  rules:
900
901
902
903
904
    - <<: *if-not-ee
      when: never
    - changes:
        - ".gitlab/ci/test-metadata.gitlab-ci.yml"
        - "scripts/rspec_helpers.sh"
905
906
907
908
909
910
911
912
913
914
    - <<: *if-dot-com-ee-schedule
      changes: *code-backstage-patterns

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