Read about our upcoming Code of Conduct on this issue

review.gitlab-ci.yml 7.79 KB
Newer Older
1
review-cleanup:
2
3
  extends:
    - .default-retry
4
    - .review:rules:review-cleanup
5
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-helm3-kubectl1.14
6
7
8
9
10
11
  stage: prepare
  environment:
    name: review/auto-cleanup
    action: stop
  before_script:
    - source scripts/utils.sh
12
    - source scripts/review_apps/gcp_cleanup.sh
13
    - install_gitlab_gem
14
    - setup_gcp_dependencies
15
16
  script:
    - ruby -rrubygems scripts/review_apps/automated_cleanup.rb
17
18
    - gcp_cleanup

19
20
21
22
23
.base-before_script: &base-before_script
  - source ./scripts/utils.sh
  - source ./scripts/review_apps/review-apps.sh
  - install_api_client_dependencies_with_apk

24
25
26
27
28
29
30
review-build-cng:
  extends:
    - .default-retry
    - .review:rules:review-build-cng
  image: ruby:2.6-alpine
  stage: review-prepare
  before_script:
31
    - source ./scripts/utils.sh
32
33
34
35
36
37
38
39
40
41
    - install_api_client_dependencies_with_apk
    - install_gitlab_gem
  needs:
    - job: compile-production-assets
      artifacts: false
  script:
    - BUILD_TRIGGER_TOKEN=$REVIEW_APPS_BUILD_TRIGGER_TOKEN ./scripts/trigger-build cng
    # 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
42

43
.review-workflow-base:
44
45
  extends:
    - .default-retry
46
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-helm3-kubectl1.14
Kamil Trzciński's avatar
Kamil Trzciński committed
47
48
  variables:
    HOST_SUFFIX: "${CI_ENVIRONMENT_SLUG}"
49
    REVIEW_APPS_DOMAIN: "temp.gitlab-review.app"  # FIXME: using temporary domain
Kamil Trzciński's avatar
Kamil Trzciński committed
50
    DOMAIN: "-${CI_ENVIRONMENT_SLUG}.${REVIEW_APPS_DOMAIN}"
51
    GITLAB_HELM_CHART_REF: "v4.3.0"
Stan Hu's avatar
Stan Hu committed
52
  environment:
53
    name: review/${CI_COMMIT_REF_SLUG}${FREQUENCY}
54
    url: https://gitlab-${CI_ENVIRONMENT_SLUG}.${REVIEW_APPS_DOMAIN}
Kamil Trzciński's avatar
Kamil Trzciński committed
55
    on_stop: review-stop
56
    auto_stop_in: 48 hours
57

58
59
60
review-deploy:
  extends:
    - .review-workflow-base
61
    - .review:rules:review-deploy
62
63
64
65
66
67
68
69
  stage: review
  dependencies: []
  resource_group: "review/${CI_COMMIT_REF_NAME}"
  before_script:
    - export GITLAB_SHELL_VERSION=$(<GITLAB_SHELL_VERSION)
    - export GITALY_VERSION=$(<GITALY_SERVER_VERSION)
    - export GITLAB_WORKHORSE_VERSION=$(<GITLAB_WORKHORSE_VERSION)
    - echo "${CI_ENVIRONMENT_URL}" > environment_url.txt
70
    - *base-before_script
71
72
73
74
75
76
77
  script:
    - check_kube_domain
    - ensure_namespace
    - install_external_dns
    - download_chart
    - date
    - deploy || (display_deployment_debug && exit 1)
78
    - disable_sign_ups || (delete_release && exit 1)
79
80
81
82
    # 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"'
83
84
85
86
  after_script:
    # Run seed-dast-test-data.sh only when DAST_RUN is set to true. This is to pupulate review app with data for DAST scan.
    # Set DAST_RUN to true when jobs are manually scheduled.
    - if [ "$DAST_RUN" == "true" ]; then source scripts/review_apps/seed-dast-test-data.sh; TRACE=1 trigger_proj_user_creation; fi
87
88
  artifacts:
    paths: [environment_url.txt]
89
    expire_in: 7 days
90
    when: always
Kamil Trzciński's avatar
Kamil Trzciński committed
91

92
.review-stop-base:
93
  extends: .review-workflow-base
94
95
  environment:
    action: stop
96
  dependencies: []
Stan Hu's avatar
Stan Hu committed
97
  variables:
98
99
100
101
    # 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
102
  before_script:
103
    - *base-before_script
104

105
review-stop-failed-deployment:
106
107
  extends:
    - .review-stop-base
108
    - .review:rules:review-stop-failed-deployment
109
110
111
112
  stage: prepare
  script:
    - delete_failed_release

113
review-stop:
114
115
  extends:
    - .review-stop-base
116
117
    - .review:rules:review-stop
  stage: post-qa
118
119
120
  script:
    - delete_release

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
.review-qa-base:
  extends:
    - .default-retry
    - .use-docker-in-docker
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-qa-alpine-ruby-2.6
  stage: qa
  # 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"]
  variables:
    QA_ARTIFACTS_DIR: "${CI_PROJECT_DIR}/qa"
    QA_CAN_TEST_GIT_PROTOCOL_V2: "false"
    QA_DEBUG: "true"
    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}"
    SIGNUP_DISABLED: "true"
  before_script:
    - export QA_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab-ee-qa:${CI_COMMIT_REF_SLUG}"
    - export CI_ENVIRONMENT_URL="$(cat environment_url.txt)"
    - echo "${CI_ENVIRONMENT_URL}"
    - echo "${QA_IMAGE}"
146
    - *base-before_script
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
    - gem install gitlab-qa --no-document ${GITLAB_QA_VERSION:+ --version ${GITLAB_QA_VERSION}}
  artifacts:
    paths:
      - ./qa/gitlab-qa-run-*
    expire_in: 7 days
    when: always

review-qa-smoke:
  extends:
    - .review-qa-base
    - .review:rules:review-qa-smoke
  script:
    - gitlab-qa Test::Instance::Smoke "${QA_IMAGE}" "${CI_ENVIRONMENT_URL}"

review-qa-all:
  extends:
    - .review-qa-base
    - .review:rules:mr-only-manual
  parallel: 5
  script:
    - export KNAPSACK_REPORT_PATH=knapsack/master_report.json
    - export KNAPSACK_TEST_FILE_PATTERN=qa/specs/features/**/*_spec.rb
    - 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

review-performance:
  extends:
    - .default-retry
174
    - .review:rules:review-performance
175
  image:
176
    name: sitespeedio/sitespeed.io
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
    entrypoint: [""]
  stage: qa
  # 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"]
  before_script:
    - export CI_ENVIRONMENT_URL="$(cat environment_url.txt)"
    - 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:
    - /start.sh --plugins.add ./gitlab-exporter --outputFolder sitespeed-results "${CI_ENVIRONMENT_URL}"
  after_script:
    - mv sitespeed-results/data/performance.json performance.json
  artifacts:
    paths:
      - sitespeed-results/
    reports:
      performance: performance.json
    expire_in: 31d

parallel-spec-reports:
  extends:
    - .review:rules:mr-only-manual
  image: ruby:2.6-alpine
  stage: post-qa
  dependencies: ["review-qa-all"]
  variables:
    NEW_PARALLEL_SPECS_REPORT: qa/report-new.html
    BASE_ARTIFACT_URL: "${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/file/qa/"
  script:
    - 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
  artifacts:
    when: always
    paths:
      - qa/report-new.html
      - qa/gitlab-qa-run-*
    reports:
      junit: qa/gitlab-qa-run-*/**/rspec-*.xml
    expire_in: 31d
Kamil Trzciński's avatar
Kamil Trzciński committed
224
225

danger-review:
Stan Hu's avatar
Stan Hu committed
226
227
  extends:
    - .default-retry
228
    - .yarn-cache
229
    - .review:rules:danger
Kamil Trzciński's avatar
Kamil Trzciński committed
230
231
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:danger
  stage: test
232
  needs: []
Kamil Trzciński's avatar
Kamil Trzciński committed
233
  script:
234
235
    - source ./scripts/utils.sh
    - run_timed_command "retry yarn install --frozen-lockfile"
236
    - danger --fail-on-errors=true --verbose