From 616ae13509ce915b2f0882ff4f083197cfc93a55 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Sun, 30 Jan 2022 10:07:31 -0800 Subject: [PATCH] chore: make it easier to pin Rust versions in CI (#4448) When backporting patches to LTS branches, we often run into CI failures due to changes in rust. Newer rust versions add more lints, which break CI. We really don't want to also have to backport patches that fix CI, so instead, LTS branches should pin the stable rust version in CI (e.g. #4434). This PR restructures the CI config files to make it a bit easier to set a specific rust version in CI. --- .cirrus.yml | 8 ++- .github/workflows/ci.yml | 109 +++++++++++++++++++----------- .github/workflows/loom.yml | 9 ++- .github/workflows/stress-test.yml | 13 +++- 4 files changed, 91 insertions(+), 48 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 4bef869c24f..8e3665ee2aa 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,6 +1,8 @@ freebsd_instance: image: freebsd-12-2-release-amd64 env: + RUST_STABLE: 1.52.0 + RUST_NIGHTLY: nightly-2021-10-25 RUSTFLAGS: -D warnings # Test FreeBSD in a full VM on cirrus-ci.com. Test the i686 target too, in the @@ -12,7 +14,7 @@ task: setup_script: - pkg install -y bash curl - curl https://sh.rustup.rs -sSf --output rustup.sh - - sh rustup.sh -y --profile minimal --default-toolchain stable + - sh rustup.sh -y --profile minimal --default-toolchain $RUST_STABLE - . $HOME/.cargo/env - | echo "~~~~ rustc --version ~~~~" @@ -29,7 +31,7 @@ task: setup_script: - pkg install -y bash curl - curl https://sh.rustup.rs -sSf --output rustup.sh - - sh rustup.sh -y --profile minimal --default-toolchain nightly-2021-10-25 + - sh rustup.sh -y --profile minimal --default-toolchain $RUST_NIGHTLY - . $HOME/.cargo/env - | echo "~~~~ rustc --version ~~~~" @@ -43,7 +45,7 @@ task: setup_script: - pkg install -y bash curl - curl https://sh.rustup.rs -sSf --output rustup.sh - - sh rustup.sh -y --profile minimal --default-toolchain stable + - sh rustup.sh -y --profile minimal --default-toolchain $RUST_STABLE - . $HOME/.cargo/env - rustup target add i686-unknown-freebsd - | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9fec5837e3c..d5ae4d7c61f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,15 @@ env: RUSTFLAGS: -Dwarnings RUST_BACKTRACE: 1 nightly: nightly-2021-10-25 - minrust: 1.45.2 + # Change to specific Rust release to pin + rust_stable: 1.56.0 + rust_nightly: nightly-2021-10-25 + rust_clippy: 1.52.0 + rust_min: 1.45.2 + +defaults: + run: + shell: bash jobs: # Depends on all action sthat are required for a "successful" CI run. @@ -44,6 +52,11 @@ jobs: - macos-latest steps: - uses: actions/checkout@v2 + - name: Install Rust ${{ env.rust_stable }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.rust_stable }} + override: true - name: Install Rust run: rustup update stable - uses: Swatinem/rust-cache@v1 @@ -82,8 +95,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install Rust - run: rustup update stable + - name: Install Rust ${{ env.rust_stable }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.rust_stable }} + override: true - uses: Swatinem/rust-cache@v1 - name: Install Valgrind @@ -120,10 +136,12 @@ jobs: - macos-latest steps: - uses: actions/checkout@v2 - - name: Install Rust - run: rustup update stable + - name: Install Rust ${{ env.rust_stable }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.rust_stable }} + override: true - uses: Swatinem/rust-cache@v1 - # Run `tokio` with "unstable" cfg flag. - name: test tokio full --cfg unstable run: cargo test --all-features @@ -136,29 +154,29 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - name: Install Rust ${{ env.rust_nightly }} + uses: actions-rs/toolchain@v1 with: - toolchain: ${{ env.nightly }} + toolchain: ${{ env.rust_nightly }} + components: miri override: true - uses: Swatinem/rust-cache@v1 - - name: Install Miri + - name: miri run: | set -e - rustup component add miri - cargo miri setup - rm -rf tokio/tests - - - name: miri - run: cargo miri test --features rt,rt-multi-thread,sync task + rm -rf tests + cargo miri test --features rt,rt-multi-thread,sync task working-directory: tokio + san: name: san runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - name: Install Rust ${{ env.rust_nightly }} + uses: actions-rs/toolchain@v1 with: - toolchain: ${{ env.nightly }} + toolchain: ${{ env.rust_nightly }} override: true - uses: Swatinem/rust-cache@v1 - name: asan @@ -181,9 +199,10 @@ jobs: - arm-linux-androideabi steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - name: Install Rust ${{ env.rust_stable }} + uses: actions-rs/toolchain@v1 with: - toolchain: stable + toolchain: ${{ env.rust_stable }} target: ${{ matrix.target }} override: true - uses: Swatinem/rust-cache@v1 @@ -198,17 +217,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - name: Install Rust ${{ env.rust_nightly }} + uses: actions-rs/toolchain@v1 with: - toolchain: ${{ env.nightly }} + toolchain: ${{ env.rust_nightly }} + target: ${{ matrix.target }} override: true - uses: Swatinem/rust-cache@v1 - name: Install cargo-hack run: cargo install cargo-hack - - name: check --each-feature run: cargo hack check --all --each-feature -Z avoid-dev-deps - # Try with unstable feature flags - name: check --each-feature --unstable run: cargo hack check --all --each-feature -Z avoid-dev-deps @@ -220,9 +239,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - name: Install Rust ${{ env.rust_min }} + uses: actions-rs/toolchain@v1 with: - toolchain: ${{ env.minrust }} + toolchain: ${{ env.rust_min }} override: true - uses: Swatinem/rust-cache@v1 - name: "test --workspace --all-features" @@ -233,9 +253,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - name: Install Rust ${{ env.rust_nightly }} + uses: actions-rs/toolchain@v1 with: - toolchain: ${{ env.nightly }} + toolchain: ${{ env.rust_nightly }} override: true - uses: Swatinem/rust-cache@v1 - name: Install cargo-hack @@ -264,12 +285,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install Rust - run: rustup update stable + - name: Install Rust ${{ env.rust_stable }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.rust_stable }} + override: true + components: rustfmt - uses: Swatinem/rust-cache@v1 - - name: Install rustfmt - run: rustup component add rustfmt - # Check fmt - name: "rustfmt --check" # Workaround for rust-lang/cargo#7732 @@ -284,12 +306,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install Rust - run: rustup update 1.52.1 && rustup default 1.52.1 + - name: Install Rust ${{ env.rust_clippy }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.rust_clippy }} + override: true + components: clippy - uses: Swatinem/rust-cache@v1 - - name: Install clippy - run: rustup component add clippy - # Run clippy - name: "clippy --all" run: cargo clippy --all --tests --all-features @@ -299,9 +322,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - name: Install Rust ${{ env.rust_nightly }} + uses: actions-rs/toolchain@v1 with: - toolchain: ${{ env.nightly }} + toolchain: ${{ env.rust_nightly }} override: true - uses: Swatinem/rust-cache@v1 - name: "doc --lib --all-features" @@ -315,8 +339,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install Rust - run: rustup update stable + - name: Install Rust ${{ env.rust_stable }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.rust_stable }} + override: true - uses: Swatinem/rust-cache@v1 - name: build --cfg loom run: cargo test --no-run --lib --features full diff --git a/.github/workflows/loom.yml b/.github/workflows/loom.yml index fde9f1114e1..31a8025102e 100644 --- a/.github/workflows/loom.yml +++ b/.github/workflows/loom.yml @@ -10,6 +10,8 @@ name: Loom env: RUSTFLAGS: -Dwarnings RUST_BACKTRACE: 1 + # Change to specific Rust release to pin + rust_stable: 1.52.0 jobs: loom: @@ -28,8 +30,11 @@ jobs: - time::driver steps: - uses: actions/checkout@v2 - - name: Install Rust - run: rustup update stable + - name: Install Rust ${{ env.rust_stable }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.rust_stable }} + override: true - uses: Swatinem/rust-cache@v1 - name: loom ${{ matrix.scope }} run: cargo test --lib --release --features full -- --nocapture $SCOPE diff --git a/.github/workflows/stress-test.yml b/.github/workflows/stress-test.yml index 3619d419742..a6a24fdea14 100644 --- a/.github/workflows/stress-test.yml +++ b/.github/workflows/stress-test.yml @@ -5,6 +5,12 @@ on: branches: - master +env: + RUSTFLAGS: -Dwarnings + RUST_BACKTRACE: 1 + # Change to specific Rust release to pin + rust_stable: stable + jobs: stess-test: name: Stress Test @@ -15,8 +21,11 @@ jobs: - simple_echo_tcp steps: - uses: actions/checkout@v2 - - name: Install Rust - run: rustup update stable + - name: Install Rust ${{ env.rust_stable }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.rust_stable }} + override: true - uses: Swatinem/rust-cache@v1 - name: Install Valgrind run: |