-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
482 lines (431 loc) · 11.4 KB
/
.gitlab-ci.yml
File metadata and controls
482 lines (431 loc) · 11.4 KB
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
stages:
- prepare
- prebuild
- test
- coverage
- build
- package
- release
- cleanup
variables:
CI_IMAGE: registry.gitlab.com/gitlab-org/gitlab-runner/ci:1.8.7-0
GOROOT: /usr/local/go
before_script:
- unset GPG_KEY
image: $CI_IMAGE
# Skip all jobs except the ones that begin and end with 'docs'.
# Used for commits including ONLY documentation changes.
# https://docs.gitlab.com/ce/development/writing_documentation.html#testing
.except_docs: &except_docs
except:
- /(^docs[\/-].*|.*-docs$)/
.docker: &docker
<<: *except_docs
services:
- docker:dind
variables: &docker_variables
CI_IMAGE: registry.gitlab.com/gitlab-org/gitlab-runner/ci:1.8.7-0
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375
tags:
- docker
#
# Prepare stage
#
.image_builder: &image_builder
<<: *docker
stage: prepare
image: docker:git
script:
- source ./ci/build_ci_image
prepare ci image:
<<: *image_builder
variables:
BUILD_IMAGE: $CI_IMAGE
BUILD_DOCKERFILE: ./dockerfiles/ci/Dockerfile
only:
- /\Adocker-ci-image\/.*/
prepare alpine-no-root image:
<<: *image_builder
variables:
BUILD_IMAGE: registry.gitlab.com/gitlab-org/gitlab-runner/alpine-no-root:latest
BUILD_DOCKERFILE: ./tests/dockerfiles/alpine-no-root/Dockerfile
only:
- /\Adocker-alpine-no-root-image\/.*/
#
# Prebuild stage
#
helper images:
<<: *docker
stage: prebuild
script:
- make docker
artifacts:
paths:
- out/helper-images/
- .gopath/bin
- .gopath/.ok
expire_in: 7d
clone test repo:
<<: *except_docs
stage: prebuild
script:
- mkdir tmp
- succeed=0
- for i in {1..3}; do git clone https://gitlab.com/gitlab-org/gitlab-test.git tmp/gitlab-test && succeed=1 && break; echo "retrying"; done
- '[[ "$succeed" -eq 1 ]]'
artifacts:
paths:
- tmp/gitlab-test
expire_in: 7d
# Review docs base
.review-docs: &review-docs
image: ruby:2.4-alpine
before_script:
- unset GPG_KEY
- gem install gitlab --no-doc
# We need to download the script rather than clone the repo since the
# review-docs-cleanup job will not be able to run when the branch gets
# deleted (when merging the MR).
- apk add --update openssl
- wget https://gitlab.com/gitlab-org/gitlab-ce/raw/master/scripts/trigger-build-docs
- chmod 755 trigger-build-docs
cache: {}
dependencies: []
variables:
GIT_STRATEGY: none
when: manual
only:
- branches
# Trigger a docs build in gitlab-docs
# Useful to preview the docs changes live
# https://docs.gitlab.com/ee/development/writing_documentation.html#previewing-the-changes-live
review-docs-deploy:
<<: *review-docs
stage: prebuild
environment:
name: review-docs/$CI_COMMIT_REF_NAME
# DOCS_REVIEW_APPS_DOMAIN and DOCS_GITLAB_REPO_SUFFIX are secret variables
# Discussion: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14236/diffs#note_40140693
url: http://$DOCS_GITLAB_REPO_SUFFIX-$CI_COMMIT_REF_SLUG.$DOCS_REVIEW_APPS_DOMAIN/$DOCS_GITLAB_REPO_SUFFIX
on_stop: review-docs-cleanup
script:
- ./trigger-build-docs deploy
# Cleanup remote environment of gitlab-docs
review-docs-cleanup:
<<: *review-docs
stage: cleanup
environment:
name: review-docs/$CI_COMMIT_REF_NAME
action: stop
script:
- ./trigger-build-docs cleanup
tests definitions:
<<: *except_docs
stage: prebuild
# Using Go 1.10, because the `go test -list` is unavailable in <1.9
# and it's much faster in 1.10. And since there is no real test execution
# in this step, the version difference doesn't matter
image: golang:1.10
script:
- apt update
- apt install make
- source ci/touch_make_dependencies
- make parallel_test_prepare
artifacts:
paths:
- testsdefinitions.txt
expire_in: 7d
tags:
- gitlab-org
#
# Test stage
#
code_quality:
<<: *except_docs
stage: test
image: docker:git
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
CODECLIMATE_FORMAT: json
cache: {}
dependencies: []
script:
- ./scripts/codequality analyze -f json --dev | tee gl-code-quality-report.json
artifacts:
paths: [gl-code-quality-report.json]
expire_in: 7d
.unit_tests: &unit_tests
<<: *docker
stage: test
script:
- JOB_NAME=( $CI_JOB_NAME )
- export SUITE_INDEX=${JOB_NAME[-2]}
- export SUITE_TOTAL=${JOB_NAME[-1]}
- source ci/touch_make_dependencies
- make parallel_test_execute
artifacts:
paths:
- .cover/*
- .testoutput/*
when: always
expire_in: 7d
.unit_tests_with_race: &unit_tests_with_race
<<: *unit_tests
allow_failure: true
variables:
<<: *docker_variables
CGO_ENABLED: "1"
TESTFLAGS: "-cover -race"
unit tests 0 5: *unit_tests
unit tests 1 5: *unit_tests
unit tests 2 5: *unit_tests
unit tests 3 5: *unit_tests
unit tests 4 5: *unit_tests
unit tests with race 0 5: *unit_tests_with_race
unit tests with race 1 5: *unit_tests_with_race
unit tests with race 2 5: *unit_tests_with_race
unit tests with race 3 5: *unit_tests_with_race
unit tests with race 4 5: *unit_tests_with_race
docs check links:
image: "registry.gitlab.com/gitlab-org/gitlab-build-images:nanoc-bootstrap-ruby-2.4-alpine"
stage: test
cache: {}
dependencies: []
before_script:
- unset GPG_KEY
script:
- mv docs/ /nanoc/content/
- cd /nanoc
# Build HTML from Markdown
- bundle exec nanoc
# Check the internal links
- bundle exec nanoc check internal_links
integration windows:
<<: *except_docs
stage: test
before_script:
- $GODIR = "$env:GOPATH\src\gitlab.com\gitlab-org"
- $target_path = "$GODIR\gitlab-runner"
- $current_path = pwd
- md $GODIR -Force
- if (Test-Path $target_path) { cmd /c rmdir $target_path }
- cmd /c mklink /D $target_path $current_path
- cd $GODIR\gitlab-runner
script:
- $packages = (go list ./... | findstr -v "\/vendor\/" | Out-String | %{$_ -replace "\r\n"," "})
- $testCommand = "go test $packages"
- Invoke-Expression $testCommand
- if ( $LASTEXITCODE -ne 0 ) { exit $LASTEXITCODE }
allow_failure: true
only:
- /.*/@gitlab-org/gitlab-runner
tags:
- integration
- windows
git 1.7.1:
<<: *except_docs
image: centos:6
stage: test
variables:
GOROOT: /usr/local/go
GOPATH: /go
CGO_ENABLED: 0
OUR_PACKAGES: gitlab.com/gitlab-org/gitlab-runner/executors/shell gitlab.com/gitlab-org/gitlab-runner/shells
before_script:
- unset GPG_KEY
- yum install -y -q git && git version
- curl https://storage.googleapis.com/golang/go1.8.7.linux-amd64.tar.gz | tar zx -C $(dirname "$GOROOT")
- export PATH=${GOROOT}/bin:$PATH
- source ci/touch_make_dependencies
script:
- make test
#
# Coverage stage
#
test coverage report: &test_coverage_report
<<: *except_docs
stage: coverage
image: golang:1.10
coverage: /regular total:\s+\(statements\)\s+\d+.\d+\%/
script:
- source ci/touch_make_dependencies
- make parallel_test_coverage_report
- make parallel_test_coverage_report TESTFLAGS="-cover -race"
artifacts:
paths:
- out/coverage/*
expire_in: 7d
race conditions detector:
<<: *except_docs
stage: coverage
image: golang:1.10
script:
- source ci/touch_make_dependencies
- make check_race_conditions
#
# Build stage
#
.binaries: &binaries
<<: *except_docs
stage: build
script:
- source ci/touch_make_dependencies
- export platforms=$(echo $CI_JOB_NAME | sed 's|binaries ||')
- make build BUILD_PLATFORMS="-osarch='$platforms'"
artifacts:
paths:
- out/binaries/
expire_in: 7d
tags:
- gitlab-org
binaries darwin/386 darwin/amd64: *binaries
binaries freebsd/386 freebsd/amd64 freebsd/arm: *binaries
binaries linux/386 linux/amd64 linux/arm: *binaries
binaries windows/386 windows/amd64: *binaries
#
# Package stage
#
.packages: &packages
<<: *except_docs
stage: package
before_script:
- |
# checking GPG signing support
if [ -n "$GPG_KEY" ]; then
echo "$GPG_KEY" | gpg --batch --no-tty --allow-secret-key-import --import -
unset GPG_KEY
export GPG_KEYID=$(gpg --with-colon --list-secret-keys | head -n1 | cut -d : -f 5)
else
echo -e "\033[0;31m****** GPG signing disabled ******\033[0m"
fi
script:
- source ci/touch_make_dependencies
- make ${CI_JOB_NAME}
artifacts:
paths:
- out/deb/
- out/rpm/
expire_in: 7d
tags:
- gitlab-org
package-deb: *packages
package-rpm: *packages
#
# Release stage
#
.release_docker_images: &release_docker_images
<<: *docker
stage: release
variables: &release_docker_images_variables
<<: *docker_variables
PUBLISH_IMAGES: "true"
PUSH_TO_DOCKER_HUB: "true"
DOCKER_MACHINE_VERSION: "0.14.0"
DOCKER_MACHINE_CHECKSUM: "a4c69bffb78d3cfe103b89dae61c3ea11cc2d1a91c4ff86e630c9ae88244db02"
DUMB_INIT_VERSION: "1.0.2"
DUMB_INIT_CHECKSUM: "a8defac40aaca2ca0896c7c5adbc241af60c7c3df470c1a4c469a860bd805429"
script:
- source ci/touch_make_dependencies
- make release_docker_images
tags:
- release
.release: &release
<<: *except_docs
stage: release
before_script:
- unset GPG_KEY
- source ci/touch_make_dependencies
tags:
- release
.release_s3: &release_s3
<<: *release
script:
- make release_s3
.release_packagecloud: &release_packagecloud
<<: *release
script:
- make release_packagecloud
.release_development: &release_development
only:
- branches@gitlab-org/gitlab-runner
except:
- master@gitlab-org/gitlab-runner
- /(^docs[\/-].*|.*-docs$)/
.release_bleeding_edge: &release_bleeding_edge
only:
- master@gitlab-org/gitlab-runner
- /\Av[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+\Z/@gitlab-org/gitlab-runner
.release_stable: &release_stable
only:
- /\Av[0-9]+\.[0-9]+\.[0-9]+\Z/@gitlab-org/gitlab-runner
development S3:
<<: *release_s3
<<: *release_development
environment:
name: development/s3/${CI_COMMIT_REF_NAME}
url: https://gitlab-runner-downloads.s3.amazonaws.com/${CI_COMMIT_REF_NAME}/index.html
development docker images:
<<: *release_docker_images
variables:
<<: *release_docker_images_variables
PUBLISH_IMAGES: "false"
PUSH_TO_DOCKER_HUB: "false"
only:
- branches
except:
- master
- /(^docs[\/-].*|.*-docs$)/
tags:
- docker
bleeding edge S3:
<<: *release_s3
<<: *release_bleeding_edge
environment:
name: bleeding_edge/s3
url: https://gitlab-runner-downloads.s3.amazonaws.com/${CI_COMMIT_REF_NAME}/index.html
bleeding edge packagecloud:
<<: *release_packagecloud
<<: *release_bleeding_edge
environment:
name: bleeding_edge/packagecloud
url: https://packages.gitlab.com/runner/unstable
bleeding edge docker images:
<<: *release_docker_images
<<: *release_bleeding_edge
environment:
name: bleeding_edge/docker_images
url: https://hub.docker.com/r/gitlab/gitlab-runner/tags/
stable S3:
<<: *release_s3
<<: *release_stable
environment:
name: stable/s3
url: https://gitlab-runner-downloads.s3.amazonaws.com/${CI_COMMIT_REF_NAME}/index.html
stable packagecloud:
<<: *release_packagecloud
<<: *release_stable
environment:
name: stable/packagecloud
url: https://packages.gitlab.com/runner/gitlab-runner
stable docker images:
<<: *release_docker_images
<<: *release_stable
environment:
name: stable/docker_images
url: https://hub.docker.com/r/gitlab/gitlab-runner/tags/
static QA:
<<: *except_docs
stage: release
image: alpine:3.7
cache: {}
dependencies:
- code_quality
script: |
if [ "$(cat gl-code-quality-report.json)" != "[]" ] ; then
apk add -U --no-cache jq > /dev/null
jq -C . gl-code-quality-report.json
exit 1
fi