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 env: 21 # This is an attempt to reduce flakiness and see what happens. If this 22 # lands it worked. Feel free to modify if this becomes flaky again. 23 RUSTUP_USE_CURL: 1 24 run: | 25 # Determine MSRV as N in `1.N.0` by looking at the `rust-version` 26 # located in the root `Cargo.toml`. 27 msrv=$(grep 'rust-version.*1' Cargo.toml | sed 's/.*\.\([0-9]*\)\..*/\1/') 28 range=${{ inputs.msrv_range }} 29 30 if [ "${{ inputs.toolchain }}" = "default" ]; then 31 echo "version=1.$((msrv+range)).0" >> "$GITHUB_OUTPUT" 32 elif [ "${{ inputs.toolchain }}" = "msrv" ]; then 33 echo "version=1.$msrv.0" >> "$GITHUB_OUTPUT" 34 elif [ "${{ inputs.toolchain }}" = "wasmtime-ci-pinned-nightly" ]; then 35 echo "version=nightly-2026-01-26" >> "$GITHUB_OUTPUT" 36 elif [ "${{ inputs.toolchain }}" = "wasmtime-ci-oss-fuzz-pin" ]; then 37 # Do not change this number unless OSS-Fuzz has updated. If you update 38 # this version and do not update OSS-Fuzz then you will break our 39 # fuzzer build. Update OSS-Fuzz first, wait for that, then land the PR 40 # in Wasmtime that needs to update this. 41 echo "version=nightly-2026-01-28" >> "$GITHUB_OUTPUT" 42 else 43 echo "version=${{ inputs.toolchain }}" >> "$GITHUB_OUTPUT" 44 fi 45 46 - name: Install Rust 47 shell: bash 48 run: | 49 rustup set profile minimal 50 for attempt in 1 2 3 4 5; do 51 [ "$attempt" = "5" ] && exit 1 52 rustup update "${{ steps.select.outputs.version }}" --no-self-update \ 53 && break 54 sleep 5 55 done 56 rustup default "${{ steps.select.outputs.version }}" 57 58 # Save disk space by avoiding incremental compilation. Also turn down 59 # debuginfo from 2 to 0 to help save disk space. 60 cat >> "$GITHUB_ENV" <<EOF 61 CARGO_INCREMENTAL=0 62 CARGO_PROFILE_DEV_DEBUG=0 63 CARGO_PROFILE_TEST_DEBUG=0 64 EOF 65 66 # Deny warnings on CI to keep our code warning-free as it lands in-tree. 67 echo RUSTFLAGS="-D warnings $RUSTFLAGS" >> "$GITHUB_ENV" 68 69 if [[ "${{ runner.os }}" = "macOS" ]]; then 70 cat >> "$GITHUB_ENV" <<EOF 71 CARGO_PROFILE_DEV_SPLIT_DEBUGINFO=unpacked 72 CARGO_PROFILE_TEST_SPLIT_DEBUGINFO=unpacked 73 EOF 74 fi 75 76 - name: Require semicolons in WIT 77 shell: bash 78 run: echo WIT_REQUIRE_SEMICOLONS=1 >> "$GITHUB_ENV" 79 80 - name: Install the WASI target 81 shell: bash 82 run: rustup target add wasm32-wasip1 wasm32-unknown-unknown 83