Skip to content

Commit

Permalink
Use rust-toolchain.toml to specify target and component requirements.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kpreid committed Sep 19, 2023
1 parent c60bcee commit 01ebdac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/unstable-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
5 changes: 5 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[toolchain]
channel = "stable"
targets = ["wasm32-unknown-unknown"]
profile = "minimal"
components = ["clippy", "rustfmt"]

0 comments on commit 01ebdac

Please sign in to comment.