From 9735c5f5247bcafcdfeb3b65acd561f8d8568395 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 16 Nov 2021 13:00:59 +0300 Subject: 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. --- .cirrus.yml | 50 ++++++--- Cargo.lock.msrv | 318 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 355 insertions(+), 13 deletions(-) create mode 100644 Cargo.lock.msrv diff --git a/.cirrus.yml b/.cirrus.yml index 186443d2..a342e858 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/Cargo.lock.msrv b/Cargo.lock.msrv new file mode 100644 index 00000000..d7936db8 --- /dev/null +++ b/Cargo.lock.msrv @@ -0,0 +1,318 @@ +# This file was generated by running the following command: +# `cargo +nightly generate-lockfile -Zminimal-versions` +# We use it on CI to test non-latest-stable Rust versions. +version = 3 + +[[package]] +name = "assert-impl" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40e79d69c321c1d98eb55e4890ed07e885c071b9575960a9e742d2931581f496" + +[[package]] +name = "autocfg" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" + +[[package]] +name = "bitflags" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da1976d75adbe5fbc88130ecd119529cf1cc6a93ae1546d8696ee66f0d21af1" + +[[package]] +name = "byteorder" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8" + +[[package]] +name = "caps" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d092fbb6657fb1f98a7da70c14335ac97e5a9477e1a8156d4bbf19a3a7aece51" +dependencies = [ + "errno", + "libc", + "thiserror", +] + +[[package]] +name = "cc" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7db2f146208d7e0fbee761b09cd65a7f51ccc38705d4e7262dad4d73b12a76b1" + +[[package]] +name = "cfg-if" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "errno" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2c858c42ac0b88532f48fca88b0ed947cad4f1f64d904bcd6c9f138f7b95d70" +dependencies = [ + "kernel32-sys", + "libc", + "winapi 0.2.4", +] + +[[package]] +name = "getrandom" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4" +dependencies = [ + "cfg-if 0.1.2", + "libc", + "wasi", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad1ca084b49bfd975182288e1a5f1d27ea34ff2d6ae084ae5e66e1652427eada" +dependencies = [ + "winapi 0.2.4", + "winapi-build", +] + +[[package]] +name = "lazy_static" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" + +[[package]] +name = "libc" +version = "0.2.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103" + +[[package]] +name = "memoffset" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" +dependencies = [ + "autocfg", +] + +[[package]] +name = "nix" +version = "0.23.0" +dependencies = [ + "assert-impl", + "bitflags", + "caps", + "cc", + "cfg-if 1.0.0", + "lazy_static", + "libc", + "memoffset", + "rand", + "semver", + "sysctl", + "tempfile", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" + +[[package]] +name = "proc-macro2" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19f287c234c9b2d0308d692dee5c449c1a171167a6f8150f7cf2a49d8fd96967" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ab938ebe6f1c82426b5fb82eaf10c3e3028c53deaa3fbe38f5904b37cf4d767" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76330fb486679b4ace3670f117bbc9e16204005c4bde9c4bd372f45bed34f12" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core", +] + +[[package]] +name = "redox_syscall" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bac5c4ce99d34f37ce30e45606946fcd6331223f1c98af4d29c5b6c4977d675b" +dependencies = [ + "bitflags", +] + +[[package]] +name = "remove_dir_all" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc5b3ce5d5ea144bb04ebd093a9e14e9765bcfec866aecda9b6dec43b3d1e24" +dependencies = [ + "winapi 0.3.0", +] + +[[package]] +name = "semver" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76b5842e81eb9bbea19276a9dbbda22ac042532f390a67ab08b895617978abf3" + +[[package]] +name = "syn" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f8c8eab7d9f493cd89d4068085651d81ac7d39c56eb64f7158ea514b156e280" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "sysctl" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c7da87d95ab91294ebf2132bf36e1c4f6ac1df11db4c63105858cb175e2141c" +dependencies = [ + "byteorder", + "errno", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi 0.3.0", +] + +[[package]] +name = "thiserror" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d032db01164196ffdea5d016aa5cacd9d163a4fb00b85e9fc3ad18c5b1a3951d" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d53f5a0d2bd66d1d841e69a4beb74a226216b3f158ff0c534578f76e7beac9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "winapi" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5350e40d908c7e8b9e5c9edb541ca47cc617c6229d3575a46da6f550f36c96fd" + +[[package]] +name = "winapi" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3ad91d846a4a5342c1fb7008d26124ee6cf94a3953751618577295373b32117" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a16a8e2ebfc883e2b1771c6482b1fb3c6831eab289ba391619a2d93a7356220f" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ca29cb03c8ceaf20f8224a18a530938305e9872b1478ea24ff44b4f503a1d1d" -- cgit v1.2.3