forked from mendersoftware/gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
300 lines (279 loc) · 7.42 KB
/
.gitlab-ci.yml
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
image: node:19-alpine
stages:
- pre-test
- test
- build
- e2e-test
- publish
variables:
DOCKER_REPOSITORY: mendersoftware/gui
DOCS_VERSION: development
include:
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-commits.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-docker-build.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-github-status-updates.yml'
- project: 'Northern.tech/Mender/mender-qa'
file: 'gitlab-pipeline/internal-variables.yml'
test:lint:
stage: test
except:
- master
- /^(staging|saas-[a-zA-Z0-9.]+)$/
needs: []
cache:
key:
files:
- package-lock.json
paths:
- .npm/
script:
- npm ci --cache .npm --prefer-offline
- cd tests/e2e_tests && npm ci && cd ../..
- npm run lint
tags:
- mender-qa-worker-generic-light
.template:test:acceptance:
stage: e2e-test
image: tiangolo/docker-with-compose
needs:
- job: build:docker
artifacts: true
services:
- docker:dind
before_script:
- export DOCKER_TAG=${CI_COMMIT_REF_SLUG:-master}
- export SERVICE_IMAGE=${DOCKER_REPOSITORY}:${DOCKER_TAG}
- apk add --no-cache bash git jq wget
- git clone --no-tags --depth=1 --single-branch https://github.com/mendersoftware/integration.git
- docker load -i image.tar
artifacts:
expire_in: 2w
paths:
- coverage
- screenshots
- logs
- junit
reports:
junit:
- junit/results.xml
when: always
test:acceptance:
extends: .template:test:acceptance
except:
- /^(staging|saas-[a-zA-Z0-9.]+)$/
script:
- docker tag $SERVICE_IMAGE $DOCKER_REPOSITORY:pr
- GUI_REPOSITORY=$(pwd) INTEGRATION_PATH=$(pwd)/integration ./tests/e2e_tests/run
- docker rmi $DOCKER_REPOSITORY:pr
test:acceptance:enterprise:
extends: .template:test:acceptance
only:
- master
variables:
TEST_ENVIRONMENT: enterprise
script:
- if [ -n "$REGISTRY_MENDER_IO_USERNAME" ]; then
- docker login -u $REGISTRY_MENDER_IO_USERNAME -p $REGISTRY_MENDER_IO_PASSWORD registry.mender.io
- fi
- docker tag $SERVICE_IMAGE $DOCKER_REPOSITORY:pr
- GUI_REPOSITORY=$(pwd) INTEGRATION_PATH=$(pwd)/integration ./tests/e2e_tests/run --enterprise
- docker rmi $DOCKER_REPOSITORY:pr
test:unit:
stage: test
except:
- /^(staging|saas-[a-zA-Z0-9.]+)$/
needs: []
cache:
key:
files:
- package-lock.json
paths:
- .npm/
script:
- npm i -g npm
- npm ci --cache .npm --prefer-offline
- npm run test -- --ci --maxWorkers=2 --reporters=default --reporters=jest-junit
after_script:
- mkdir logs && cp .npm/_logs/* logs/
artifacts:
expire_in: 2w
paths:
- coverage
- logs
reports:
junit: junit.xml
when: always
tags:
- mender-qa-worker-gui-tests
test:docs-links:
stage: test
needs: []
except:
- /^(staging|saas-[a-zA-Z0-9.]+)$/
before_script:
- apk add --no-cache curl
script:
- links=$(grep -r docs.mender.io src/ | grep -v snapshots | sed -e 's,\${docsVersion},'${DOCS_VERSION}'/,g' | sed -e 's,\${path},''/,g' | egrep -o 'https?://[^ `"]+' | sort | uniq)
- error=0
- for url in $links; do
- if ! curl --output /dev/null --silent --head --fail $url; then
- error=1
- echo "[ko] $url"
- else
- echo "[ok] $url"
- fi
- done
- if [ $error -gt 0 ]; then
- exit 1
- fi
tags:
- mender-qa-worker-generic-light
test:docs-links:hosted:
extends: test:docs-links
only:
- /^(staging|saas-[a-zA-Z0-9.]+)$/
except: []
variables:
DOCS_VERSION: hosted
test:prep:
stage: pre-test
image: docker
only:
- staging
services:
- docker:dind
script:
- docker run --rm --entrypoint "/bin/sh" -v $(pwd):/extract mendersoftware/mender-stress-test-client:master -c "cp mender-stress-test-client /extract/"
artifacts:
paths:
- mender-stress-test-client
expire_in: 30 days
tags:
- mender-qa-worker-generic-light
build:docker:
after_script:
- docker build --tag ${DOCKER_REPOSITORY}:base --target base --build-arg GIT_COMMIT_TAG="${DOCKER_PUBLISH_COMMIT_TAG}" .
- docker save ${DOCKER_REPOSITORY}:base > baseImage.tar
artifacts:
paths:
- baseImage.tar
- image.tar
.template:test:staging-deployment:
image: mendersoftware/mender-test-containers:gui-e2e-testing
stage: .post
services:
- docker:dind
cache:
key:
files:
- tests/e2e_tests/package-lock.json
paths:
- .npm/
dependencies:
- test:prep
variables:
CI: 1
DEVICE_TYPE: qemux86-64
TEST_ENVIRONMENT: staging
before_script:
- curl -fsSL https://get.docker.com | sh
- mv mender-stress-test-client tests/e2e_tests/ && cd tests/e2e_tests
- mv /e2e/mender-demo-artifact.mender .
- docker pull mendersoftware/mender-client-docker-addons:master
- npm ci --cache .npm --prefer-offline
script:
- npm run test-ci
after_script:
- cd $CI_PROJECT_DIR
- mkdir logs && cp /root/.npm/_logs/* logs/
only:
- staging
when: delayed
start_in: 15 minutes
artifacts:
expire_in: 2w
paths:
- tests/e2e_tests/test-results
- logs
when: always
tags:
- mender-qa-worker-generic-light
test:staging-deployment:chrome:
extends: .template:test:staging-deployment
script:
- npm run test-ci
test:staging-deployment:firefox:
extends: .template:test:staging-deployment
script:
- npm run test-ci -- --browser=firefox
test:staging-deployment:webkit:
extends: .template:test:staging-deployment
script:
- npm run test-ci -- --browser=webkit
.template:publish:tests:
stage: publish
before_script:
- export CI_BUILD_REF=${CI_COMMIT_SHA}
- export CI_BUILD_REF_NAME=${CI_COMMIT_REF_NAME}
- export CI_MERGE_REQUEST_IID=${CI_COMMIT_BRANCH#pr_}
- export COVERALLS_PARALLEL=true
- export COVERALLS_SERVICE_JOB_ID=${CI_JOB_ID}
- export COVERALLS_SERVICE_NUMBER=${CI_PIPELINE_ID}
- apk add --no-cache git
- npm i -g coveralls
tags:
- mender-qa-worker-generic-light
publish:tests:
extends: .template:publish:tests
except:
- /^(staging|saas-[a-zA-Z0-9.]+)$/
needs:
- test:unit
script:
- export COVERALLS_SERVICE_JOB_NUMBER=unittests
- export COVERALLS_FLAG_NAME=unittests
- coveralls < coverage/lcov.info
publish:e2e-tests:
extends: .template:publish:tests
only:
- master
needs:
- test:acceptance:enterprise
script:
- export COVERALLS_SERVICE_JOB_NUMBER=e2etests
- export COVERALLS_FLAG_NAME=e2etests
- sed -i -re 's/(^[SF:]+[../]+)(.*)$/SF:\2/' coverage/lcov.info
- coveralls < coverage/lcov.info
publish:disclaimer:
stage: publish
image: docker:git
needs:
- job: build:docker
artifacts: true
services:
- docker:dind
variables:
DOCKER_BUILDKIT: 1
script:
- docker load -i baseImage.tar
- docker build -t disclaimer --target disclaim .
- docker run --rm --entrypoint "/bin/sh" -v $(pwd):/extract disclaimer -c "cp disclaimer.txt /extract/"
- docker image rm disclaimer
artifacts:
expire_in: 2w
paths:
- disclaimer.txt
only:
- /^(master|staging|[0-9]+\.[0-9]+\.x)$/
tags:
- mender-qa-worker-generic-light
coveralls:done:
image: curlimages/curl
stage: .post
script:
- curl "https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN" -d "payload[build_num]=$CI_PIPELINE_ID&payload[status]=done"
tags:
- mender-qa-worker-generic-light