review.gitlab-ci.yml 7.9 KB
Newer Older
S
Stan Hu 已提交
1
.review-schedules-only:
K
Kamil Trzciński 已提交
2 3 4 5 6 7 8 9 10 11
  only:
    refs:
      - schedules@gitlab-org/gitlab-ce
      - schedules@gitlab-org/gitlab-ee
    kubernetes: active
    variables:
      - $REVIEW_APP_CLEANUP
  except:
    refs:
      - tags
12
      - /(^docs[\/-].+|.+-docs$)/
K
Kamil Trzciński 已提交
13

S
Stan Hu 已提交
14
.review-base:
15
  extends:
S
Stan Hu 已提交
16 17
    - .default-tags
    - .default-retry
18
    - .review-only
K
Kamil Trzciński 已提交
19 20
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-charts-build-base
  dependencies: []
21 22
  before_script:
    - source scripts/utils.sh
K
Kamil Trzciński 已提交
23

S
Stan Hu 已提交
24
.review-docker:
25 26 27
  extends:
    - .default-tags
    - .default-retry
K
Kamil Trzciński 已提交
28 29
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-qa-alpine
  services:
L
Lukas Eipert 已提交
30
    - docker:19.03.0-dind
K
Kamil Trzciński 已提交
31 32 33
  tags:
    - gitlab-org
    - docker
S
Stan Hu 已提交
34
  variables:
K
Kamil Trzciński 已提交
35 36 37 38 39 40
    DOCKER_DRIVER: overlay2
    DOCKER_HOST: tcp://docker:2375
    LATEST_QA_IMAGE: "gitlab/${CI_PROJECT_NAME}-qa:nightly"
    QA_IMAGE: "${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab/${CI_PROJECT_NAME}-qa:${CI_COMMIT_REF_SLUG}"

build-qa-image:
41 42
  extends:
    - .review-docker
43
    - .except-docs
44 45 46 47
  only:
    refs:
      - branches@gitlab-org/gitlab-ce
      - branches@gitlab-org/gitlab-ee
48
  stage: test
K
Kamil Trzciński 已提交
49
  script:
50
    - time docker build --cache-from ${LATEST_QA_IMAGE} --tag ${QA_IMAGE} --file ./qa/Dockerfile ./
K
Kamil Trzciński 已提交
51 52 53
    - echo "${CI_JOB_TOKEN}" | docker login --username gitlab-ci-token --password-stdin ${CI_REGISTRY}
    - time docker push ${QA_IMAGE}

S
Stan Hu 已提交
54
.review-build-cng-base:
S
Stan Hu 已提交
55
  image: ruby:2.6-alpine
56
  stage: review-prepare
57 58 59 60
  before_script:
    - source scripts/utils.sh
    - install_api_client_dependencies_with_apk
    - install_gitlab_gem
K
Kamil Trzciński 已提交
61 62 63 64 65
  dependencies: []
  script:
    - BUILD_TRIGGER_TOKEN=$REVIEW_APPS_BUILD_TRIGGER_TOKEN ./scripts/trigger-build cng

review-build-cng:
S
Stan Hu 已提交
66 67 68
  extends:
    - .review-build-cng-base
    - .review-only
69
  needs: ["gitlab:assets:compile pull-cache"]
K
Kamil Trzciński 已提交
70 71

schedule:review-build-cng:
S
Stan Hu 已提交
72 73 74
  extends:
    - .review-build-cng-base
    - .review-schedules-only
75
  needs: ["gitlab:assets:compile"]
K
Kamil Trzciński 已提交
76

S
Stan Hu 已提交
77 78
review-deploy:
  extends: .review-base
79
  allow_failure: true
80
  stage: review
81
  needs: ["review-build-cng"]
K
Kamil Trzciński 已提交
82 83 84 85
  variables:
    HOST_SUFFIX: "${CI_ENVIRONMENT_SLUG}"
    DOMAIN: "-${CI_ENVIRONMENT_SLUG}.${REVIEW_APPS_DOMAIN}"
    GITLAB_HELM_CHART_REF: "master"
S
Stan Hu 已提交
86
  environment:
87 88
    name: review/${CI_COMMIT_REF_NAME}
    url: https://gitlab-${CI_ENVIRONMENT_SLUG}.${REVIEW_APPS_DOMAIN}
K
Kamil Trzciński 已提交
89 90 91 92 93
    on_stop: review-stop
  before_script:
    - export GITLAB_SHELL_VERSION=$(<GITLAB_SHELL_VERSION)
    - export GITALY_VERSION=$(<GITALY_SERVER_VERSION)
    - export GITLAB_WORKHORSE_VERSION=$(<GITLAB_WORKHORSE_VERSION)
94 95 96 97
    - echo "${CI_ENVIRONMENT_URL}" > review_app_url.txt
    - source scripts/utils.sh
    - install_api_client_dependencies_with_apk
    - source scripts/review_apps/review-apps.sh
K
Kamil Trzciński 已提交
98
  script:
99 100 101 102 103
    - check_kube_domain
    - ensure_namespace
    - install_tiller
    - install_external_dns
    - download_chart
104
    - deploy || (display_deployment_debug && exit 1)
105
    - add_license
106
  artifacts:
107
    paths: [review_app_url.txt]
108 109
    expire_in: 2 days
    when: always
K
Kamil Trzciński 已提交
110 111

schedule:review-deploy:
S
Stan Hu 已提交
112 113 114
  extends:
    - review-deploy
    - .review-schedules-only
K
Kamil Trzciński 已提交
115

116
review-stop:
S
Stan Hu 已提交
117
  extends: review-deploy
118 119 120
  when: manual
  environment:
    action: stop
S
Stan Hu 已提交
121 122 123 124 125 126 127
  variables:
    GIT_STRATEGY: none
  before_script:
    # We don't clone the repo by using GIT_STRATEGY: none and only download the
    # single script we need here so it's much faster than cloning.
    - apk add --update openssl
    - wget $CI_PROJECT_URL/raw/$CI_COMMIT_SHA/scripts/review_apps/review-apps.sh
128 129
    - wget $CI_PROJECT_URL/raw/$CI_COMMIT_SHA/scripts/utils.sh
    - source utils.sh
S
Stan Hu 已提交
130 131
    - source review-apps.sh
  script:
132 133 134
    - delete_release
  artifacts:
    paths: []
135

136 137 138 139 140 141 142 143 144
review-cleanup-failed-deployment:
  extends: review-stop
  stage: prepare
  when: on_success
  needs: []
  allow_failure: false
  script:
    - delete_failed_release

S
Stan Hu 已提交
145
.review-qa-base:
146 147 148
  extends:
    - .review-docker
    - .review-only
149
  stage: qa
K
Kamil Trzciński 已提交
150 151 152
  variables:
    QA_ARTIFACTS_DIR: "${CI_PROJECT_DIR}/qa"
    QA_CAN_TEST_GIT_PROTOCOL_V2: "false"
S
Stan Hu 已提交
153
    QA_DEBUG: "true"
K
Kamil Trzciński 已提交
154 155 156 157 158 159
    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}"
S
Stan Hu 已提交
160
  dependencies: ["review-deploy"]
K
Kamil Trzciński 已提交
161 162 163 164 165 166
  artifacts:
    paths:
      - ./qa/gitlab-qa-run-*
    expire_in: 7 days
    when: always
  before_script:
167
    - export CI_ENVIRONMENT_URL="$(cat review_app_url.txt)"
K
Kamil Trzciński 已提交
168
    - echo "${CI_ENVIRONMENT_URL}"
169 170 171
    - echo "${QA_IMAGE}"
    - source scripts/utils.sh
    - install_api_client_dependencies_with_apk
K
Kamil Trzciński 已提交
172 173 174
    - gem install gitlab-qa --no-document ${GITLAB_QA_VERSION:+ --version ${GITLAB_QA_VERSION}}

review-qa-smoke:
S
Stan Hu 已提交
175 176
  extends: .review-qa-base
  allow_failure: true
K
Kamil Trzciński 已提交
177 178 179 180
  script:
    - gitlab-qa Test::Instance::Smoke "${QA_IMAGE}" "${CI_ENVIRONMENT_URL}"

review-qa-all:
S
Stan Hu 已提交
181
  extends: .review-qa-base
182
  allow_failure: true
183
  when: manual
184
  parallel: 5
K
Kamil Trzciński 已提交
185
  script:
186 187
    - export KNAPSACK_REPORT_PATH=knapsack/${CI_PROJECT_NAME}/review-qa-all_master_report.json
    - export KNAPSACK_TEST_FILE_PATTERN=qa/specs/features/**/*_spec.rb
188 189 190
    - 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

parallel-spec-reports:
191
  extends:
S
Stan Hu 已提交
192 193
    - .default-tags
    - .except-docs
194
  image: ruby:2.6-alpine
S
Stan Hu 已提交
195 196
  stage: post-test
  dependencies: ["review-qa-all"]
197 198 199 200 201 202 203 204 205 206 207 208 209 210
  variables:
    NEW_PARALLEL_SPECS_REPORT: qa/report-new.html
    BASE_ARTIFACT_URL: "${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/file/qa/"
  allow_failure: true
  when: manual
  artifacts:
    when: always
    paths:
      - qa/report-new.html
      - qa/gitlab-qa-run-*
    reports:
      junit: qa/gitlab-qa-run-*/**/rspec-*.xml
  script:
    - apk add --update build-base libxml2-dev libxslt-dev && rm -rf /var/cache/apk/*
S
Stan Hu 已提交
211
    - gem install nokogiri --no-document
212 213
    - cd qa/gitlab-qa-run-*/gitlab-*
    - ARTIFACT_DIRS=$(pwd |rev| awk -F / '{print $1,$2}' | rev | sed s_\ _/_)
S
Stan Hu 已提交
214
    - cd -
215 216
    - '[[ -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
K
Kamil Trzciński 已提交
217

S
Stan Hu 已提交
218 219
review-performance:
  extends: .review-qa-base
220
  allow_failure: true
221 222 223
  before_script:
    - export CI_ENVIRONMENT_URL="$(cat review_app_url.txt)"
    - echo "${CI_ENVIRONMENT_URL}"
K
Kamil Trzciński 已提交
224 225
    - mkdir -p gitlab-exporter
    - wget -O ./gitlab-exporter/index.js https://gitlab.com/gitlab-org/gl-performance/raw/master/index.js
226 227 228 229
    - mkdir -p sitespeed-results
  script:
    - docker run --shm-size=1g --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io:6.3.1 --plugins.add ./gitlab-exporter --outputFolder sitespeed-results "${CI_ENVIRONMENT_URL}"
  after_script:
K
Kamil Trzciński 已提交
230 231 232 233 234 235 236
    - mv sitespeed-results/data/performance.json performance.json
  artifacts:
    paths:
      - sitespeed-results/
    reports:
      performance: performance.json

237
schedule:review-performance:
S
Stan Hu 已提交
238 239 240 241
  extends:
    - review-performance
    - .review-schedules-only
  dependencies: ["schedule:review-deploy"]
K
Kamil Trzciński 已提交
242 243

schedule:review-cleanup:
S
Stan Hu 已提交
244 245 246
  extends:
    - .review-base
    - .review-schedules-only
247
  stage: build
K
Kamil Trzciński 已提交
248 249 250
  allow_failure: true
  environment:
    name: review/auto-cleanup
251
    action: stop
K
Kamil Trzciński 已提交
252
  before_script:
253 254
    - source scripts/utils.sh
    - install_gitlab_gem
K
Kamil Trzciński 已提交
255 256 257 258
  script:
    - ruby -rrubygems scripts/review_apps/automated_cleanup.rb

danger-review:
S
Stan Hu 已提交
259 260 261 262
  extends:
    - .default-tags
    - .default-retry
    - .default-cache
K
Kamil Trzciński 已提交
263 264 265 266 267 268 269 270 271
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:danger
  stage: test
  dependencies: []
  only:
    variables:
      - $DANGER_GITLAB_API_TOKEN
  except:
    refs:
      - master
272
      - /^\d+-\d+-auto-deploy-\d+$/
273
      - /^[\d-]+-stable(-ee)?$/
S
Stan Hu 已提交
274 275
      - /^ce-to-ee-.*/
      - /.*-stable(-ee)?-prepare-.*/
K
Kamil Trzciński 已提交
276 277 278
  script:
    - git version
    - node --version
L
Lukas Eipert 已提交
279
    - yarn install --frozen-lockfile --cache-folder .yarn-cache --prefer-offline
K
Kamil Trzciński 已提交
280
    - danger --fail-on-errors=true