Skip to content

Commit

Permalink
Vendor install-rust CI action from Wasmtime (#1901)
Browse files Browse the repository at this point in the history
* Update CI workflows imported from Wasmtime

Mostly to update the auto-installation of `wasm32-wasi` to
`wasm32-wasip1` now that it's been renamed on nightly.

* Try the 27 release branch

* Try the main branch

* Vendor the install-rust action in this repo

Update it to work for wasm-tools as well
  • Loading branch information
alexcrichton authored Nov 11, 2024
1 parent 3e0dda0 commit c430ce5
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 18 deletions.
43 changes: 43 additions & 0 deletions .github/actions/install-rust/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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: Install Rust
shell: bash
id: select
run: |
# Determine MSRV as N in `1.N.0` by looking at the `rust-version`
# located in the root `Cargo.toml`.
msrv=$(grep 'rust-version.*1' Cargo.toml | sed 's/.*\.\([0-9]*\)\..*/\1/')
if [ "${{ inputs.toolchain }}" = "msrv" ]; then
echo "version=1.$msrv.0" >> "$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"
36 changes: 18 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: bytecodealliance/wasmtime/.github/actions/binary-compatible-builds@v20.0.0
- uses: ./.github/actions/install-rust
- uses: bytecodealliance/wasmtime/.github/actions/binary-compatible-builds@main
with:
name: ${{ matrix.build }}
if: matrix.build != 'wasm32-wasip1'
Expand All @@ -63,7 +63,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- name: Test (prefer-btree-collections)
run: cargo test --workspace --locked --features prefer-btree-collections

Expand All @@ -74,15 +74,15 @@ jobs:
matrix:
include:
- os: ubuntu-latest
rust: default
rust: stable
- os: ubuntu-latest
rust: beta
- os: ubuntu-latest
rust: nightly-2024-09-10
rust: nightly
- os: macos-latest
rust: default
rust: stable
- os: windows-latest
rust: default
rust: stable
- os: ubuntu-latest
rust: msrv
# skip testing crates that require wasmtime since wasmtime has a
Expand All @@ -95,15 +95,15 @@ jobs:
# test that if `RUST_BACKTRACE=1` is set in the environment that all
# tests with blessed error messages still pass.
- os: ubuntu-latest
rust: default
rust: stable
env:
RUST_BACKTRACE: 1
env: ${{ matrix.env || fromJSON('{}') }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
with:
toolchain: ${{ matrix.rust }}
- run: cargo test --locked --all ${{ matrix.flags }}
Expand All @@ -115,7 +115,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- run: cargo test --locked -p wasmparser --benches
- run: cargo test --locked -p wasm-encoder --all-features
- run: cargo test -p wasm-smith --features wasmparser
Expand All @@ -134,7 +134,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- run: cmake -S examples -B examples/build -DCMAKE_BUILD_TYPE=Release
- run: cmake --build examples/build --config Release

Expand All @@ -145,7 +145,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
with:
toolchain: 1.79.0
- run: rustup target add wasm32-wasip1
Expand All @@ -162,7 +162,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- run: rustup target add wasm32-wasip1
- run: |
tag=v10.0.1
Expand All @@ -183,7 +183,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- run: rustup component add rustfmt
- run: printf "\n" > playground/component/src/bindings.rs
# Note that this doesn't use `cargo fmt` because that doesn't format
Expand All @@ -198,7 +198,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
with:
toolchain: nightly
- run: cargo install cargo-fuzz
Expand All @@ -209,7 +209,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- run: rustup target add x86_64-unknown-none
- run: cargo check --benches -p wasm-smith
- run: cargo check --no-default-features
Expand Down Expand Up @@ -281,7 +281,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- run: rustup component add clippy
- run: cargo clippy --workspace --all-targets --exclude dl --exclude component

Expand All @@ -292,7 +292,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: bytecodealliance/wasmtime/.github/actions/install-rust@v20.0.0
- uses: ./.github/actions/install-rust
- run: rustc ci/publish.rs
# Make sure we can bump version numbers for the next release
- run: ./publish bump
Expand Down

0 comments on commit c430ce5

Please sign in to comment.