From 002f7f0477fba006dd0d54c0b32596e0c34c6387 Mon Sep 17 00:00:00 2001 From: Juniper Tyree <50025784+juntyr@users.noreply.github.com> Date: Tue, 18 Jun 2024 05:22:26 +0000 Subject: [PATCH] Check but don't install rust toolchain in build script --- .github/workflows/main.yml | 10 ++++++++++ ci/build-wasi-preview1-component-adapter.sh | 18 ++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9f26a4cb1fd3..de0e6dbe7e3b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -793,6 +793,16 @@ jobs: - uses: actions/checkout@v4 with: submodules: true + + - name: Install Rust version + run: | + RUST_VERSION=$( \ + grep '^rust-version\s*=' crates/wasi-preview1-component-adapter/Cargo.toml | \ + sed 's/rust-version.*=.*\"\(.*\)\"/\1/' \ + ) + rustup toolchain install $RUST_VERSION --profile minimal + rustup target add wasm32-wasi wasm32-unknown-unknown --toolchain $RUST_VERSION + echo RUSTUP_TOOLCHAIN=$RUST_VERSION >> "$GITHUB_ENV" - name: Install wasm-tools run: | diff --git a/ci/build-wasi-preview1-component-adapter.sh b/ci/build-wasi-preview1-component-adapter.sh index f3d5162a0857..e10cdef0d12b 100755 --- a/ci/build-wasi-preview1-component-adapter.sh +++ b/ci/build-wasi-preview1-component-adapter.sh @@ -13,12 +13,18 @@ RUST_VERSION=$( \ sed 's/rust-version.*=.*\"\(.*\)\"/\1/' \ ) -rustup toolchain install $RUST_VERSION --profile minimal -rustup target add wasm32-wasi wasm32-unknown-unknown --toolchain $RUST_VERSION - -export RUSTUP_TOOLCHAIN=$RUST_VERSION - -cargo --version +if [[ $(rustc --version | grep $RUST_VERSION | wc -c) -eq 0 ]]; then + set +x + echo "The adapter is being built with a different Rust version than its" + echo "MSRV" + echo "" + echo " current rust version: $(rustc --version)" + echo " MSRV: $RUST_VERSION" + echo "" + echo "Please rerun this script with Rust version $RUST_VERSION, or update" + echo "the adapter's MSRV in its Cargo.toml file" + exit 1 +fi # Debug build, default features (reactor) $build_adapter