Read about our upcoming Code of Conduct on this issue

review.gitlab-ci.yml 8.9 KB
Newer Older
Stan Hu's avatar
Stan Hu committed
1
.review-docker:
2
3
  extends:
    - .default-retry
4
    - .use-docker-in-docker
5
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-qa-alpine-ruby-2.6
Stan Hu's avatar
Stan Hu committed
6
  variables:
7
    GITLAB_EDITION: "ce"
Kamil Trzciński's avatar
Kamil Trzciński committed
8
9

build-qa-image:
10
  extends:
11
12
    - .use-kaniko
    - .default-retry
13
    - .review:rules:mr-and-schedule-auto
14
  stage: prepare
Kamil Trzciński's avatar
Kamil Trzciński committed
15
  script:
16
    - '[[ ! -d "ee/" ]] || export GITLAB_EDITION="ee"'
17
18
    - export QA_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab-${GITLAB_EDITION}-qa:${CI_COMMIT_REF_SLUG}"
    - /kaniko/executor --context=${CI_PROJECT_DIR} --dockerfile=${CI_PROJECT_DIR}/qa/Dockerfile --destination=${QA_IMAGE} --cache=true
Kamil Trzciński's avatar
Kamil Trzciński committed
19

20
.review-cleanup-base:
21
22
  extends:
    - .default-retry
23
    - .review:rules:review-cleanup
24
25
26
27
28
29
30
31
32
33
34
  stage: prepare
  allow_failure: true
  environment:
    name: review/auto-cleanup
    action: stop
  before_script:
    - source scripts/utils.sh
    - install_gitlab_gem
  script:
    - ruby -rrubygems scripts/review_apps/automated_cleanup.rb

35
36
37
38
39
40
41
42
43
44
45
46
review-cleanup:
  extends:
    - .review-cleanup-base
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-charts-build-base

review-cleanup-helm3:
  extends:
    - .review-cleanup-base
  variables:
    HELM_3: 1
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-helm3-kubectl1.14

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
review-gcp-cleanup:
  extends:
    - .review:rules:review-gcp-cleanup
  stage: prepare
  image: gcr.io/google.com/cloudsdktool/cloud-sdk:latest
  allow_failure: true
  environment:
    name: review/auto-gcp-cleanup
    action: stop
  before_script:
    - gcloud auth activate-service-account --key-file=$REVIEW_APPS_GCP_CREDENTIALS
    - gcloud config set project $REVIEW_APPS_GCP_PROJECT
    - apt-get install -y jq
    - source scripts/review_apps/gcp_cleanup.sh
  script:
    - gcp_cleanup

64
review-build-cng:
65
  extends:
66
    - .default-retry
67
    - .review:rules:mr-and-schedule-auto-if-frontend-manual-otherwise
Stan Hu's avatar
Stan Hu committed
68
  image: ruby:2.6-alpine
69
  stage: review-prepare
70
71
72
73
  before_script:
    - source scripts/utils.sh
    - install_api_client_dependencies_with_apk
    - install_gitlab_gem
74
75
76
  needs:
    - job: gitlab:assets:compile pull-cache
      artifacts: false
Kamil Trzciński's avatar
Kamil Trzciński committed
77
78
  script:
    - BUILD_TRIGGER_TOKEN=$REVIEW_APPS_BUILD_TRIGGER_TOKEN ./scripts/trigger-build cng
79
80
81
    # When the job is manual, review-deploy is also manual and we don't want people
    # to have to manually start the jobs in sequence, so we do it for them.
    - '[ -z $CI_JOB_MANUAL ] || play_job "review-deploy"'
Kamil Trzciński's avatar
Kamil Trzciński committed
82

83
.review-workflow-base:
84
85
  extends:
    - .default-retry
86
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-helm3-kubectl1.14
Kamil Trzciński's avatar
Kamil Trzciński committed
87
88
89
  variables:
    HOST_SUFFIX: "${CI_ENVIRONMENT_SLUG}"
    DOMAIN: "-${CI_ENVIRONMENT_SLUG}.${REVIEW_APPS_DOMAIN}"
90
    GITLAB_HELM_CHART_REF: "v3.2.2"
91
    GITLAB_EDITION: "ce"
Stan Hu's avatar
Stan Hu committed
92
  environment:
93
94
    name: review/${CI_COMMIT_REF_NAME}
    url: https://gitlab-${CI_ENVIRONMENT_SLUG}.${REVIEW_APPS_DOMAIN}
Kamil Trzciński's avatar
Kamil Trzciński committed
95
    on_stop: review-stop
96
    auto_stop_in: 48 hours
97

98
99
100
review-deploy:
  extends:
    - .review-workflow-base
101
    - .review:rules:mr-and-schedule-auto-if-frontend-manual-otherwise
102
  stage: review
103
  dependencies: []
104
  resource_group: "review/${CI_COMMIT_REF_NAME}"
105
  allow_failure: true
Kamil Trzciński's avatar
Kamil Trzciński committed
106
  before_script:
107
    - '[[ ! -d "ee/" ]] || export GITLAB_EDITION="ee"'
Kamil Trzciński's avatar
Kamil Trzciński committed
108
109
110
    - export GITLAB_SHELL_VERSION=$(<GITLAB_SHELL_VERSION)
    - export GITALY_VERSION=$(<GITALY_SERVER_VERSION)
    - export GITLAB_WORKHORSE_VERSION=$(<GITLAB_WORKHORSE_VERSION)
111
    - echo "${CI_ENVIRONMENT_URL}" > environment_url.txt
112
    - source ./scripts/utils.sh
113
114
    - install_api_client_dependencies_with_apk
    - source scripts/review_apps/review-apps.sh
Kamil Trzciński's avatar
Kamil Trzciński committed
115
  script:
116
117
118
119
    - check_kube_domain
    - ensure_namespace
    - install_external_dns
    - download_chart
120
    - date
121
    - deploy || (display_deployment_debug && exit 1)
122
123
124
125
    # When the job is manual, review-qa-smoke is also manual and we don't want people
    # to have to manually start the jobs in sequence, so we do it for them.
    - '[ -z $CI_JOB_MANUAL ] || play_job "review-qa-smoke"'
    - '[ -z $CI_JOB_MANUAL ] || play_job "review-performance"'
126
  artifacts:
127
    paths: [environment_url.txt]
128
129
    expire_in: 2 days
    when: always
Kamil Trzciński's avatar
Kamil Trzciński committed
130

131
.review-stop-base:
132
  extends: .review-workflow-base
133
134
  environment:
    action: stop
135
  dependencies: []
Stan Hu's avatar
Stan Hu committed
136
  variables:
137
138
139
140
    # We're cloning the repo instead of downloading the script for now
    # because some repos are private and CI_JOB_TOKEN cannot access files.
    # See https://gitlab.com/gitlab-org/gitlab/issues/191273
    GIT_DEPTH: 1
Stan Hu's avatar
Stan Hu committed
141
142
  before_script:
    - apk add --update openssl
143
144
    - source ./scripts/utils.sh
    - source ./scripts/review_apps/review-apps.sh
145

146
review-stop-failed-deployment:
147
148
149
  extends:
    - .review-stop-base
    - .review:rules:mr-only-auto
150
151
152
  stage: prepare
  script:
    - delete_failed_release
153
    - delete_helm2_release
154

155
review-stop:
156
157
158
  extends:
    - .review-stop-base
    - .review:rules:mr-only-manual
159
  stage: review
160
161
162
163
  allow_failure: true
  script:
    - delete_release

Stan Hu's avatar
Stan Hu committed
164
.review-qa-base:
165
  extends: .review-docker
166
  stage: qa
167
168
169
  # This is needed so that manual jobs with needs don't block the pipeline.
  # See https://gitlab.com/gitlab-org/gitlab/-/issues/199979.
  dependencies: ["review-deploy"]
170
  allow_failure: true
Kamil Trzciński's avatar
Kamil Trzciński committed
171
172
173
  variables:
    QA_ARTIFACTS_DIR: "${CI_PROJECT_DIR}/qa"
    QA_CAN_TEST_GIT_PROTOCOL_V2: "false"
Stan Hu's avatar
Stan Hu committed
174
    QA_DEBUG: "true"
Kamil Trzciński's avatar
Kamil Trzciński committed
175
176
177
178
179
180
181
    GITLAB_USERNAME: "root"
    GITLAB_PASSWORD: "${REVIEW_APPS_ROOT_PASSWORD}"
    GITLAB_ADMIN_USERNAME: "root"
    GITLAB_ADMIN_PASSWORD: "${REVIEW_APPS_ROOT_PASSWORD}"
    GITHUB_ACCESS_TOKEN: "${REVIEW_APPS_QA_GITHUB_ACCESS_TOKEN}"
    EE_LICENSE: "${REVIEW_APPS_EE_LICENSE}"
  before_script:
182
    - '[[ ! -d "ee/" ]] || export GITLAB_EDITION="ee"'
183
    - export QA_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab-${GITLAB_EDITION}-qa:${CI_COMMIT_REF_SLUG}"
184
    - export CI_ENVIRONMENT_URL="$(cat environment_url.txt)"
Kamil Trzciński's avatar
Kamil Trzciński committed
185
    - echo "${CI_ENVIRONMENT_URL}"
186
187
188
    - echo "${QA_IMAGE}"
    - source scripts/utils.sh
    - install_api_client_dependencies_with_apk
Kamil Trzciński's avatar
Kamil Trzciński committed
189
    - gem install gitlab-qa --no-document ${GITLAB_QA_VERSION:+ --version ${GITLAB_QA_VERSION}}
190
191
192
193
194
  artifacts:
    paths:
      - ./qa/gitlab-qa-run-*
    expire_in: 7 days
    when: always
Kamil Trzciński's avatar
Kamil Trzciński committed
195
196

review-qa-smoke:
197
198
  extends:
    - .review-qa-base
199
    - .review:rules:mr-only-auto-if-frontend-manual-otherwise
Kamil Trzciński's avatar
Kamil Trzciński committed
200
201
202
203
  script:
    - gitlab-qa Test::Instance::Smoke "${QA_IMAGE}" "${CI_ENVIRONMENT_URL}"

review-qa-all:
204
205
206
  extends:
    - .review-qa-base
    - .review:rules:mr-only-manual
207
  parallel: 5
Kamil Trzciński's avatar
Kamil Trzciński committed
208
  script:
209
    - export KNAPSACK_REPORT_PATH=knapsack/master_report.json
210
    - export KNAPSACK_TEST_FILE_PATTERN=qa/specs/features/**/*_spec.rb
211
212
    - gitlab-qa Test::Instance::Any "${QA_IMAGE}" "${CI_ENVIRONMENT_URL}" -- --format RspecJunitFormatter --out tmp/rspec-${CI_JOB_ID}.xml --format html --out tmp/rspec.htm --color --format documentation

213
214
review-performance:
  extends:
215
    - .default-retry
216
    - .review:rules:mr-and-schedule-auto-if-frontend-manual-otherwise
217
218
219
  image:
    name: sitespeedio/sitespeed.io:6.3.1
    entrypoint: [""]
220
  stage: qa
221
222
223
  # This is needed so that manual jobs with needs don't block the pipeline.
  # See https://gitlab.com/gitlab-org/gitlab/-/issues/199979.
  dependencies: ["review-deploy"]
224
  allow_failure: true
225
  before_script:
226
    - export CI_ENVIRONMENT_URL="$(cat environment_url.txt)"
227
228
229
230
231
    - echo "${CI_ENVIRONMENT_URL}"
    - mkdir -p gitlab-exporter
    - wget -O ./gitlab-exporter/index.js https://gitlab.com/gitlab-org/gl-performance/raw/master/index.js
    - mkdir -p sitespeed-results
  script:
232
    - /start.sh --plugins.add ./gitlab-exporter --outputFolder sitespeed-results "${CI_ENVIRONMENT_URL}"
233
234
  after_script:
    - mv sitespeed-results/data/performance.json performance.json
235
236
  artifacts:
    paths:
237
      - sitespeed-results/
238
    reports:
239
      performance: performance.json
Kamil Trzciński's avatar
Kamil Trzciński committed
240

241
parallel-spec-reports:
Stan Hu's avatar
Stan Hu committed
242
  extends:
243
    - .review:rules:mr-only-manual
244
  image: ruby:2.6-alpine
245
  stage: post-qa
246
  dependencies: ["review-qa-all"]
247
  allow_failure: true
248
249
250
  variables:
    NEW_PARALLEL_SPECS_REPORT: qa/report-new.html
    BASE_ARTIFACT_URL: "${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/file/qa/"
Kamil Trzciński's avatar
Kamil Trzciński committed
251
  script:
252
253
254
255
256
257
258
    - apk add --update build-base libxml2-dev libxslt-dev && rm -rf /var/cache/apk/*
    - gem install nokogiri --no-document
    - cd qa/gitlab-qa-run-*/gitlab-*
    - ARTIFACT_DIRS=$(pwd |rev| awk -F / '{print $1,$2}' | rev | sed s_\ _/_)
    - cd -
    - '[[ -f $NEW_PARALLEL_SPECS_REPORT ]] || echo "{}" > ${NEW_PARALLEL_SPECS_REPORT}'
    - scripts/merge-html-reports ${NEW_PARALLEL_SPECS_REPORT} ${BASE_ARTIFACT_URL}${ARTIFACT_DIRS} qa/gitlab-qa-run-*/**/rspec.htm
259
260
261
262
263
264
265
  artifacts:
    when: always
    paths:
      - qa/report-new.html
      - qa/gitlab-qa-run-*
    reports:
      junit: qa/gitlab-qa-run-*/**/rspec-*.xml
Kamil Trzciński's avatar
Kamil Trzciński committed
266
267

danger-review:
Stan Hu's avatar
Stan Hu committed
268
269
270
  extends:
    - .default-retry
    - .default-cache
271
    - .review:rules:danger
Kamil Trzciński's avatar
Kamil Trzciński committed
272
273
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:danger
  stage: test
274
  needs: []
Kamil Trzciński's avatar
Kamil Trzciński committed
275
276
277
  script:
    - git version
    - node --version
Lukas Eipert's avatar
Lukas Eipert committed
278
    - yarn install --frozen-lockfile --cache-folder .yarn-cache --prefer-offline
279
    - danger --fail-on-errors=true --verbose