summaryrefslogtreecommitdiff
path: root/.gitlab/ci/review-apps/rules.gitlab-ci.yml
blob: a3ae31cb14cbd2a7c7bb00d5febb455f31f5f5ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# ------------------------------------------
# Conditions
# ------------------------------------------
# Specific specs passed
.specific-specs: &specific-specs
  if: $QA_TESTS != ""

# No specific specs passed
.all-specs: &all-specs
  if: $QA_TESTS == ""

# No specific specs in mr pipeline
.all-specs-mr: &all-specs-mr
  if: '($CI_MERGE_REQUEST_EVENT_TYPE == "merged_result" || $CI_MERGE_REQUEST_EVENT_TYPE == "detached") && $QA_TESTS == ""'
  when: manual

# Triggered by change pattern
.app-changes: &app-changes
  if: $APP_CHANGE_TRIGGER == "true"

# Run all tests when framework changes present or explicitly enabled full suite execution
.qa-run-all-tests: &qa-run-all-tests
  if: $QA_FRAMEWORK_CHANGES == "true" || $QA_RUN_ALL_TESTS == "true"

.default-branch: &default-branch
  if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH

.if-merge-request: &if-merge-request
  if: '$CI_MERGE_REQUEST_EVENT_TYPE == "merged_result" || $CI_MERGE_REQUEST_EVENT_TYPE == "detached"'

.if-merge-request-labels-run-review-app: &if-merge-request-labels-run-review-app
  if: '$CI_MERGE_REQUEST_LABELS =~ /pipeline:run-review-app/'

.if-dot-com-ee-schedule-nightly-child-pipeline: &if-dot-com-ee-schedule-nightly-child-pipeline
  if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_PATH == "gitlab-org/gitlab" && $CI_PIPELINE_SOURCE == "parent_pipeline" && $SCHEDULE_TYPE == "nightly"'

# ------------------------------------------
# Changes patterns
# ------------------------------------------
.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"
  - ".gitlab/ci/review-apps/**/*"
  - "scripts/review_apps/**/*"
  - "scripts/trigger-build.rb"
  - "{,ee/,jh/}{bin,config}/**/*.rb"

# ------------------------------------------
# Conditions set
# ------------------------------------------
.qa-manual: &qa-manual
  when: manual
  allow_failure: true
  variables:
    QA_TESTS: ""

.never-when-qa-run-all-tests-or-no-specific-specs:
  - <<: *qa-run-all-tests
    when: never
  - <<: *all-specs
    when: never

.never-when-specific-specs-always-when-qa-run-all-tests:
  - *qa-run-all-tests
  - <<: *specific-specs
    when: manual
    allow_failure: true
    variables:
      QA_TESTS: ""

# ------------------------------------------
# Prepare
# ------------------------------------------
.rules:dont-interrupt:
  rules:
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
      allow_failure: true
    - if: $CI_MERGE_REQUEST_IID
      when: manual
      allow_failure: true

.review:rules:review-build-cng:
  rules:
    - when: always

.review:rules:review-delete-deployment:
  rules:
    - when: on_success

# ------------------------------------------
# Deploy
# ------------------------------------------
.review:rules:review-deploy:
  rules:
    - when: on_success

.review:rules:trigger-review-stop:
  rules:
    - when: manual
      allow_failure: true

# ------------------------------------------
# Test
# ------------------------------------------
.rules:qa-smoke:
  rules:
    # always trigger smoke suite if review pipeline got triggered by specific changes in application code
    - <<: *app-changes
      variables:
        QA_TESTS: ""  # unset QA_TESTS even if specific tests were inferred from stage label
    - *qa-run-all-tests
    - if: $QA_SUITES =~ /Test::Instance::Smoke/
    - *qa-manual

.rules:qa-blocking:
  rules:
    - <<: *app-changes
      when: never
    - !reference [.never-when-qa-run-all-tests-or-no-specific-specs]
    - if: $QA_SUITES =~ /Test::Instance::ReviewBlocking/
.rules:qa-blocking-parallel:
  rules:
    # always trigger blocking suite if review pipeline got triggered by specific changes in application code
    - <<: *app-changes
      variables:
        QA_TESTS: ""  # unset QA_TESTS even if specific tests were inferred from stage label
    - !reference [.never-when-specific-specs-always-when-qa-run-all-tests]
    - if: $QA_SUITES =~ /Test::Instance::ReviewBlocking/

.rules:qa-non-blocking:
  rules:
    - !reference [.never-when-qa-run-all-tests-or-no-specific-specs]
    - if: $QA_SUITES =~ /Test::Instance::ReviewNonBlocking/
.rules:qa-non-blocking-parallel:
  rules:
    - !reference [.never-when-specific-specs-always-when-qa-run-all-tests]
    - *all-specs-mr  # set full suite to manual when no specific specs passed in mr
    - if: $QA_SUITES =~ /Test::Instance::ReviewNonBlocking/

.review:rules:review-performance:
  rules:
    - if: '$DAST_RUN == "true"'  # Skip this job when DAST is run
      when: never
    - <<: *if-merge-request-labels-run-review-app  # we explicitly don't allow the job to fail in that case
    - <<: *if-merge-request  # we explicitly don't allow the job to fail in that case
      changes: *ci-review-patterns
    - when: on_success
      allow_failure: true

# ------------------------------------------
# DAST
# ------------------------------------------
.reports:rules:schedule-dast:
  rules:
    - if: '$DAST_DISABLED || $GITLAB_FEATURES !~ /\bdast\b/'
      when: never
    - <<: *if-dot-com-ee-schedule-nightly-child-pipeline

# ------------------------------------------
# Prepare/Report
# ------------------------------------------
.rules:prepare-report:
  rules:
    - when: always

.rules:main-run:
  rules:
    - *default-branch