.gitlab-ci.yml 4.56 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
12
13
14
.only_settings: &only_settings
    - merge_requests
    - branches@utils/rust-git-workarea
    - tags@utils/rust-git-workarea

15
16
17
.cargo_update: &cargo_update
    - cargo generate-lockfile $GENERATE_LOCKFILE_ARGS
    - cargo fetch --locked
18
19
    - mkdir .cargo
    - cargo vendor > .cargo/config
20

21
.cargo_clippy: &cargo_clippy
Ben Boeckel's avatar
Ben Boeckel committed
22
23
24
    # 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
25
    - rustup component add clippy
Ben Boeckel's avatar
Ben Boeckel committed
26
    - cargo clippy --frozen --tests --all --verbose -- -D warnings
Ben Boeckel's avatar
Ben Boeckel committed
27
    - ".gitlab/sccache --show-stats || :"
28

29
.cargo_build: &cargo_build
Ben Boeckel's avatar
Ben Boeckel committed
30
31
32
    # 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
Ben Boeckel's avatar
Ben Boeckel committed
33
    - cargo build --frozen --all --verbose
34
    - cargo test --frozen --all --no-run --verbose
Ben Boeckel's avatar
Ben Boeckel committed
35
    - ".gitlab/sccache --show-stats || :"
36
37
38
39
40

.cargo_test: &cargo_test
    - cargo test --frozen --all --verbose

.rust_minimum: &rust_minimum
Ben Boeckel's avatar
Ben Boeckel committed
41
    image: "rust:1.36.0"
42
43
44

    variables:
        CARGO_UPDATE_POLICY: newest
Ben Boeckel's avatar
Ben Boeckel committed
45
        SCCACHE_REDIS: redis://minmus:6379
46
47
48
49
50
51

.rust_stable: &rust_stable
    image: "rust:latest"

    variables:
        CARGO_UPDATE_POLICY: newest
Ben Boeckel's avatar
Ben Boeckel committed
52
        SCCACHE_REDIS: redis://minmus:6379
53
54
55
56
57
58
59
60

.rust_nightly: &rust_nightly
    extends: .rust_stable

    image: "rustlang/rust:nightly"

.cargo_fetch_job: &cargo_fetch_job
    stage: prepare
61
    only: *only_settings
62
63
64
65
66
67
    tags:
        - build
        - docker
        - ghostflow
        - linux

68
69
70
71
    script: *cargo_update
    artifacts:
        expire_in: 60m
        paths:
72
73
            - vendor
            - .cargo
74
75
76
77
78
79
80
            - Cargo.lock
    cache:
        key: cargo-cache-$CARGO_UPDATE_POLICY
        paths:
            - .cargo-cache
    interruptible: true

81
82
.cargo_clippy_job: &cargo_clippy_job
    stage: build
83
    only: *only_settings
84
85
86
87
88
    tags:
        - build
        - docker
        - ghostflow
        - linux
89
90
91
    script: *cargo_clippy
    interruptible: true

92
93
.cargo_build_job: &cargo_build_job
    stage: build
94
    only: *only_settings
95
96
97
98
99
    tags:
        - build
        - docker
        - ghostflow
        - linux
100
101
102
103
    script: *cargo_build
    artifacts:
        expire_in: 60m
        paths:
104
105
            - vendor
            - .cargo
106
107
108
109
110
111
            - Cargo.lock
            - target
    interruptible: true

.cargo_test_job: &cargo_test_job
    stage: test
112
    only: *only_settings
113
114
115
116
117
    tags:
        - build
        - docker
        - ghostflow
        - linux
118
119
120
121
122
123
124
125
126
127
128
129
130
    script: *cargo_test
    interruptible: true

stages:
    - prepare
    - build
    - test

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

131
132
133
134
135
136
137
138
# prepare:cargo-cache-mindeps:
#     <<:
#         - *cargo_fetch_job
#         - *rust_nightly
#     variables:
#         GENERATE_LOCKFILE_ARGS: "-Z minimal-versions"
#         CARGO_UPDATE_POLICY: mindeps

139
140
141
142
143
144
145
146
.cargo_cache_newest: &cargo_cache_newest
    dependencies:
        - prepare:cargo-cache-newest
    needs:
        - prepare:cargo-cache-newest

build:cargo-clippy:
    <<:
147
        - *cargo_clippy_job
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
        - *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

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

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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212

# 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