From fb45ff66eb5fea2e6b7b41cdb77f6215858222c0 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 17 Feb 2021 14:55:53 +1100 Subject: [PATCH] Update rust-toolchain to new toml syntax This allows us to completely skip the "Install Rust" step in CI because the rust-toolchain file completely describes what we need. The first invocation of cargo will simply install all the required components. Additionally, we make all caches dependant on the version of Rust that we require. --- .github/workflows/ci.yml | 33 ++++----------------------------- rust-toolchain | 4 +++- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89842a1c..caaffef1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,19 +15,12 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - override: true - components: rustfmt, clippy - - name: Cache ~/.cargo/bin directory id: cargo-bin-cache uses: actions/cache@v2.1.4 with: path: ~/.cargo/bin - key: ubuntu-rust-${{ env.RUST_TOOLCHAIN }}-cargo-bin-directory-v1 + key: ubuntu-rust-${{ hashFiles('rust-toolchain') }}-cargo-bin-directory-v1 - name: Install tomlfmt if: steps.cargo-bin-cache.outputs.cache-hit != 'true' @@ -63,19 +56,13 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - override: true - - name: Cache target and registry directory uses: actions/cache@v2.1.4 with: path: | target ~/.cargo/registry - key: rust-${{ matrix.target }}-build-${{ hashFiles('Cargo.lock') }}-v1 + key: rust-${{ matrix.target }}-build-${{ hashFiles('Cargo.lock') }}-${{ hashFiles('rust-toolchain') }}-v1 - name: Build binary run: | @@ -110,19 +97,13 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - override: true - - name: Cache target and registry directory uses: actions/cache@v2.1.4 with: path: | target ~/.cargo/registry - key: rust-${{ matrix.target }}-test-${{ hashFiles('Cargo.lock') }}-v1 + key: rust-${{ matrix.target }}-test-${{ hashFiles('Cargo.lock') }}-${{ hashFiles('rust-toolchain') }}-v1 - name: Build tests run: cargo build --tests --workspace --all-features @@ -152,19 +133,13 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - override: true - - name: Cache target and registry directory uses: actions/cache@v2.1.4 with: path: | target ~/.cargo/registry - key: rust-${{ matrix.target }}-test-${{ hashFiles('Cargo.lock') }}-v1 + key: rust-${{ matrix.target }}-test-${{ hashFiles('Cargo.lock') }}-${{ hashFiles('rust-toolchain') }}-v1 - name: Run test ${{ matrix.test_name }} run: cargo test --package swap --all-features --test ${{ matrix.test_name }} "" diff --git a/rust-toolchain b/rust-toolchain index 97e6da5f..b431082c 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1,3 @@ -nightly-2021-01-31 +[toolchain] +channel = "nightly-2021-01-31" +components = ["rustfmt", "clippy"]