|
| 1 | +name: 'Install Rust toolchain' |
| 2 | +description: 'Install a rust toolchain' |
| 3 | + |
| 4 | +inputs: |
| 5 | + toolchain: |
| 6 | + description: 'Default toolchan to install' |
| 7 | + required: false |
| 8 | + default: 'stable' |
| 9 | + |
| 10 | +runs: |
| 11 | + using: composite |
| 12 | + steps: |
| 13 | + - name: Install Rust |
| 14 | + shell: bash |
| 15 | + id: select |
| 16 | + run: | |
| 17 | + # Determine MSRV as N in `1.N.0` by looking at the `rust-version` |
| 18 | + # located in the root `Cargo.toml`. |
| 19 | + msrv=$(grep 'rust-version.*1' Cargo.toml | sed 's/.*\.\([0-9]*\)\..*/\1/') |
| 20 | +
|
| 21 | + if [ "${{ inputs.toolchain }}" = "msrv" ]; then |
| 22 | + echo "version=1.$msrv.0" >> "$GITHUB_OUTPUT" |
| 23 | + else |
| 24 | + echo "version=${{ inputs.toolchain }}" >> "$GITHUB_OUTPUT" |
| 25 | + fi |
| 26 | +
|
| 27 | + - name: Install Rust |
| 28 | + shell: bash |
| 29 | + run: | |
| 30 | + rustup set profile minimal |
| 31 | + rustup update "${{ steps.select.outputs.version }}" --no-self-update |
| 32 | + rustup default "${{ steps.select.outputs.version }}" |
| 33 | +
|
| 34 | + # Save disk space by avoiding incremental compilation. Also turn down |
| 35 | + # debuginfo from 2 to 0 to help save disk space. |
| 36 | + cat >> "$GITHUB_ENV" <<EOF |
| 37 | + CARGO_INCREMENTAL=0 |
| 38 | + CARGO_PROFILE_DEV_DEBUG=0 |
| 39 | + CARGO_PROFILE_TEST_DEBUG=0 |
| 40 | + EOF |
| 41 | +
|
| 42 | + # Deny warnings on CI to keep our code warning-free as it lands in-tree. |
| 43 | + echo RUSTFLAGS="-D warnings" >> "$GITHUB_ENV" |
| 44 | +
|
| 45 | + - run: rustup target add wasm32-wasip2 |
| 46 | + if: inputs.toolchain != 'msrv' |
| 47 | + shell: bash |
| 48 | + |
| 49 | + - run: | |
| 50 | + curl -L -o wasi-sdk.tar.gz https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-linux.tar.gz |
| 51 | + tar xf wasi-sdk.tar.gz |
| 52 | + echo "WASI_SDK_PATH=`pwd`/wasi-sdk-27.0-x86_64-linux" >> $GITHUB_ENV |
| 53 | + if: runner.os == 'Linux' |
| 54 | + shell: bash |
| 55 | + working-directory: ${{ runner.tool_cache }} |
| 56 | + - run: | |
| 57 | + curl -L -o wasi-sdk.tar.gz https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-macos.tar.gz |
| 58 | + tar xf wasi-sdk.tar.gz |
| 59 | + echo "WASI_SDK_PATH=`pwd`/wasi-sdk-27.0-x86_64-macos" >> $GITHUB_ENV |
| 60 | + if: runner.os == 'macOS' |
| 61 | + shell: bash |
| 62 | + working-directory: ${{ runner.tool_cache }} |
| 63 | + - run: | |
| 64 | + curl -L -o wasi-sdk.tar.gz https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-windows.tar.gz |
| 65 | + tar xf wasi-sdk.tar.gz |
| 66 | + echo "WASI_SDK_PATH=`pwd`/wasi-sdk-27.0-x86_64-windows" >> $GITHUB_ENV |
| 67 | + if: runner.os == 'Windows' |
| 68 | + shell: bash |
| 69 | + working-directory: ${{ runner.tool_cache }} |
| 70 | + - name: Setup `wasmtime` |
| 71 | + uses: bytecodealliance/actions/wasmtime/setup@v1 |
| 72 | + with: |
| 73 | + version: "v40.0.0" |
0 commit comments