From 1435419d8ce7695e5b29ab1720e1ef706a196cdd Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 3 Mar 2023 10:12:08 +0100 Subject: Use dtolnay/rust-toolchain instead of deprecated actions-rs Signed-off-by: Matthias Beyer --- .github/workflows/ci.yml | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a2274a..c9006c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,15 +25,12 @@ jobs: - name: Checkout sources uses: actions/checkout@v3 - name: Install toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} - override: true - uses: swatinem/rust-cache@v2 - name: cargo-check - uses: actions-rs/cargo@v1 - with: - command: check + run: cargo check deny: name: deny @@ -61,15 +58,12 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@master with: toolchain: 1.67.0 - - run: rustup component add rustfmt + components: rustfmt - name: cargo-fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check + run: cargo fmt -- --check test: @@ -85,17 +79,12 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v3 - - name: Install toolchain - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} - override: true - uses: swatinem/rust-cache@v2 - name: cargo-test - uses: actions-rs/cargo@v1 - with: - command: test - args: --all --all-features + run: cargo test --all --all-features clippy: @@ -103,12 +92,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@master with: toolchain: 1.67.0 - override: true + components: clippy - uses: swatinem/rust-cache@v2 - - run: rustup component add clippy - name: cargo-clippy run: cargo clippy --all --all-targets --all-features -- -D warnings -- cgit v1.2.3 From 4f2d692433858db7bfbc4a94471649ff0345a50b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 9 Mar 2023 10:10:03 +0100 Subject: Specify RUSTUP_TOOLCHAIN in workflow The problem here is that we are not actually using a specific rust version due to the contents of rust-toolchain.toml file, which we need for the flake.nix infrastructure. We are installing a workflow-defined rust version, but the one from the rust-toolchain file ends up being used anyway. This then conflicts with dtolnay/rust-toolchain's way to conditionally set CARGO_REGISTRIES_CRATES_IO_PROTOCOL: it checks if the toolchain being installed is (e.g.) 1.66 or 1.67 and otherwise sets the flag. This assumes that if we're installing an old version we're using that old version, and there the flag will be ignored because not yet implemented. However we end up actually using rust 1.66 and thus the flag is read and breaks our CI because it's nightly only. To fix the actual issue (running rust 1.66 instead of 1.60 for example) we can either explicitly set the toolchain in the command (`cargo +${{ matrix.rust }} check` for each command) or set the RUSTUP_TOOLCHAIN environment variable to ${{ matrix.rust }}. Both will override out rust-toolchain.toml. We opt for the latter here, for no particular reason. Thanks to @SkiFire13, who helped solving this here: https://users.rust-lang.org/t/sparse-registry-breaking-my-ci-and-i-dont-understand-why/89976/ Signed-off-by: Matthias Beyer --- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9006c9..4533c8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,11 @@ jobs: - beta # - nightly + # required because we have a different toolchain than {{ matrix.rust }} in + # rust-toolchain.toml, which we use for the flake.nix + env: + RUSTUP_TOOLCHAIN: ${{ matrix.rust }} + steps: - name: Checkout sources uses: actions/checkout@v3 @@ -56,6 +61,11 @@ jobs: name: format runs-on: ubuntu-latest + # required because we have a different toolchain in + # rust-toolchain.toml, which we use for the flake.nix + env: + RUSTUP_TOOLCHAIN: 1.67.0 + steps: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@master @@ -76,6 +86,12 @@ jobs: - stable - beta # - nightly + + # required because we have a different toolchain than {{ matrix.rust }} in + # rust-toolchain.toml, which we use for the flake.nix + env: + RUSTUP_TOOLCHAIN: ${{ matrix.rust }} + steps: - name: Checkout sources uses: actions/checkout@v3 @@ -90,6 +106,12 @@ jobs: clippy: name: clippy runs-on: ubuntu-latest + + # required because we have a different toolchain in + # rust-toolchain.toml, which we use for the flake.nix + env: + RUSTUP_TOOLCHAIN: 1.67.0 + steps: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@master -- cgit v1.2.3