Skip to content

Commit

Permalink
Ensure that MSRV tests do not regress
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matklad committed Nov 18, 2021
1 parent 10c2a3b commit 9735c5f
Show file tree
Hide file tree
Showing 2 changed files with 355 additions and 13 deletions.
50 changes: 37 additions & 13 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ task:
- . $HOME/.cargo/env
- rustup target add i686-unknown-freebsd
- rustup component add --toolchain $TOOLCHAIN clippy
- cp Cargo.lock.msrv Cargo.lock
<< : *TEST
i386_test_script:
- . $HOME/.cargo/env
Expand All @@ -64,6 +65,7 @@ task:
- sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN
- . $HOME/.cargo/env
- rustup component add --toolchain $TOOLCHAIN clippy
- cp Cargo.lock.msrv Cargo.lock
<< : *TEST
before_cache_script: rm -rf $CARGO_HOME/registry/index

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

# Tasks for Linux native builds
task:
matrix:
- name: Rust Stable
container:
image: rust:latest
env:
TARGET: x86_64-unknown-linux-gnu
TOOLCHAIN:
- name: Linux aarch64
arm_container:
image: rust:1.46
Expand All @@ -144,6 +141,20 @@ task:
image: rust:1.46
env:
TARGET: x86_64-unknown-linux-musl
setup_script:
- rustup target add $TARGET
- rustup component add clippy
- cp Cargo.lock.msrv Cargo.lock
<< : *TEST
before_cache_script: rm -rf $CARGO_HOME/registry/index

task:
name: Rust Stable
container:
image: rust:latest
env:
TARGET: x86_64-unknown-linux-gnu
TOOLCHAIN:
setup_script:
- rustup target add $TARGET
- rustup component add clippy
Expand Down Expand Up @@ -219,13 +230,26 @@ task:
- name: NetBSD x86_64
env:
TARGET: x86_64-unknown-netbsd
- name: Redox x86_64
env:
TARGET: x86_64-unknown-redox
# Redox requires a nightly compiler.
# If stuff breaks, change nightly to the date at
# https://gitlab.redox-os.org/redox-os/redox/-/blob/master/rust-toolchain
TOOLCHAIN: nightly-2021-06-15
setup_script:
- rustup target add $TARGET
- rustup toolchain install $TOOLCHAIN --profile minimal --target $TARGET
- rustup component add --toolchain $TOOLCHAIN clippy
- cp Cargo.lock.msrv Cargo.lock
<< : *BUILD
before_cache_script: rm -rf $CARGO_HOME/registry/index

task:
container:
image: rust:1.46
env:
BUILD: check
name: Redox x86_64
env:
TARGET: x86_64-unknown-redox
# Redox requires a nightly compiler.
# If stuff breaks, change nightly to the date at
# https://gitlab.redox-os.org/redox-os/redox/-/blob/master/rust-toolchain
TOOLCHAIN: nightly-2021-06-15
setup_script:
- rustup target add $TARGET
- rustup toolchain install $TOOLCHAIN --profile minimal --target $TARGET
Expand Down

0 comments on commit 9735c5f

Please sign in to comment.