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 authored and asomers committed Jan 23, 2022
1 parent f1cec51 commit 8164a0b
Show file tree
Hide file tree
Showing 2 changed files with 340 additions and 4 deletions.
26 changes: 22 additions & 4 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ task:
- fetch https://sh.rustup.rs -o rustup.sh
- sh rustup.sh -y --profile=minimal --default-toolchain 1.41.0
- $HOME/.cargo/bin/rustup target add i686-unknown-freebsd
- cp Cargo.lock.msrv Cargo.lock
amd64_test_script:
- . $HOME/.cargo/env
- cargo test
Expand Down Expand Up @@ -49,6 +50,7 @@ task:
- sh rustup.sh -y --profile=minimal --default-toolchain 1.41.0
- . $HOME/.cargo/env
- bash ci/install.sh
- cp Cargo.lock.msrv Cargo.lock
script:
- . $HOME/.cargo/env
- bash ci/script.sh
Expand Down Expand Up @@ -104,6 +106,7 @@ task:
- sh rustup.sh -y --profile=minimal --default-toolchain 1.41.0
- . $HOME/.cargo/env
- bash ci/install.sh
- cp Cargo.lock.msrv Cargo.lock
script:
- . $HOME/.cargo/env || true
- bash ci/script.sh
Expand All @@ -112,10 +115,6 @@ task:
# Tasks for Linux amd64 builds
task:
matrix:
- name: Rust Stable
env:
TARGET: x86_64-unknown-linux-gnu
TOOLCHAIN: stable
- name: Linux x86_64
env:
TARGET: x86_64-unknown-linux-gnu
Expand All @@ -126,6 +125,24 @@ task:
TOOLCHAIN: 1.41.0
container:
image: rust:1.41
setup_script:
- rustup toolchain install $TOOLCHAIN
- rustup target add --toolchain $TOOLCHAIN $TARGET
- cp Cargo.lock.msrv Cargo.lock
script:
- cargo +$TOOLCHAIN build --target $TARGET --all-targets
- cargo +$TOOLCHAIN build --target $TARGET --all-targets --release
- cargo +$TOOLCHAIN test --target $TARGET
- cargo +$TOOLCHAIN test --target $TARGET --release
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: stable
setup_script:
- rustup toolchain install $TOOLCHAIN
- rustup target add --toolchain $TOOLCHAIN $TARGET
Expand Down Expand Up @@ -176,6 +193,7 @@ task:
image: rust:1.41
setup_script:
- rustup target add $TARGET
- cp Cargo.lock.msrv Cargo.lock
script:
- cargo +$TOOLCHAIN check --target $TARGET
- cargo +$TOOLCHAIN check --target $TARGET --release
Expand Down
318 changes: 318 additions & 0 deletions Cargo.lock.msrv

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8164a0b

Please sign in to comment.