|
7 | 7 |
|
8 | 8 | stages:
|
9 | 9 | - test
|
10 |
| - - build |
| 10 | + - publish |
11 | 11 |
|
12 | 12 | variables: &default-vars
|
13 | 13 | GIT_STRATEGY: fetch
|
14 |
| - GIT_DEPTH: 3 |
| 14 | + GIT_DEPTH: 100 |
15 | 15 | CARGO_INCREMENTAL: 0
|
16 | 16 | CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
|
17 |
| - CI_SERVER_NAME: "GitLab CI" |
| 17 | + CI_IMAGE: "paritytech/ci-linux:production" |
| 18 | + DOCKER_OS: "debian:stretch" |
| 19 | + ARCH: "x86_64" |
| 20 | + |
| 21 | +.rust-info-script: &rust-info-script |
| 22 | + - rustup show |
| 23 | + - cargo --version |
| 24 | + - rustup +nightly show |
| 25 | + - cargo +nightly --version |
| 26 | + - bash --version |
| 27 | + - sccache -s |
| 28 | + |
| 29 | +.publish-refs: &publish-refs |
| 30 | + rules: |
| 31 | + - if: $CI_PIPELINE_SOURCE == "web" |
| 32 | + - if: $CI_PIPELINE_SOURCE == "schedule" |
| 33 | + - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 |
18 | 34 |
|
19 | 35 | .docker-env: &docker-env
|
20 |
| - image: paritytech/ci-linux:production |
| 36 | + image: "${CI_IMAGE}" |
21 | 37 | before_script:
|
22 |
| - - cargo -vV |
23 |
| - - rustc -vV |
24 |
| - - rustup show |
25 |
| - - cargo --version |
| 38 | + - *rust-info-script |
| 39 | + - ./scripts/ci/pre_cache.sh |
26 | 40 | - sccache -s
|
27 |
| - only: |
28 |
| - - master |
29 |
| - - /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 |
30 |
| - - schedules |
31 |
| - - web |
32 |
| - - /^[0-9]+$/ # PRs |
33 |
| - dependencies: [] |
34 |
| - interruptible: true |
35 | 41 | retry:
|
36 | 42 | max: 2
|
37 | 43 | when:
|
38 | 44 | - runner_system_failure
|
39 | 45 | - unknown_failure
|
40 | 46 | - api_failure
|
| 47 | + interruptible: true |
41 | 48 | tags:
|
42 | 49 | - linux-docker
|
43 | 50 |
|
44 |
| -#### stage: test |
| 51 | +.kubernetes-env: &kubernetes-env |
| 52 | + retry: |
| 53 | + max: 2 |
| 54 | + when: |
| 55 | + - runner_system_failure |
| 56 | + - unknown_failure |
| 57 | + - api_failure |
| 58 | + interruptible: true |
| 59 | + tags: |
| 60 | + - kubernetes-parity-build |
45 | 61 |
|
46 |
| -cargo-audit: |
47 |
| - stage: test |
48 |
| - <<: *docker-env |
49 |
| - except: |
50 |
| - - /^[0-9]+$/ |
51 |
| - script: |
52 |
| - - cargo audit |
53 |
| - allow_failure: true |
| 62 | +.collect-artifacts: &collect-artifacts |
| 63 | + artifacts: |
| 64 | + name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}" |
| 65 | + when: on_success |
| 66 | + expire_in: 28 days |
| 67 | + paths: |
| 68 | + - ./artifacts/ |
| 69 | + |
| 70 | +#### stage: test |
54 | 71 |
|
55 | 72 | test-linux-stable:
|
56 | 73 | stage: test
|
57 | 74 | <<: *docker-env
|
| 75 | + rules: |
| 76 | + - if: $CI_COMMIT_REF_NAME == "master" |
| 77 | + - if: $CI_COMMIT_REF_NAME == "tags" |
| 78 | + - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs |
| 79 | + # It doesn't make sense to build on every commit, so we build on tags |
| 80 | + - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 |
| 81 | + variables: |
| 82 | + ARE_WE_RELEASING_YET: maybe! |
| 83 | + # web and schedule triggers can be provided with the non-empty variable ARE_WE_RELEASING_YET |
| 84 | + # to run building and publishing the binary. |
| 85 | + - if: $CI_PIPELINE_SOURCE == "web" |
| 86 | + - if: $CI_PIPELINE_SOURCE == "schedule" |
| 87 | + <<: *collect-artifacts |
58 | 88 | variables:
|
59 | 89 | <<: *default-vars
|
60 | 90 | # Enable debug assertions since we are running optimized builds for testing
|
61 | 91 | # but still want to have debug assertions.
|
62 | 92 | RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
|
63 | 93 | script:
|
64 | 94 | - time cargo test --all --release --locked
|
| 95 | + # It's almost free to produce a binary here, please refrain from using it in production since |
| 96 | + # it goes with the debug assertions. |
| 97 | + - if [ "${ARE_WE_RELEASING_YET}" ]; then |
| 98 | + echo "___Building a binary___"; |
| 99 | + time cargo build --release --locked --bin polkadot-collator; |
| 100 | + echo "___Packing the artifacts___"; |
| 101 | + mkdir -p ./artifacts; |
| 102 | + mv ${CARGO_TARGET_DIR}/release/polkadot-collator ./artifacts/.; |
| 103 | + echo "___The VERSION is either a tag name or the curent branch if triggered not by a tag___"; |
| 104 | + echo ${CI_COMMIT_REF_NAME} | tee ./artifacts/VERSION; |
| 105 | + else |
| 106 | + exit 0; |
| 107 | + fi |
65 | 108 | - sccache -s
|
| 109 | + |
| 110 | +#### stage: publish |
| 111 | + |
| 112 | +publish-s3: |
| 113 | + stage: publish |
| 114 | + <<: *kubernetes-env |
| 115 | + image: paritytech/awscli:latest |
| 116 | + <<: *publish-refs |
| 117 | + variables: |
| 118 | + GIT_STRATEGY: none |
| 119 | + BUCKET: "releases.parity.io" |
| 120 | + PREFIX: "cumulus/${ARCH}-${DOCKER_OS}" |
| 121 | + before_script: |
| 122 | + # Job will fail if no artifacts were provided by test-linux-stable job. It's only possible for |
| 123 | + # this test to fail if the pipeline was triggered by web or schedule trigger without supplying |
| 124 | + # a nono-empty ARE_WE_RELEASING_YET variable. |
| 125 | + - test -e ./artifacts/polkadot-collator || |
| 126 | + ( echo "___No artifacts were provided by the previous job, please check the build there___"; exit 1 ) |
| 127 | + script: |
| 128 | + - echo "___Publishing a binary with debug assertions!___" |
| 129 | + - echo "___VERSION = $(cat ./artifacts/VERSION) ___" |
| 130 | + - aws s3 sync ./artifacts/ s3://${BUCKET}/${PREFIX}/$(cat ./artifacts/VERSION)/ |
| 131 | + - echo "___Updating objects in latest path___" |
| 132 | + - aws s3 sync s3://${BUCKET}/${PREFIX}/$(cat ./artifacts/VERSION)/ s3://${BUCKET}/${PREFIX}/latest/ |
| 133 | + after_script: |
| 134 | + - aws s3 ls s3://${BUCKET}/${PREFIX}/latest/ |
| 135 | + --recursive --human-readable --summarize |
0 commit comments