summaryrefslogtreecommitdiff
path: root/.gitlab/ci/review-apps/qa.gitlab-ci.yml
blob: 69ce028987aabc89c1e2ddc0f9f0301048ac47ac (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
171
172
173
174
175
176
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
include:
  - project: gitlab-org/quality/pipeline-common
    ref: 1.7.0
    file:
      - /ci/base.gitlab-ci.yml
      - /ci/allure-report.yml
      - /ci/knapsack-report.yml

.test-variables:
  variables:
    QA_GENERATE_ALLURE_REPORT: "true"
    QA_CAN_TEST_PRAEFECT: "false"
    GITLAB_USERNAME: "root"
    GITLAB_PASSWORD: "${REVIEW_APPS_ROOT_PASSWORD}"
    GITLAB_ADMIN_USERNAME: "root"
    GITLAB_ADMIN_PASSWORD: "${REVIEW_APPS_ROOT_PASSWORD}"
    GITLAB_QA_ADMIN_ACCESS_TOKEN: "${REVIEW_APPS_ROOT_TOKEN}"
    GITHUB_ACCESS_TOKEN: "${QA_GITHUB_ACCESS_TOKEN}"

.bundle-base:
  extends:
    - .qa-cache
  image: ${REGISTRY_HOST}/${REGISTRY_GROUP}/gitlab-build-images/debian-bullseye-ruby-${RUBY_VERSION}:bundler-2.3
  before_script:
    - cd qa && bundle install

.review-qa-base:
  image: ${REGISTRY_HOST}/${REGISTRY_GROUP}/gitlab-build-images/debian-bullseye-ruby-${RUBY_VERSION}:bundler-2.3-git-2.36-lfs-2.9-chrome-${CHROME_VERSION}-docker-${DOCKER_VERSION}-gcloud-383-kubectl-1.23
  extends:
    - .use-docker-in-docker
    - .bundle-base
    - .test-variables
  stage: qa
  needs:
    - review-deploy
    - download-knapsack-report
  variables:
    GIT_LFS_SKIP_SMUDGE: 1
    WD_INSTALL_DIR: /usr/local/bin
    RSPEC_REPORT_OPTS: --force-color --order random --format documentation --format RspecJunitFormatter --out tmp/rspec-${CI_JOB_ID}.xml
  script:
    - export EE_LICENSE="$(cat $REVIEW_APPS_EE_LICENSE_FILE)"
    - QA_COMMAND="bundle exec bin/qa ${QA_SCENARIO} ${QA_GITLAB_URL} -- ${QA_TESTS} ${RSPEC_REPORT_OPTS}"
    - echo "Running - '${QA_COMMAND}'"
    - eval "$QA_COMMAND"
  after_script:
    - |
      echo "Sentry errors for the current review-app test run can be found via following url:"
      echo "https://sentry.gitlab.net/gitlab/gitlab-review-apps/releases/$(echo "${CI_COMMIT_SHA}" | cut -c1-11)/all-events/."
  artifacts:
    paths:
      - qa/tmp
    reports:
      junit: qa/tmp/rspec-*.xml
    expire_in: 7 days
    when: always

# Store knapsack report as artifact so the same report is reused across all jobs
download-knapsack-report:
  extends:
    - .bundle-base
    - .rules:prepare-report
  stage: prepare
  script:
    - bundle exec rake "knapsack:download[qa]"
  allow_failure: true
  artifacts:
    paths:
      - qa/knapsack/review-qa-*.json
    expire_in: 1 day

review-qa-smoke:
  extends:
    - .review-qa-base
    - .rules:qa-smoke
  variables:
    QA_SCENARIO: Test::Instance::Smoke
    QA_RUN_TYPE: review-qa-smoke
  retry: 1

review-qa-blocking:
  extends:
    - .review-qa-base
    - .rules:qa-blocking
  variables:
    QA_SCENARIO: Test::Instance::ReviewBlocking
    QA_RUN_TYPE: review-qa-blocking
  retry: 1
review-qa-blocking-parallel:
  extends:
    - review-qa-blocking
    - .rules:qa-blocking-parallel
  parallel: 10

review-qa-non-blocking:
  extends:
    - .review-qa-base
    - .rules:qa-non-blocking
  variables:
    QA_SCENARIO: Test::Instance::ReviewNonBlocking
    QA_RUN_TYPE: review-qa-non-blocking
  allow_failure: true
review-qa-non-blocking-parallel:
  extends:
    - review-qa-non-blocking
    - .rules:qa-non-blocking-parallel
  parallel: 5

review-performance:
  extends:
    - .default-retry
    - .review:rules:review-performance
  image:
    name: sitespeedio/sitespeed.io
    entrypoint: [""]
  stage: qa
  needs: ["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

e2e-test-report:
  extends:
    - .generate-allure-report-base
    - .rules:prepare-report
  stage: post-qa
  variables:
    ALLURE_JOB_NAME: e2e-review-qa
    ALLURE_PROJECT_PATH: $CI_PROJECT_PATH
    ALLURE_RESULTS_GLOB: qa/tmp/allure-results
    ALLURE_MERGE_REQUEST_IID: $CI_MERGE_REQUEST_IID
    GITLAB_AUTH_TOKEN: $GITLAB_QA_MR_ALLURE_REPORT_TOKEN
    GIT_STRATEGY: none
  allow_failure: true
  when: always
  artifacts:  # re-save rspec results for displaying in parent pipeline
    expire_in: 1 day
    when: always
    paths:
      - qa/tmp/rspec-*.xml

upload-knapsack-report:
  extends:
    - .generate-knapsack-report-base
    - .bundle-base
  stage: post-qa
  variables:
    QA_KNAPSACK_REPORT_FILE_PATTERN: $CI_PROJECT_DIR/qa/tmp/knapsack/*/*.json

delete-test-resources:
  extends:
    - .bundle-base
    - .rules:prepare-report
  stage: post-qa
  variables:
    QA_TEST_RESOURCES_FILE_PATTERN: $CI_PROJECT_DIR/qa/tmp/test-resources-*.json
    GITLAB_QA_ACCESS_TOKEN: $REVIEW_APPS_ROOT_TOKEN
  script:
    - export GITLAB_ADDRESS="$QA_GITLAB_URL"
    - bundle exec rake "test_resources:delete[$QA_TEST_RESOURCES_FILE_PATTERN]"
  allow_failure: true
  when: always

notify-slack:
  extends:
    - .notify-slack-qa
    - .qa-cache
    - .rules:main-run
  stage: post-qa
  variables:
    RUN_WITH_BUNDLE: "true"
    QA_PATH: qa
    ALLURE_JOB_NAME: e2e-review-qa
    SLACK_ICON_EMOJI: ci_failing
    STATUS_SYM: ☠️
    STATUS: failed
    TYPE: "(review-app) "
  when: on_failure
  script:
    - bundle exec gitlab-qa-report --prepare-stage-reports "$CI_PROJECT_DIR/qa/tmp/rspec-*.xml"  # generate summary
    - !reference [.notify-slack-qa, script]

export-test-metrics:
  extends:
    - .bundle-base
    - .rules:main-run
  stage: post-qa
  when: always
  script:
    - bundle exec rake "ci:export_test_metrics[tmp/test-metrics-*.json]"