github.com/secure-build/gitlab-runner@v12.5.0+incompatible/.gitlab-ci.yml (about) 1 include: 2 template: License-Management.gitlab-ci.yml 3 4 stages: 5 - prepare 6 - prebuild 7 - test 8 - coverage 9 - build 10 - package 11 - release 12 - docs 13 14 variables: 15 CI_IMAGE: registry.gitlab.com/gitlab-org/gitlab-runner/ci:1.10.8-1 16 GOROOT: /usr/local/go 17 # Following variables are used in some jobs to install specified software 18 DOCKER_MACHINE_VERSION: "0.16.2" 19 DUMB_INIT_VERSION: "1.0.2" 20 GIT_VERSION: "2.21.0" 21 GIT_VERSION_BUILD: "1" 22 GIT_LFS_VERSION: "2.7.1" 23 LICENSE_MANAGEMENT_SETUP_CMD: echo "Skip setup. Dependency already vendored" 24 DOCS_GITLAB_REPO_SUFFIX: "runner" 25 26 before_script: 27 - unset GPG_KEY 28 29 image: $CI_IMAGE 30 31 # Skip all jobs except the ones that begin and end with 'docs'. 32 # Used for commits including ONLY documentation changes. 33 # https://docs.gitlab.com/ce/development/writing_documentation.html#testing 34 .except_docs: &except_docs 35 except: 36 - /(^docs[\/-].*|.*-docs$)/ 37 38 .windows_base: 39 variables: &windows_base_variables 40 PKG_NAMESPACE: gitlab.com\gitlab-org 41 PKG_NAME: gitlab-runner 42 GOPATH: "$CI_PROJECT_DIR\\.gopath" 43 PKG_BASE_DIR: "$CI_PROJECT_DIR\\.gopath\\src\\$PKG_NAMESPACE" 44 PKG_BUILD_DIR: "$CI_PROJECT_DIR\\.gopath\\src\\$PKG_NAMESPACE\\$PKG_NAME" 45 46 .docker: &docker 47 <<: *except_docs 48 services: 49 - docker:19.03-dind 50 variables: &docker_variables 51 CI_IMAGE: registry.gitlab.com/gitlab-org/gitlab-runner/ci:1.10.8-1 52 DOCKER_DRIVER: overlay2 53 DOCKER_HOST: tcp://docker:2376 54 DOCKER_TLS_VERIFY: 1 55 DOCKER_TLS_CERTDIR: "/certs" 56 DOCKER_CERT_PATH: "/certs/client" 57 tags: 58 - docker 59 60 .windows1803: &windows1803 61 variables: &windows1803_variables 62 <<: *windows_base_variables 63 WINDOWS_VERSION: servercore1803 64 tags: 65 - windows-1803 66 - shell 67 68 .windows1809: &windows1809 69 variables: &windows1809_variables 70 <<: *windows_base_variables 71 WINDOWS_VERSION: servercore1809 72 tags: 73 - windows-1809 74 - shell 75 76 # 77 # Prepare stage 78 # 79 80 .image_builder: &image_builder 81 <<: *docker 82 stage: prepare 83 image: docker:19.03-git 84 script: 85 - source ./ci/build_ci_image 86 87 prepare ci image: 88 <<: *image_builder 89 variables: 90 BUILD_IMAGE: $CI_IMAGE 91 BUILD_DOCKERFILE: ./dockerfiles/ci/Dockerfile 92 only: 93 - /\Adocker-ci-image\/.*/ 94 95 prepare alpine-no-root image: 96 <<: *image_builder 97 variables: 98 BUILD_IMAGE: registry.gitlab.com/gitlab-org/gitlab-runner/alpine-no-root:latest 99 BUILD_DOCKERFILE: ./tests/dockerfiles/alpine-no-root/Dockerfile 100 only: 101 - /\Adocker-alpine-no-root-image\/.*/ 102 103 # 104 # Prebuild stage 105 # 106 107 helper images: 108 <<: *docker 109 stage: prebuild 110 script: 111 - make helper-build helper-docker 112 artifacts: 113 paths: 114 - out/helper-images/ 115 - dockerfiles/build/binaries/*-windows.exe 116 - .gopath/bin 117 - .gopath/.ok 118 expire_in: 7d 119 120 clone test repo: 121 <<: *except_docs 122 stage: prebuild 123 script: 124 - mkdir tmp 125 - succeed=0 126 - for i in {1..3}; do git clone https://gitlab.com/gitlab-org/ci-cd/tests/gitlab-test.git tmp/gitlab-test && succeed=1 && break; echo "retrying"; done 127 - '[[ "$succeed" -eq 1 ]]' 128 artifacts: 129 paths: 130 - tmp/gitlab-test 131 expire_in: 7d 132 133 tests definitions: 134 <<: *except_docs 135 stage: prebuild 136 # Using Go 1.10, because the `go test -list` is unavailable in <1.9 137 # and it's much faster in 1.10. And since there is no real test execution 138 # in this step, the version difference doesn't matter 139 image: golang:1.10 140 script: 141 - apt-get update 142 - apt-get install -y make 143 - source ci/touch_make_dependencies 144 - make parallel_test_prepare 145 artifacts: 146 paths: 147 - testsdefinitions.txt 148 expire_in: 7d 149 tags: 150 - gitlab-org 151 152 dep check: 153 <<: *except_docs 154 stage: prebuild 155 cache: {} 156 dependencies: 157 script: 158 - make dep_check 159 160 dep status: 161 <<: *except_docs 162 stage: prebuild 163 cache: {} 164 dependencies: 165 script: 166 - make dep_status 167 only: 168 variables: 169 - $CI_DEP_STATUS_ENABLED 170 171 check feature flags docs: 172 stage: prebuild 173 cache: {} 174 dependencies: 175 script: 176 - cp docs/configuration/feature-flags.md docs/configuration/feature-flags.md.orig 177 - make update_feature_flags_docs 178 - | 179 diff docs/configuration/feature-flags.md.orig docs/configuration/feature-flags.md || ( 180 echo 181 echo "Feature Flags list in documentation is not up-to-date" 182 echo "Run 'make update_feature_flags_docs' to upate it" 183 echo 184 exit 1 185 ) 186 187 # 188 # Test stage 189 # 190 191 code_quality: 192 <<: *except_docs 193 stage: test 194 image: docker:19.03-git 195 services: 196 - docker:19.03-dind 197 variables: 198 DOCKER_DRIVER: overlay2 199 CODECLIMATE_FORMAT: json 200 cache: {} 201 dependencies: [] 202 script: 203 - ./scripts/codequality analyze -f json --dev | tee gl-code-quality-report.json 204 artifacts: 205 paths: [gl-code-quality-report.json] 206 expire_in: 7d 207 208 unit test: &unit_tests 209 <<: *docker 210 stage: test 211 parallel: 5 212 variables: 213 <<: *docker_variables 214 GIT_LFS_256_CHECKSUM: 7be85238cbbb957ab25de52b60279d40ba40d3faa72eeb2cb9fa77d6d92381e5 215 before_script: 216 # This' script content as well as the definition of GIT_LFS_256_CHECKSUM should be moved to 217 # "prepare ci image". Git LFS should be installed inside of the CI image. Unfortunately, building 218 # this image is currently blocked because of https://gitlab.com/gitlab-org/gitlab-runner/issues/3946. 219 # After we will resolve this issue, we should update the CI configuration and move the Git LFS installation 220 # to the proper place. 221 - ./ci/install_git_lfs 222 script: 223 - source ci/touch_make_dependencies 224 - make parallel_test_execute 225 artifacts: 226 paths: 227 - .cover/* 228 - .testoutput/* 229 when: always 230 expire_in: 7d 231 232 unit test with race: 233 <<: *unit_tests 234 allow_failure: true 235 variables: 236 <<: *docker_variables 237 GIT_LFS_256_CHECKSUM: 7be85238cbbb957ab25de52b60279d40ba40d3faa72eeb2cb9fa77d6d92381e5 238 CGO_ENABLED: "1" 239 TESTFLAGS: "-cover -race" 240 241 docs lint: 242 image: "registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-docs-lint" 243 stage: test 244 cache: {} 245 dependencies: [] 246 before_script: 247 - unset GPG_KEY 248 script: 249 # Lint Markdown 250 - markdownlint --config .markdownlint.json 'docs/**/*.md' 251 # Prepare docs for build 252 - mv docs/ /tmp/gitlab-docs/content/$DOCS_GITLAB_REPO_SUFFIX 253 - cd /tmp/gitlab-docs 254 # Build HTML from Markdown 255 - bundle exec nanoc 256 # Check the internal links 257 - bundle exec nanoc check internal_links 258 # Check the internal anchor links 259 - bundle exec nanoc check internal_anchors 260 261 .windows test: 262 extends: .except_docs 263 stage: test 264 parallel: 3 265 variables: 266 GOROOT: "C:\\Go" 267 before_script: 268 - if (Test-Path $GOPATH) { Remove-Item -Force -Recurse $GOPATH } 269 - New-Item $PKG_BASE_DIR -ItemType directory -Force 270 - New-Item -ItemType SymbolicLink -Path $PKG_BUILD_DIR -Value $CI_PROJECT_DIR 271 - cd $PKG_BUILD_DIR 272 script: 273 - .\ci\test_windows.ps1 274 after_script: 275 - if (Test-Path $PKG_BUILD_DIR) { $(Get-Item $PKG_BUILD_DIR).Delete() } 276 artifacts: 277 paths: 278 - .testoutput/* 279 when: always 280 expire_in: 7d 281 allow_failure: true 282 only: 283 - /.*/@gitlab-org/gitlab-runner 284 285 windows 1803 tests: 286 <<: *windows1803 287 extends: .windows test 288 289 windows 1809 tests: 290 <<: *windows1809 291 extends: .windows test 292 293 git 1.7.1: 294 <<: *except_docs 295 image: centos:6 296 stage: test 297 variables: 298 GOROOT: /usr/local/go 299 GOPATH: /go 300 CGO_ENABLED: 0 301 OUR_PACKAGES: gitlab.com/gitlab-org/gitlab-runner/executors/shell gitlab.com/gitlab-org/gitlab-runner/shells 302 before_script: 303 - unset GPG_KEY 304 - yum install -y -q git && git version 305 - curl https://storage.googleapis.com/golang/go1.10.8.linux-amd64.tar.gz | tar zx -C $(dirname "$GOROOT") 306 - export PATH=${GOROOT}/bin:$PATH 307 - source ci/touch_make_dependencies 308 script: 309 - make test 310 311 # 312 # Coverage stage 313 # 314 315 .coverage_job: &coverage_job 316 <<: *except_docs 317 stage: coverage 318 image: golang:1.10 319 when: always 320 321 test coverage report: 322 <<: *coverage_job 323 coverage: /regular total:\s+\(statements\)\s+\d+.\d+\%/ 324 script: 325 - source ci/touch_make_dependencies 326 - make parallel_test_coverage_report 327 - make parallel_test_coverage_report TESTFLAGS="-cover -race" 328 artifacts: 329 paths: 330 - out/coverage/* 331 expire_in: 7d 332 333 race conditions detector: 334 <<: *coverage_job 335 script: 336 - source ci/touch_make_dependencies 337 - make check_race_conditions 338 339 test junit report: 340 <<: *coverage_job 341 image: $CI_IMAGE 342 script: 343 - source ci/touch_make_dependencies 344 - make parallel_test_junit_report 345 artifacts: 346 reports: 347 junit: out/junit/report.xml 348 349 .check windows test failures: 350 <<: *except_docs 351 stage: coverage 352 script: 353 - ./scripts/check_windows_failures 354 artifacts: 355 paths: 356 - .test-failures.*.txt.updated 357 expire_in: 7d 358 when: always 359 360 check windows 1803 test failures: 361 variables: 362 <<: *windows1803_variables 363 extends: .check windows test failures 364 365 check windows 1809 test failures: 366 variables: 367 <<: *windows1809_variables 368 extends: .check windows test failures 369 370 # 371 # Build stage 372 # 373 374 .binaries: &binaries 375 <<: *except_docs 376 stage: build 377 script: 378 - source ci/touch_make_dependencies 379 - export platforms=$(echo $CI_JOB_NAME | sed 's|binaries ||') 380 - make build BUILD_PLATFORMS="-osarch='$platforms'" 381 artifacts: 382 paths: 383 - out/binaries/ 384 expire_in: 7d 385 tags: 386 - gitlab-org 387 388 binaries darwin/386 darwin/amd64: *binaries 389 binaries freebsd/386 freebsd/amd64 freebsd/arm: *binaries 390 binaries linux/386 linux/amd64 linux/arm: *binaries 391 binaries windows/386 windows/amd64: *binaries 392 393 # 394 # Package stage 395 # 396 397 .packages: &packages 398 <<: *except_docs 399 stage: package 400 before_script: 401 - | 402 # checking GPG signing support 403 if [ -n "$GPG_KEY" ]; then 404 echo "$GPG_KEY" | gpg --batch --no-tty --allow-secret-key-import --import - 405 unset GPG_KEY 406 export GPG_KEYID=$(gpg --with-colon --list-secret-keys | head -n1 | cut -d : -f 5) 407 else 408 echo -e "\033[0;31m****** GPG signing disabled ******\033[0m" 409 fi 410 script: 411 - source ci/touch_make_dependencies 412 - make ${CI_JOB_NAME} 413 artifacts: 414 paths: 415 - out/deb/ 416 - out/rpm/ 417 expire_in: 7d 418 tags: 419 - gitlab-org 420 421 package-deb: *packages 422 package-rpm: *packages 423 424 # 425 # Release stage 426 # 427 428 .release_docker_images: &release_docker_images 429 <<: *docker 430 stage: release 431 variables: &release_docker_images_variables 432 <<: *docker_variables 433 PUBLISH_IMAGES: "true" 434 PUSH_TO_DOCKER_HUB: "true" 435 DOCKER_MACHINE_CHECKSUM: "a7f7cbb842752b12123c5a5447d8039bf8dccf62ec2328853583e68eb4ffb097" 436 DUMB_INIT_CHECKSUM: "a8defac40aaca2ca0896c7c5adbc241af60c7c3df470c1a4c469a860bd805429" 437 GIT_LFS_VERSION: "2.7.1" 438 GIT_LFS_CHECKSUM: "c8952ee72af214e3669f834d829e8a0a3becd160dead18237f99e40d75a3e920" 439 440 script: 441 - source ci/touch_make_dependencies 442 - make release_docker_images 443 tags: 444 - release 445 446 .build_windows_docker_images: 447 <<: *except_docs 448 stage: release 449 variables: 450 PUSH_TO_DOCKER_HUB: "false" 451 GIT_256_CHECKSUM: "bd91db55bd95eaa80687df28877e2df8c8858a0266e9c67331cfddba2735f25c" 452 GIT_LFS_256_CHECKSUM: "5c12db9728b53cba23e5f58f4a53d88cb2132e82fa1de0f8a79ce9d112e4d396" 453 before_script: 454 - if (Test-Path env:GPG_KEY) { Remove-Item Env:GPG_KEY } 455 script: 456 - .\ci\build_release_windows_images.ps1 457 dependencies: 458 - helper images 459 460 .release: &release 461 <<: *except_docs 462 stage: release 463 before_script: 464 - unset GPG_KEY 465 - source ci/touch_make_dependencies 466 tags: 467 - release 468 469 .release_s3: &release_s3 470 <<: *release 471 script: 472 - make release_s3 473 - | 474 # publish release on gitlab.com 475 if [[ -n "${CI_COMMIT_TAG}" ]]; then 476 ./ci/release_gitlab 477 else 478 echo -e "\033[0;31m****** gitlab publishing disabled ******\033[0m" 479 fi 480 481 .release_packagecloud: &release_packagecloud 482 <<: *release 483 script: 484 - make release_packagecloud 485 486 .release_development: &release_development 487 only: 488 - branches@gitlab-org/gitlab-runner 489 except: 490 - master@gitlab-org/gitlab-runner 491 - /(^docs[\/-].*|.*-docs$)/ 492 493 .release_bleeding_edge: &release_bleeding_edge 494 only: 495 - master@gitlab-org/gitlab-runner 496 - /\Av[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+\Z/@gitlab-org/gitlab-runner 497 498 .release_stable: &release_stable 499 only: 500 - /\Av[0-9]+\.[0-9]+\.[0-9]+\Z/@gitlab-org/gitlab-runner 501 502 development S3: 503 <<: *release_s3 504 <<: *release_development 505 environment: 506 name: development/s3/${CI_COMMIT_REF_NAME} 507 url: https://gitlab-runner-downloads.s3.amazonaws.com/${CI_COMMIT_REF_NAME}/index.html 508 509 development docker images: 510 <<: *release_docker_images 511 variables: 512 <<: *release_docker_images_variables 513 PUBLISH_IMAGES: "false" 514 PUSH_TO_DOCKER_HUB: "false" 515 only: 516 - branches 517 except: 518 - master 519 - /(^docs[\/-].*|.*-docs$)/ 520 tags: 521 - docker 522 523 development servercore1803 helper docker image: 524 <<: *release_development 525 <<: *windows1803 526 extends: .build_windows_docker_images 527 528 development servercore1809 helper docker image: 529 <<: *release_development 530 <<: *windows1809 531 extends: .build_windows_docker_images 532 533 bleeding edge S3: 534 <<: *release_s3 535 <<: *release_bleeding_edge 536 environment: 537 name: bleeding_edge/s3 538 url: https://gitlab-runner-downloads.s3.amazonaws.com/${CI_COMMIT_REF_NAME}/index.html 539 540 bleeding edge packagecloud: 541 <<: *release_packagecloud 542 <<: *release_bleeding_edge 543 environment: 544 name: bleeding_edge/packagecloud 545 url: https://packages.gitlab.com/runner/unstable 546 547 bleeding edge docker images: 548 <<: *release_docker_images 549 <<: *release_bleeding_edge 550 environment: 551 name: bleeding_edge/docker_images 552 url: https://hub.docker.com/r/gitlab/gitlab-runner/tags/ 553 554 bleeding edge servercore1803 docker images: 555 <<: *release_bleeding_edge 556 <<: *windows1803 557 extends: .build_windows_docker_images 558 variables: 559 <<: *windows1803_variables 560 PUSH_TO_DOCKER_HUB: "true" 561 environment: 562 name: bleeding_edge/docker_images/windows1803 563 url: https://hub.docker.com/r/gitlab/gitlab-runner/tags/ 564 565 bleeding edge servercore1809 docker images: 566 <<: *release_bleeding_edge 567 <<: *windows1809 568 extends: .build_windows_docker_images 569 variables: 570 <<: *windows1809_variables 571 PUSH_TO_DOCKER_HUB: "true" 572 environment: 573 name: bleeding_edge/docker_images/windows1809 574 url: https://hub.docker.com/r/gitlab/gitlab-runner/tags/ 575 576 stable S3: 577 <<: *release_s3 578 <<: *release_stable 579 environment: 580 name: stable/s3 581 url: https://gitlab-runner-downloads.s3.amazonaws.com/${CI_COMMIT_REF_NAME}/index.html 582 583 stable packagecloud: 584 <<: *release_packagecloud 585 <<: *release_stable 586 environment: 587 name: stable/packagecloud 588 url: https://packages.gitlab.com/runner/gitlab-runner 589 590 stable docker images: 591 <<: *release_docker_images 592 <<: *release_stable 593 environment: 594 name: stable/docker_images 595 url: https://hub.docker.com/r/gitlab/gitlab-runner/tags/ 596 597 stable servercore1803 docker images: 598 <<: *release_stable 599 <<: *windows1803 600 extends: .build_windows_docker_images 601 variables: 602 <<: *windows1803_variables 603 PUSH_TO_DOCKER_HUB: "true" 604 environment: 605 name: stable/docker_images/windows1803 606 url: https://hub.docker.com/r/gitlab/gitlab-runner/tags/ 607 608 stable servercore1809 docker images: 609 <<: *release_stable 610 <<: *windows1809 611 extends: .build_windows_docker_images 612 variables: 613 <<: *windows1809_variables 614 PUSH_TO_DOCKER_HUB: "true" 615 environment: 616 name: stable/docker_images/windows1809 617 url: https://hub.docker.com/r/gitlab/gitlab-runner/tags/ 618 619 static QA: 620 <<: *except_docs 621 stage: release 622 image: alpine:3.7 623 cache: {} 624 dependencies: 625 - code_quality 626 script: | 627 if [ "$(cat gl-code-quality-report.json)" != "[]" ] ; then 628 apk add -U --no-cache jq > /dev/null 629 jq -C . gl-code-quality-report.json 630 exit 1 631 fi 632 633 # 634 # Docs stage 635 # 636 637 # Review docs base 638 .review-docs: &review-docs 639 image: ruby:2.6-alpine 640 before_script: 641 - unset GPG_KEY 642 - gem install gitlab --no-doc 643 # We need to download the script rather than clone the repo since the 644 # review-docs-cleanup job will not be able to run when the branch gets 645 # deleted (when merging the MR). 646 - apk add --update openssl 647 - wget https://gitlab.com/gitlab-org/gitlab-ce/raw/master/scripts/trigger-build-docs 648 - chmod 755 trigger-build-docs 649 cache: {} 650 dependencies: [] 651 variables: 652 GIT_STRATEGY: none 653 when: manual 654 only: 655 - branches 656 657 # Trigger a docs build in gitlab-docs 658 # Useful to preview the docs changes live 659 # https://docs.gitlab.com/ee/development/writing_documentation.html#previewing-the-changes-live 660 review-docs-deploy: 661 <<: *review-docs 662 stage: docs 663 environment: 664 name: review-docs/$CI_COMMIT_REF_SLUG 665 # DOCS_REVIEW_APPS_DOMAIN and DOCS_GITLAB_REPO_SUFFIX are secret variables 666 # Discussion: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14236/diffs#note_40140693 667 url: http://$CI_ENVIRONMENT_SLUG.$DOCS_REVIEW_APPS_DOMAIN/$DOCS_GITLAB_REPO_SUFFIX 668 on_stop: review-docs-cleanup 669 script: 670 - ./trigger-build-docs deploy 671 672 # Cleanup remote environment of gitlab-docs 673 review-docs-cleanup: 674 <<: *review-docs 675 stage: docs 676 environment: 677 name: review-docs/$CI_COMMIT_REF_SLUG 678 action: stop 679 script: 680 - ./trigger-build-docs cleanup