From 01ebdac5b727fc7226023f9ed9f1581fe07de230 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Tue, 19 Sep 2023 10:13:05 -0700 Subject: [PATCH] Use `rust-toolchain.toml` to specify target and component requirements. This way, the requirements are automatically available to all users, not just specifically the GitHub Actions CI. A caveat is that `rustup override set` ignores the file entirely, so in order to change toolchains we have to patch the file instead of using the override command. Still seems better overall. --- .github/workflows/ci.yml | 11 ++++++----- .github/workflows/unstable-ci.yml | 12 ++++-------- rust-toolchain.toml | 5 +++++ 3 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 430155721..5cc26612c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,12 +92,13 @@ jobs: - run: df -h . - - name: Install Rust toolchain - # Install exactly what we need: compiler, Cargo, clippy, rustfmt + - name: Set Rust toolchain + # The rust-toolchain.toml file specifies the targets and components we need, + # but we may want to override the toolchain. + if: ${{ matrix.toolchain != 'stable' }} run: | - rustup toolchain install "${{ matrix.toolchain }}" --profile=minimal --component=clippy --component=rustfmt - rustup target add --toolchain="${{ matrix.toolchain }}" wasm32-unknown-unknown - rustup override set "${{ matrix.toolchain }}" + sed -i "s/stable/${{ matrix.toolchain }}/" rust-toolchain.toml + rustup show # triggers installation of selected toolchain - name: Install nightly for -Z direct-minimal-versions if: ${{ matrix.depversions == 'minimal' }} diff --git a/.github/workflows/unstable-ci.yml b/.github/workflows/unstable-ci.yml index 9cfcd5e07..49cd1e0b4 100644 --- a/.github/workflows/unstable-ci.yml +++ b/.github/workflows/unstable-ci.yml @@ -63,16 +63,12 @@ jobs: with: ref: unstable-rust - - name: Install Rust toolchain - # Install exactly what we need: compiler, Cargo, clippy, rustfmt + - name: Set Rust toolchain + # The rust-toolchain.toml file specifies the targets and components we need. + # Therefore, CI only needs to set the toolchain override. run: | - rustup toolchain install "${{ matrix.toolchain }}" --profile=minimal --component=clippy --component=rustfmt - rustup target add --toolchain="${{ matrix.toolchain }}" wasm32-unknown-unknown rustup override set "${{ matrix.toolchain }}" - - - name: Install nightly too - if: ${{ matrix.depversions == 'minimal' }} - run: rustup toolchain install nightly --profile=minimal + rustup show # triggers installation of selected toolchain - name: Install native libraries if: ${{ runner.os == 'Linux' }} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 000000000..a01bbcd6c --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,5 @@ +[toolchain] +channel = "stable" +targets = ["wasm32-unknown-unknown"] +profile = "minimal" +components = ["clippy", "rustfmt"]