1name: 'Install Rust toolchain' 2description: 'Install a rust toolchain' 3 4inputs: 5 toolchain: 6 description: 'Default toolchan to install' 7 required: false 8 default: 'default' 9 msrv_range: 10 description: 'Versions later-than-latest-Rust the MSRV supports' 11 required: false 12 default: '2' 13 14runs: 15 using: composite 16 steps: 17 - name: Install Rust 18 shell: bash 19 id: select 20 run: | 21 # Determine MSRV as N in `1.N.0` by looking at the `rust-version` 22 # located in the root `Cargo.toml`. 23 msrv=$(grep 'rust-version.*1' Cargo.toml | sed 's/.*\.\([0-9]*\)\..*/\1/') 24 range=${{ inputs.msrv_range }} 25 26 if [ "${{ inputs.toolchain }}" = "default" ]; then 27 echo "version=1.$((msrv+range)).0" >> "$GITHUB_OUTPUT" 28 elif [ "${{ inputs.toolchain }}" = "msrv" ]; then 29 echo "version=1.$msrv.0" >> "$GITHUB_OUTPUT" 30 elif [ "${{ inputs.toolchain }}" = "wasmtime-ci-pinned-nightly" ]; then 31 echo "version=nightly-2025-08-06" >> "$GITHUB_OUTPUT" 32 else 33 echo "version=${{ inputs.toolchain }}" >> "$GITHUB_OUTPUT" 34 fi 35 36 - name: Install Rust 37 shell: bash 38 run: | 39 rustup set profile minimal 40 rustup update "${{ steps.select.outputs.version }}" --no-self-update 41 rustup default "${{ steps.select.outputs.version }}" 42 43 # Save disk space by avoiding incremental compilation. Also turn down 44 # debuginfo from 2 to 0 to help save disk space. 45 cat >> "$GITHUB_ENV" <<EOF 46 CARGO_INCREMENTAL=0 47 CARGO_PROFILE_DEV_DEBUG=0 48 CARGO_PROFILE_TEST_DEBUG=0 49 EOF 50 51 # Deny warnings on CI to keep our code warning-free as it lands in-tree. 52 echo RUSTFLAGS="-D warnings" >> "$GITHUB_ENV" 53 54 if [[ "${{ runner.os }}" = "macOS" ]]; then 55 cat >> "$GITHUB_ENV" <<EOF 56 CARGO_PROFILE_DEV_SPLIT_DEBUGINFO=unpacked 57 CARGO_PROFILE_TEST_SPLIT_DEBUGINFO=unpacked 58 EOF 59 fi 60 61 - name: Require semicolons in WIT 62 shell: bash 63 run: echo WIT_REQUIRE_SEMICOLONS=1 >> "$GITHUB_ENV" 64 65 - name: Install the WASI target 66 shell: bash 67 run: rustup target add wasm32-wasip1 wasm32-unknown-unknown 68