Skip to content

Commit 9735c5f

Browse files
committed
Ensure that MSRV tests do not regress
When testing with older versions of rustc, there's a CI failure mode when our dependency, which used to be compatible with that Rust version, publishes a new version which can't be compiled using that old Rust anymore. That's pretty unfortunate, as that means that third parties can break our CI without any changes to the code in this repo. To protect against that, let's use Cargo.lock on CI, but only when testing against older versions. For stable Rust, we continue to generate Cargo.lock with freshest dependencies. Implementation wise, we save known-good Cargo.lock as `Cargo.lock.msrv`, and just copy that in every relevant CI job. To get a working `Cargo.lock.msrv`, I run `cargo +nightly generate-lockfile -Zminimal-versions` -- that is guaranteed to support the oldest Rust version we can.
1 parent 10c2a3b commit 9735c5f

File tree

2 files changed

+355
-13
lines changed

2 files changed

+355
-13
lines changed

.cirrus.yml

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ task:
4343
- . $HOME/.cargo/env
4444
- rustup target add i686-unknown-freebsd
4545
- rustup component add --toolchain $TOOLCHAIN clippy
46+
- cp Cargo.lock.msrv Cargo.lock
4647
<< : *TEST
4748
i386_test_script:
4849
- . $HOME/.cargo/env
@@ -64,6 +65,7 @@ task:
6465
- sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN
6566
- . $HOME/.cargo/env
6667
- rustup component add --toolchain $TOOLCHAIN clippy
68+
- cp Cargo.lock.msrv Cargo.lock
6769
<< : *TEST
6870
before_cache_script: rm -rf $CARGO_HOME/registry/index
6971

@@ -116,18 +118,13 @@ task:
116118
- sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN
117119
- . $HOME/.cargo/env
118120
- cargo install cross
121+
- cp Cargo.lock.msrv Cargo.lock
119122
<< : *TEST
120123
before_cache_script: rm -rf $CARGO_HOME/registry/index
121124

122125
# Tasks for Linux native builds
123126
task:
124127
matrix:
125-
- name: Rust Stable
126-
container:
127-
image: rust:latest
128-
env:
129-
TARGET: x86_64-unknown-linux-gnu
130-
TOOLCHAIN:
131128
- name: Linux aarch64
132129
arm_container:
133130
image: rust:1.46
@@ -144,6 +141,20 @@ task:
144141
image: rust:1.46
145142
env:
146143
TARGET: x86_64-unknown-linux-musl
144+
setup_script:
145+
- rustup target add $TARGET
146+
- rustup component add clippy
147+
- cp Cargo.lock.msrv Cargo.lock
148+
<< : *TEST
149+
before_cache_script: rm -rf $CARGO_HOME/registry/index
150+
151+
task:
152+
name: Rust Stable
153+
container:
154+
image: rust:latest
155+
env:
156+
TARGET: x86_64-unknown-linux-gnu
157+
TOOLCHAIN:
147158
setup_script:
148159
- rustup target add $TARGET
149160
- rustup component add clippy
@@ -219,13 +230,26 @@ task:
219230
- name: NetBSD x86_64
220231
env:
221232
TARGET: x86_64-unknown-netbsd
222-
- name: Redox x86_64
223-
env:
224-
TARGET: x86_64-unknown-redox
225-
# Redox requires a nightly compiler.
226-
# If stuff breaks, change nightly to the date at
227-
# https://gitlab.redox-os.org/redox-os/redox/-/blob/master/rust-toolchain
228-
TOOLCHAIN: nightly-2021-06-15
233+
setup_script:
234+
- rustup target add $TARGET
235+
- rustup toolchain install $TOOLCHAIN --profile minimal --target $TARGET
236+
- rustup component add --toolchain $TOOLCHAIN clippy
237+
- cp Cargo.lock.msrv Cargo.lock
238+
<< : *BUILD
239+
before_cache_script: rm -rf $CARGO_HOME/registry/index
240+
241+
task:
242+
container:
243+
image: rust:1.46
244+
env:
245+
BUILD: check
246+
name: Redox x86_64
247+
env:
248+
TARGET: x86_64-unknown-redox
249+
# Redox requires a nightly compiler.
250+
# If stuff breaks, change nightly to the date at
251+
# https://gitlab.redox-os.org/redox-os/redox/-/blob/master/rust-toolchain
252+
TOOLCHAIN: nightly-2021-06-15
229253
setup_script:
230254
- rustup target add $TARGET
231255
- rustup toolchain install $TOOLCHAIN --profile minimal --target $TARGET

0 commit comments

Comments
 (0)