.gitlab-ci.yml 8.02 KB
Newer Older
1 2 3 4 5 6 7 8 9
# The `mindeps` builds are not working due, at the root, `syntex` -> `ctest` ->
# `flate2` -> `reqwest`.

before_script:
    - apt-get update -yqq
    - export CARGO_HOME=.cargo-cache
    - rustc --version
    - cargo --version

10 11
.only_settings: &only_settings
    - merge_requests
Grokafar's avatar
Test CI  
Grokafar committed
12
    - branches@Grokafar/rust-gitlab
Ben Boeckel's avatar
Ben Boeckel committed
13
    - tags@utils/rust-gitlab
14

15
.cargo_update: &cargo_update
16 17 18 19 20
    # XXX(minver<1.41.0): No backwards compatibility is provided. Instead, it
    # uses the format of the existing `Cargo.lock` file to determine the format
    # of the to-be-written file. See
    # https://github.com/rust-lang/cargo/pull/7579#pullrequestreview-323640264
    - touch Cargo.lock
21
    - cargo update $GENERATE_LOCKFILE_ARGS
22
    - cargo fetch --locked
23 24
    - mkdir .cargo
    - cargo vendor > .cargo/config
25

26
.cargo_clippy: &cargo_clippy
Ben Boeckel's avatar
Ben Boeckel committed
27 28 29
    # Only use it if it's available; no need to fail the build due to something
    # gone wrong here.
    - .gitlab/ci/sccache.sh && export RUSTC_WRAPPER=$PWD/.gitlab/sccache
30
    - rustup component add clippy
Ben Boeckel's avatar
Ben Boeckel committed
31
    - cargo clippy --frozen --tests --all --verbose -- -D warnings
Ben Boeckel's avatar
Ben Boeckel committed
32
    - ".gitlab/sccache --show-stats || :"
33

34
.cargo_build: &cargo_build
Ben Boeckel's avatar
Ben Boeckel committed
35 36 37
    # Only use it if it's available; no need to fail the build due to something
    # gone wrong here.
    - .gitlab/ci/sccache.sh && export RUSTC_WRAPPER=$PWD/.gitlab/sccache
Grokafar's avatar
Grokafar committed
38 39
    - cargo build $CARGO_FEATURES --frozen --all --verbose
    - cargo test $CARGO_FEATURES --frozen --all --no-run --verbose
Ben Boeckel's avatar
Ben Boeckel committed
40
    - ".gitlab/sccache --show-stats || :"
41 42

.cargo_test: &cargo_test
Grokafar's avatar
Grokafar committed
43
    - cargo test $CARGO_FEATURES --frozen --all --verbose
44

45 46 47 48
.cargo_tarpaulin_build: &cargo_tarpaulin_build
    - .gitlab/ci/sccache.sh && export RUSTC_WRAPPER=$PWD/.gitlab/sccache
    - .gitlab/ci/tarpaulin.sh
    - export PATH=$PWD/.gitlab:$PATH
Grokafar's avatar
Grokafar committed
49
    - cargo tarpaulin --no-run --frozen $CARGO_FEATURES --exclude-files vendor --ignore-panics --all --verbose
50 51 52 53 54
    - ".gitlab/sccache --show-stats || :"

.cargo_tarpaulin_test: &cargo_tarpaulin_test
    - .gitlab/ci/tarpaulin.sh
    - export PATH=$PWD/.gitlab:$PATH
55
    - cargo tarpaulin --frozen $CARGO_FEATURES --exclude-files vendor --ignore-panics --all --verbose --out Html
56

57
.rust_minimum: &rust_minimum
58
    image: "rust:1.40.0"
59 60 61

    variables:
        CARGO_UPDATE_POLICY: newest
62
        GIT_CLONE_PATH: $CI_BUILDS_DIR/rust
63

Grokafar's avatar
Grokafar committed
64 65 66 67 68 69
.rust_minimum_no_default_features: &rust_minimum_no_default_features
    extends: .rust_minimum

    variables:
        CARGO_FEATURES: --no-default-features

70 71 72 73 74
.rust_stable: &rust_stable
    image: "rust:latest"

    variables:
        CARGO_UPDATE_POLICY: newest
75
        GIT_CLONE_PATH: $CI_BUILDS_DIR/rust
76

Grokafar's avatar
Grokafar committed
77 78 79 80 81 82
.rust_stable_no_default_features: &rust_stable_no_default_features
    extends: .rust_stable

    variables:
        CARGO_FEATURES: --no-default-features

83 84 85 86 87
.rust_nightly: &rust_nightly
    extends: .rust_stable

    image: "rustlang/rust:nightly"

Grokafar's avatar
Grokafar committed
88 89 90 91 92 93
.rust_nightly_no_default_features: &rust_nightly_no_default_features
    extends: .rust_nightly

    variables:
        CARGO_FEATURES: --no-default-features

94 95
.cargo_fetch_job: &cargo_fetch_job
    stage: prepare
96
    only: *only_settings
97 98 99 100 101
    tags:
        - build
        - docker
        - linux

102 103 104 105
    script: *cargo_update
    artifacts:
        expire_in: 60m
        paths:
106 107
            - vendor
            - .cargo
108 109 110 111 112 113 114
            - Cargo.lock
    cache:
        key: cargo-cache-$CARGO_UPDATE_POLICY
        paths:
            - .cargo-cache
    interruptible: true

115 116
.cargo_clippy_job: &cargo_clippy_job
    stage: build
117
    only: *only_settings
118 119 120 121
    tags:
        - build
        - docker
        - linux
122 123 124
    script: *cargo_clippy
    interruptible: true

125 126
.cargo_build_job: &cargo_build_job
    stage: build
127
    only: *only_settings
128 129 130 131
    tags:
        - build
        - docker
        - linux
132 133 134 135
    script: *cargo_build
    artifacts:
        expire_in: 60m
        paths:
136 137
            - vendor
            - .cargo
138 139 140 141 142 143
            - Cargo.lock
            - target
    interruptible: true

.cargo_test_job: &cargo_test_job
    stage: test
144
    only: *only_settings
145 146 147 148
    tags:
        - build
        - docker
        - linux
149 150 151
    script: *cargo_test
    interruptible: true

152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
.cargo_tarpaulin_build_job: &cargo_tarpaulin_build_job
    stage: build
    only: *only_settings
    tags:
        - build
        - docker
        - linux
    script: *cargo_tarpaulin_build
    artifacts:
        expire_in: 60m
        paths:
            - vendor
            - .cargo
            - Cargo.lock
            - target
    interruptible: true

.cargo_tarpaulin_test_job: &cargo_tarpaulin_test_job
    stage: test
    only: *only_settings
    tags:
        - docker
        - linux
        - privileged
176 177 178 179 180
    artifacts:
        expose_as: "Coverage report"
        expire_in: 1 week
        paths:
            - tarpaulin-report.html
181 182 183 184
    script: *cargo_tarpaulin_test
    coverage: '/\d+.\d+% coverage, \d+\/\d+ lines covered/'
    interruptible: true

185 186 187 188 189 190 191 192
stages:
    - prepare
    - build
    - test

prepare:cargo-cache-newest:
    <<:
        - *cargo_fetch_job
193
        - *rust_stable
194

195 196 197 198 199 200 201 202
# prepare:cargo-cache-mindeps:
#     <<:
#         - *cargo_fetch_job
#         - *rust_nightly
#     variables:
#         GENERATE_LOCKFILE_ARGS: "-Z minimal-versions"
#         CARGO_UPDATE_POLICY: mindeps

203 204 205 206 207 208 209 210
.cargo_cache_newest: &cargo_cache_newest
    dependencies:
        - prepare:cargo-cache-newest
    needs:
        - prepare:cargo-cache-newest

build:cargo-clippy:
    <<:
211
        - *cargo_clippy_job
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
        - *rust_stable
        - *cargo_cache_newest

build:cargo-minimum:
    <<:
        - *cargo_build_job
        - *rust_minimum
        - *cargo_cache_newest

test:cargo-minimum:
    <<:
        - *cargo_test_job
        - *rust_minimum
    dependencies:
        - build:cargo-minimum
    needs:
        - build:cargo-minimum

Grokafar's avatar
Grokafar committed
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
build:cargo-minimum-no-default-features:
    <<:
        - *cargo_build_job
        - *rust_minimum_no_default_features
        - *cargo_cache_newest

test:cargo-minimum-no-default-features:
    <<:
        - *cargo_test_job
        - *rust_minimum_no_default_features
    dependencies:
        - build:cargo-minimum-no-default-features
    needs:
        - build:cargo-minimum-no-default-features

245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
build:cargo-stable:
    <<:
        - *cargo_build_job
        - *rust_stable
        - *cargo_cache_newest

test:cargo-stable:
    <<:
        - *cargo_test_job
        - *rust_stable
    dependencies:
        - build:cargo-stable
    needs:
        - build:cargo-stable

Grokafar's avatar
Grokafar committed
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
build:cargo-stable-no-default-features:
    <<:
        - *cargo_build_job
        - *rust_stable_no_default_features
        - *cargo_cache_newest

test:cargo-stable-no-default-features:
    <<:
        - *cargo_test_job
        - *rust_stable_no_default_features
    dependencies:
        - build:cargo-stable-no-default-features
    needs:
        - build:cargo-stable-no-default-features

275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
build:cargo-tarpaulin:
    <<:
        - *cargo_tarpaulin_build_job
        - *rust_stable
        - *cargo_cache_newest

test:cargo-tarpaulin:
    <<:
        - *cargo_tarpaulin_test_job
        - *rust_stable
    dependencies:
        - build:cargo-tarpaulin
    needs:
        - build:cargo-tarpaulin

290 291 292 293 294 295 296 297 298 299 300 301 302 303
build:cargo-nightly:
    <<:
        - *cargo_build_job
        - *rust_nightly
        - *cargo_cache_newest

test:cargo-nightly:
    <<:
        - *cargo_test_job
        - *rust_nightly
    dependencies:
        - build:cargo-nightly
    needs:
        - build:cargo-nightly
304

Grokafar's avatar
Grokafar committed
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
build:cargo-nightly-no-default-features:
    <<:
        - *cargo_build_job
        - *rust_nightly_no_default_features
        - *cargo_cache_newest

test:cargo-nightly-no-default-features:
    <<:
        - *cargo_test_job
        - *rust_nightly_no_default_features
    dependencies:
        - build:cargo-nightly-no-default-features
    needs:
        - build:cargo-nightly-no-default-features

320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
# build:cargo-mindeps:
#     <<:
#         - *cargo_build_job
#         - *rust_minimum
#     dependencies:
#         - prepare:cargo-cache-mindeps
#     needs:
#         - prepare:cargo-cache-mindeps

# test:cargo-mindeps:
#     <<:
#         - *cargo_test_job
#         - *rust_minimum
#     dependencies:
#         - build:cargo-mindeps
#     needs:
#         - build:cargo-mindeps