review.gitlab-ci.yml 7.5 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 25
.review-docker:
  extends: .review-base
K
Kamil Trzciński 已提交
26 27
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-qa-alpine
  services:
L
Lukas Eipert 已提交
28
    - docker:19.03.0-dind
K
Kamil Trzciński 已提交
29 30 31
  tags:
    - gitlab-org
    - docker
S
Stan Hu 已提交
32
  variables:
K
Kamil Trzciński 已提交
33 34 35 36 37 38
    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:
S
Stan Hu 已提交
39
  extends: .review-docker
40
  stage: test
K
Kamil Trzciński 已提交
41
  script:
42
    - time docker build --cache-from ${LATEST_QA_IMAGE} --tag ${QA_IMAGE} --file ./qa/Dockerfile ./
K
Kamil Trzciński 已提交
43 44 45
    - echo "${CI_JOB_TOKEN}" | docker login --username gitlab-ci-token --password-stdin ${CI_REGISTRY}
    - time docker push ${QA_IMAGE}

S
Stan Hu 已提交
46
.review-build-cng-base:
S
Stan Hu 已提交
47
  image: ruby:2.6-alpine
K
Kamil Trzciński 已提交
48
  stage: test
49 50 51 52 53
  when: manual
  before_script:
    - source scripts/utils.sh
    - install_api_client_dependencies_with_apk
    - install_gitlab_gem
K
Kamil Trzciński 已提交
54 55 56 57 58
  dependencies: []
  script:
    - BUILD_TRIGGER_TOKEN=$REVIEW_APPS_BUILD_TRIGGER_TOKEN ./scripts/trigger-build cng

review-build-cng:
S
Stan Hu 已提交
59 60 61
  extends:
    - .review-build-cng-base
    - .review-only
K
Kamil Trzciński 已提交
62 63

schedule:review-build-cng:
S
Stan Hu 已提交
64 65 66
  extends:
    - .review-build-cng-base
    - .review-schedules-only
K
Kamil Trzciński 已提交
67

S
Stan Hu 已提交
68 69
review-deploy:
  extends: .review-base
70
  allow_failure: true
R
Rémy Coutable 已提交
71
  retry: 1
72
  stage: review
K
Kamil Trzciński 已提交
73 74 75 76
  variables:
    HOST_SUFFIX: "${CI_ENVIRONMENT_SLUG}"
    DOMAIN: "-${CI_ENVIRONMENT_SLUG}.${REVIEW_APPS_DOMAIN}"
    GITLAB_HELM_CHART_REF: "master"
S
Stan Hu 已提交
77
  environment:
78 79
    name: review/${CI_COMMIT_REF_NAME}
    url: https://gitlab-${CI_ENVIRONMENT_SLUG}.${REVIEW_APPS_DOMAIN}
K
Kamil Trzciński 已提交
80 81 82 83 84
    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)
85 86 87 88
    - 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 已提交
89
  script:
90 91 92 93 94
    - check_kube_domain
    - ensure_namespace
    - install_tiller
    - install_external_dns
    - download_chart
95
    - deploy || (display_deployment_debug && exit 1)
96
    - add_license
97
  artifacts:
98
    paths: [review_app_url.txt]
99 100
    expire_in: 2 days
    when: always
K
Kamil Trzciński 已提交
101 102

schedule:review-deploy:
S
Stan Hu 已提交
103 104 105
  extends:
    - review-deploy
    - .review-schedules-only
K
Kamil Trzciński 已提交
106

107
review-stop:
S
Stan Hu 已提交
108
  extends: review-deploy
109 110 111
  when: manual
  environment:
    action: stop
S
Stan Hu 已提交
112 113 114 115 116 117 118
  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
119 120
    - wget $CI_PROJECT_URL/raw/$CI_COMMIT_SHA/scripts/utils.sh
    - source utils.sh
S
Stan Hu 已提交
121 122
    - source review-apps.sh
  script:
123
    - delete
S
Stan Hu 已提交
124
  artifacts: {}
125

S
Stan Hu 已提交
126 127
.review-qa-base:
  extends: .review-docker
128
  retry: 2
129
  stage: qa
K
Kamil Trzciński 已提交
130 131 132
  variables:
    QA_ARTIFACTS_DIR: "${CI_PROJECT_DIR}/qa"
    QA_CAN_TEST_GIT_PROTOCOL_V2: "false"
S
Stan Hu 已提交
133
    QA_DEBUG: "true"
K
Kamil Trzciński 已提交
134 135 136 137 138 139
    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 已提交
140
  dependencies: ["review-deploy"]
K
Kamil Trzciński 已提交
141 142 143 144 145 146
  artifacts:
    paths:
      - ./qa/gitlab-qa-run-*
    expire_in: 7 days
    when: always
  before_script:
147
    - export CI_ENVIRONMENT_URL="$(cat review_app_url.txt)"
K
Kamil Trzciński 已提交
148
    - echo "${CI_ENVIRONMENT_URL}"
149 150 151
    - echo "${QA_IMAGE}"
    - source scripts/utils.sh
    - install_api_client_dependencies_with_apk
K
Kamil Trzciński 已提交
152 153 154
    - gem install gitlab-qa --no-document ${GITLAB_QA_VERSION:+ --version ${GITLAB_QA_VERSION}}

review-qa-smoke:
S
Stan Hu 已提交
155 156
  extends: .review-qa-base
  allow_failure: true
K
Kamil Trzciński 已提交
157 158 159 160
  script:
    - gitlab-qa Test::Instance::Smoke "${QA_IMAGE}" "${CI_ENVIRONMENT_URL}"

review-qa-all:
S
Stan Hu 已提交
161
  extends: .review-qa-base
162
  allow_failure: true
163
  when: manual
164
  parallel: 5
K
Kamil Trzciński 已提交
165
  script:
166 167
    - export KNAPSACK_REPORT_PATH=knapsack/${CI_PROJECT_NAME}/review-qa-all_master_report.json
    - export KNAPSACK_TEST_FILE_PATTERN=qa/specs/features/**/*_spec.rb
168 169 170
    - 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:
171
  extends:
S
Stan Hu 已提交
172 173
    - .default-tags
    - .except-docs
174
  image: ruby:2.6-alpine
S
Stan Hu 已提交
175 176
  stage: post-test
  dependencies: ["review-qa-all"]
177 178 179 180 181 182 183 184 185 186 187 188 189 190
  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 已提交
191
    - gem install nokogiri --no-document
192 193
    - cd qa/gitlab-qa-run-*/gitlab-*
    - ARTIFACT_DIRS=$(pwd |rev| awk -F / '{print $1,$2}' | rev | sed s_\ _/_)
S
Stan Hu 已提交
194
    - cd -
195 196
    - '[[ -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 已提交
197

S
Stan Hu 已提交
198 199
review-performance:
  extends: .review-qa-base
200
  allow_failure: true
201 202 203
  before_script:
    - export CI_ENVIRONMENT_URL="$(cat review_app_url.txt)"
    - echo "${CI_ENVIRONMENT_URL}"
K
Kamil Trzciński 已提交
204 205
    - mkdir -p gitlab-exporter
    - wget -O ./gitlab-exporter/index.js https://gitlab.com/gitlab-org/gl-performance/raw/master/index.js
206 207 208 209
    - 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 已提交
210 211 212 213 214 215 216
    - mv sitespeed-results/data/performance.json performance.json
  artifacts:
    paths:
      - sitespeed-results/
    reports:
      performance: performance.json

217
schedule:review-performance:
S
Stan Hu 已提交
218 219 220 221
  extends:
    - review-performance
    - .review-schedules-only
  dependencies: ["schedule:review-deploy"]
K
Kamil Trzciński 已提交
222 223

schedule:review-cleanup:
S
Stan Hu 已提交
224 225 226
  extends:
    - .review-base
    - .review-schedules-only
227
  stage: build
K
Kamil Trzciński 已提交
228 229 230
  allow_failure: true
  environment:
    name: review/auto-cleanup
231
    action: stop
K
Kamil Trzciński 已提交
232
  before_script:
233 234
    - source scripts/utils.sh
    - install_gitlab_gem
K
Kamil Trzciński 已提交
235 236 237 238
  script:
    - ruby -rrubygems scripts/review_apps/automated_cleanup.rb

danger-review:
S
Stan Hu 已提交
239 240 241 242
  extends:
    - .default-tags
    - .default-retry
    - .default-cache
K
Kamil Trzciński 已提交
243 244 245 246 247 248 249 250 251
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:danger
  stage: test
  dependencies: []
  only:
    variables:
      - $DANGER_GITLAB_API_TOKEN
  except:
    refs:
      - master
252
      - /^\d+-\d+-auto-deploy-\d+$/
253
      - /^[\d-]+-stable(-ee)?$/
S
Stan Hu 已提交
254 255
      - /^ce-to-ee-.*/
      - /.*-stable(-ee)?-prepare-.*/
K
Kamil Trzciński 已提交
256 257 258
  script:
    - git version
    - node --version
L
Lukas Eipert 已提交
259
    - yarn install --frozen-lockfile --cache-folder .yarn-cache --prefer-offline
K
Kamil Trzciński 已提交
260
    - danger --fail-on-errors=true