name: 'Install Rust toolchain'
description: 'Install a rust toolchain'
inputs:
toolchain:
description: 'Default toolchan to install'
required: false
default: 'stable'
runs:
using: composite
steps:
- name: Select Rust
shell: bash
id: select
run: |
# Determine MSRV by looking at the `rust-version` located in the root
# `Cargo.toml`.
msrv=$(grep 'rust-version.*1' Cargo.toml | sed 's/rust-version *\= *"\([^"]*\)"/\1/')
if [ "${{ inputs.toolchain }}" = "msrv" ]; then
echo "version=$msrv" >> "$GITHUB_OUTPUT"
else
echo "version=${{ inputs.toolchain }}" >> "$GITHUB_OUTPUT"
fi
- name: Install Rust
shell: bash
run: |
rustup set profile minimal
rustup update "${{ steps.select.outputs.version }}" --no-self-update
rustup default "${{ steps.select.outputs.version }}"
# Save disk space by avoiding incremental compilation. Also turn down
# debuginfo from 2 to 0 to help save disk space.
cat >> "$GITHUB_ENV" <<EOF
CARGO_INCREMENTAL=0
CARGO_PROFILE_DEV_DEBUG=0
CARGO_PROFILE_TEST_DEBUG=0
EOF
# Deny warnings on CI to keep our code warning-free as it lands in-tree.
echo RUSTFLAGS="-D warnings" >> "$GITHUB_ENV"