From 7455066be8b857dee440b1fec0bc67d36e672613 Mon Sep 17 00:00:00 2001 From: Juniper Tyree <50025784+juntyr@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:41:27 +0000 Subject: [PATCH 01/10] Add wasi adapter provider template which is materialised in CI --- ci/build-wasi-preview1-component-adapter.sh | 32 ++++++++---- .../provider/.gitignore | 1 + .../provider/Cargo.toml.in | 19 +++++++ .../provider/artefacts/.gitignore | 3 ++ .../provider/src/lib.rs | 51 +++++++++++++++++++ 5 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 crates/wasi-preview1-component-adapter/provider/.gitignore create mode 100644 crates/wasi-preview1-component-adapter/provider/Cargo.toml.in create mode 100644 crates/wasi-preview1-component-adapter/provider/artefacts/.gitignore create mode 100644 crates/wasi-preview1-component-adapter/provider/src/lib.rs diff --git a/ci/build-wasi-preview1-component-adapter.sh b/ci/build-wasi-preview1-component-adapter.sh index 76dcbc1c167e..f0e68a6d9103 100755 --- a/ci/build-wasi-preview1-component-adapter.sh +++ b/ci/build-wasi-preview1-component-adapter.sh @@ -15,24 +15,38 @@ release="target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.wasm" $build_adapter $verify $debug +build() { + input=$1 + flavor=$2 + $verify $input + name=wasi_snapshot_preview1.$flavor.wasm + dst=$(dirname $input)/$name + provider=crates/wasi-preview1-component-adapter/provider/artefacts/$name + wasm-tools metadata add --name "wasi_preview1_component_adapter.$flavor.adapter" $input \ + -o $dst + cp $dst $provider +} + # Debug build, command $build_adapter --no-default-features --features command $verify $debug # Release build, command $build_adapter --release --no-default-features --features command -$verify $release -wasm-tools metadata add --name "wasi_preview1_component_adapter.command.adapter:${VERSION}" $release \ - -o target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.command.wasm +build $release command # Release build, default features (reactor) $build_adapter --release -$verify $release -wasm-tools metadata add --name "wasi_preview1_component_adapter.reactor.adapter:${VERSION}" $release \ - -o target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.reactor.wasm +build $release reactor # Release build, proxy $build_adapter --release --no-default-features --features proxy -$verify $release -wasm-tools metadata add --name "wasi_preview1_component_adapter.proxy.adapter:${VERSION}" $release \ - -o target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.proxy.wasm +build $release proxy + +# Add the adapter provider to the workspace +cp crates/wasi-preview1-component-adapter/provider/Cargo.toml.in crates/wasi-preview1-component-adapter/provider/Cargo.toml +sed -i '/"crates\/wasi-preview1-component-adapter",/a\ \ "crates\/wasi-preview1-component-adapter\/provider",' Cargo.toml + +cargo fmt -p wasi-preview1-component-adapter-provider -- --check +cargo check -p wasi-preview1-component-adapter-provider +cargo clippy -p wasi-preview1-component-adapter-provider diff --git a/crates/wasi-preview1-component-adapter/provider/.gitignore b/crates/wasi-preview1-component-adapter/provider/.gitignore new file mode 100644 index 000000000000..1ae47fad85cd --- /dev/null +++ b/crates/wasi-preview1-component-adapter/provider/.gitignore @@ -0,0 +1 @@ +/Cargo.toml diff --git a/crates/wasi-preview1-component-adapter/provider/Cargo.toml.in b/crates/wasi-preview1-component-adapter/provider/Cargo.toml.in new file mode 100644 index 000000000000..9f0ea47c7301 --- /dev/null +++ b/crates/wasi-preview1-component-adapter/provider/Cargo.toml.in @@ -0,0 +1,19 @@ +[package] +name = "wasi-preview1-component-adapter-provider" +version.workspace = true +authors.workspace = true +description = "Embedded wasi-preview1-component-adapter binaries" +license = "Apache-2.0 WITH LLVM-exception" +repository = "https://github.com/bytecodealliance/wasmtime" +documentation = "https://docs.rs/wasi-preview1-component-adapter-provider/" +categories = ["wasm"] +keywords = ["webassembly", "wasm"] +edition.workspace = true + +[lints] +workspace = true + +[package.metadata.docs.rs] +all-features = true + +[dependencies] diff --git a/crates/wasi-preview1-component-adapter/provider/artefacts/.gitignore b/crates/wasi-preview1-component-adapter/provider/artefacts/.gitignore new file mode 100644 index 000000000000..46be8eadbf31 --- /dev/null +++ b/crates/wasi-preview1-component-adapter/provider/artefacts/.gitignore @@ -0,0 +1,3 @@ +/wasi_snapshot_preview1.reactor.wasm +/wasi_snapshot_preview1.command.wasm +/wasi_snapshot_preview1.proxy.wasm diff --git a/crates/wasi-preview1-component-adapter/provider/src/lib.rs b/crates/wasi-preview1-component-adapter/provider/src/lib.rs new file mode 100644 index 000000000000..0783c93bdb42 --- /dev/null +++ b/crates/wasi-preview1-component-adapter/provider/src/lib.rs @@ -0,0 +1,51 @@ +//! This crate contains the binaries of three WebAssembly modules: +//! +//! - [`WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER`] +//! - [`WASI_SNAPSHOT_PREVIEW1_COMMAND_ADAPTER`] +//! - [`WASI_SNAPSHOT_PREVIEW1_PROXY_ADAPTER`] +//! +//! These three modules bridge the wasip1 ABI to the wasip2 ABI of the component +//! model. +//! +//! They can be given to the [`wit_component::ComponentEncoder::adapter`] +//! method, using the [`WASI_SNAPSHOT_PREVIEW1_ADAPTER_NAME`], to translate a +//! module from the historical WASM ABI to the canonical ABI. +//! +//! [`wit_component::ComponentEncoder::adapter`]: https://docs.rs/wit-component/latest/wit_component/struct.ComponentEncoder.html#method.adapter + +/// The name of the adapters in this crate, which may be provided to +/// [`wit_component::ComponentEncoder::adapter`]. +/// +/// [`wit_component::ComponentEncoder::adapter`]: https://docs.rs/wit-component/latest/wit_component/struct.ComponentEncoder.html#method.adapter +pub const WASI_SNAPSHOT_PREVIEW1_ADAPTER_NAME: &str = "wasi_snapshot_preview1"; + +/// The "reactor" adapter provides the default adaptation from preview1 to +/// preview2. +/// +/// This adapter implements the [`wasi:cli/imports`] world. +/// +/// [`wasi:cli/imports`]: https://github.com/WebAssembly/WASI/blob/01bb90d8b66cbc1d50349aaaab9ac5b143c9c98c/preview2/cli/imports.wit +pub const WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER: &[u8] = + include_bytes!("../artefacts/wasi_snapshot_preview1.reactor.wasm"); + +/// The "command" adapter extends the ["reactor" adapter] and additionally +/// exports a `run` function entrypoint. +/// +/// This adapter implements the [`wasi:cli/command`] world. +/// +/// ["reactor" adapter]: WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER +/// [`wasi:cli/command`]: https://github.com/WebAssembly/WASI/blob/01bb90d8b66cbc1d50349aaaab9ac5b143c9c98c/preview2/cli/command.wit +pub const WASI_SNAPSHOT_PREVIEW1_COMMAND_ADAPTER: &[u8] = + include_bytes!("../artefacts/wasi_snapshot_preview1.command.wasm"); + +/// The "proxy" adapter provides implements a HTTP proxy which is more +/// restricted than the ["reactor" adapter] adapter, as it lacks filesystem, +/// socket, environment, exit, and terminal support, but includes HTTP handlers +/// for incoming and outgoing requests. +/// +/// This adapter implements the [`wasi:http/proxy`] world. +/// +/// ["reactor" adapter]: WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER +/// [`wasi:http/proxy`]: https://github.com/WebAssembly/WASI/blob/01bb90d8b66cbc1d50349aaaab9ac5b143c9c98c/preview2/http/proxy.wit +pub const WASI_SNAPSHOT_PREVIEW1_PROXY_ADAPTER: &[u8] = + include_bytes!("../artefacts/wasi_snapshot_preview1.proxy.wasm"); From 7481af5c9947c314e2aa7fc62a5ce1588175ecb8 Mon Sep 17 00:00:00 2001 From: Juniper Tyree <50025784+juntyr@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:52:35 +0000 Subject: [PATCH 02/10] Add rustfmt component to adapter CI --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 83f915183cb3..e6bf43016e4c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -794,7 +794,9 @@ jobs: with: submodules: true - uses: ./.github/actions/install-rust - - run: rustup target add wasm32-wasi wasm32-unknown-unknown + - run: | + rustup target add wasm32-wasi wasm32-unknown-unknown + rustup component add rustfmt clippy - name: Install wasm-tools run: | From a7ccb4e93456e0e303c2302404c65267499099ac Mon Sep 17 00:00:00 2001 From: Juniper Tyree <50025784+juntyr@users.noreply.github.com> Date: Wed, 26 Jun 2024 12:31:43 +0000 Subject: [PATCH 03/10] Draft an extra publish step for the adapter provider --- .github/workflows/publish-to-cratesio.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/publish-to-cratesio.yml b/.github/workflows/publish-to-cratesio.yml index 23af15a85785..504748c28ba7 100644 --- a/.github/workflows/publish-to-cratesio.yml +++ b/.github/workflows/publish-to-cratesio.yml @@ -23,3 +23,16 @@ jobs: ./publish publish env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + - run: | + # Download the published versions of the adapters + wget https://github.com/bytecodealliance/wasmtime/releases/download/${{github.event.release.tag_name}}/wasi_snapshot_preview1.command.wasm -O crates/wasi-preview1-component-adapter/provider/artefacts/wasi_snapshot_preview1.command.wasm + wget https://github.com/bytecodealliance/wasmtime/releases/download/${{github.event.release.tag_name}}/wasi_snapshot_preview1.reactor.wasm -O crates/wasi-preview1-component-adapter/provider/artefacts/wasi_snapshot_preview1.reactor.wasm + wget https://github.com/bytecodealliance/wasmtime/releases/download/${{github.event.release.tag_name}}/wasi_snapshot_preview1.proxy.wasm -O crates/wasi-preview1-component-adapter/provider/artefacts/wasi_snapshot_preview1.proxy.wasm + + # Materialise the adapter provider crate inside the workspace + cp crates/wasi-preview1-component-adapter/provider/Cargo.toml.in crates/wasi-preview1-component-adapter/provider/Cargo.toml + sed -i '/"crates\/wasi-preview1-component-adapter",/a\ \ "crates\/wasi-preview1-component-adapter\/provider",' Cargo.toml + + cargo publish -p wasi-preview1-component-adapter-provider --allow-dirty + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} From 0d2d898e1ce552dcdbf54d8f71b5742b49618bcc Mon Sep 17 00:00:00 2001 From: Juniper Tyree <50025784+juntyr@users.noreply.github.com> Date: Thu, 27 Jun 2024 06:55:37 +0000 Subject: [PATCH 04/10] Check adapter provider in a separate step with adapter artifacts --- .github/workflows/main.yml | 31 +++++++++++++++++-- ...asi-preview1-component-adapter-provider.sh | 15 +++++++++ ci/build-wasi-preview1-component-adapter.sh | 10 ------ 3 files changed, 43 insertions(+), 13 deletions(-) create mode 100755 ci/build-wasi-preview1-component-adapter-provider.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e6bf43016e4c..ca41589b9f67 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -794,9 +794,7 @@ jobs: with: submodules: true - uses: ./.github/actions/install-rust - - run: | - rustup target add wasm32-wasi wasm32-unknown-unknown - rustup component add rustfmt clippy + - run: rustup target add wasm32-wasi wasm32-unknown-unknown - name: Install wasm-tools run: | @@ -813,6 +811,33 @@ jobs: path: target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.*.wasm + # common logic to cancel the entire run if this job fails + - run: gh run cancel ${{ github.run_id }} + if: failure() && github.event_name != 'pull_request' + env: + GH_TOKEN: ${{ github.token }} + + build-preview1-component-adapter-provider: + name: Build wasi-preview1-component-adapter-provider + needs: build-preview1-component-adapter + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: ./.github/actions/install-rust + - run: rustup component add rustfmt clippy + + - uses: actions/download-artifact@v4 + with: + name: bins-wasi-preview1-component-adapter + path: crates/wasi-preview1-component-adapter/provider/artefacts + + - run: ./ci/build-wasi-preview1-component-adapter-provider.sh + env: + CHECK: 1 + + # common logic to cancel the entire run if this job fails - run: gh run cancel ${{ github.run_id }} if: failure() && github.event_name != 'pull_request' diff --git a/ci/build-wasi-preview1-component-adapter-provider.sh b/ci/build-wasi-preview1-component-adapter-provider.sh new file mode 100755 index 000000000000..7606aff206bd --- /dev/null +++ b/ci/build-wasi-preview1-component-adapter-provider.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -ex + +# Manifest the adapter provider into the workspace +cp crates/wasi-preview1-component-adapter/provider/Cargo.toml.in crates/wasi-preview1-component-adapter/provider/Cargo.toml +sed -i '/"crates\/wasi-preview1-component-adapter",/a\ \ "crates\/wasi-preview1-component-adapter\/provider",' Cargo.toml + +set +x +if [ "$CHECK" = "1" ]; then + cargo fmt -p wasi-preview1-component-adapter-provider -- --check + cargo check -p wasi-preview1-component-adapter-provider + cargo clippy -p wasi-preview1-component-adapter-provider + cargo publish -p wasi-preview1-component-adapter-provider --dry-run --allow-dirty +fi +set -x diff --git a/ci/build-wasi-preview1-component-adapter.sh b/ci/build-wasi-preview1-component-adapter.sh index f0e68a6d9103..545a4e06f389 100755 --- a/ci/build-wasi-preview1-component-adapter.sh +++ b/ci/build-wasi-preview1-component-adapter.sh @@ -21,10 +21,8 @@ build() { $verify $input name=wasi_snapshot_preview1.$flavor.wasm dst=$(dirname $input)/$name - provider=crates/wasi-preview1-component-adapter/provider/artefacts/$name wasm-tools metadata add --name "wasi_preview1_component_adapter.$flavor.adapter" $input \ -o $dst - cp $dst $provider } # Debug build, command @@ -42,11 +40,3 @@ build $release reactor # Release build, proxy $build_adapter --release --no-default-features --features proxy build $release proxy - -# Add the adapter provider to the workspace -cp crates/wasi-preview1-component-adapter/provider/Cargo.toml.in crates/wasi-preview1-component-adapter/provider/Cargo.toml -sed -i '/"crates\/wasi-preview1-component-adapter",/a\ \ "crates\/wasi-preview1-component-adapter\/provider",' Cargo.toml - -cargo fmt -p wasi-preview1-component-adapter-provider -- --check -cargo check -p wasi-preview1-component-adapter-provider -cargo clippy -p wasi-preview1-component-adapter-provider From 8a68e58517d6ada7f04e2a596a4f22e2aa4e7701 Mon Sep 17 00:00:00 2001 From: Juniper Tyree <50025784+juntyr@users.noreply.github.com> Date: Thu, 27 Jun 2024 07:07:00 +0000 Subject: [PATCH 05/10] Use artifact downloads in the publish action as well --- .github/workflows/publish-artifacts.yml | 1 + .github/workflows/publish-to-cratesio.yml | 30 ++++++++++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/publish-artifacts.yml b/.github/workflows/publish-artifacts.yml index 9ef7e2bcb492..dd7f1997ef5b 100644 --- a/.github/workflows/publish-artifacts.yml +++ b/.github/workflows/publish-artifacts.yml @@ -16,6 +16,7 @@ jobs: - uses: actions/checkout@v4 - run: | sha=${{ github.sha }} + # Remember to update this logic in publish-to-cratesio.yml as well run_id=$( gh api -H 'Accept: application/vnd.github+json' \ /repos/${{ github.repository }}/actions/workflows/main.yml/runs\?exclude_pull_requests=true \ diff --git a/.github/workflows/publish-to-cratesio.yml b/.github/workflows/publish-to-cratesio.yml index 504748c28ba7..1f437867f5b3 100644 --- a/.github/workflows/publish-to-cratesio.yml +++ b/.github/workflows/publish-to-cratesio.yml @@ -17,22 +17,30 @@ jobs: - uses: actions/checkout@v4 with: submodules: true + - run: | + sha=${{ github.sha }} + # Remember to update this logic in publish-artifacts.yml as well + echo ARTIFACT_RUN_ID=$( + gh api -H 'Accept: application/vnd.github+json' \ + /repos/${{ github.repository }}/actions/workflows/main.yml/runs\?exclude_pull_requests=true \ + | jq '.workflow_runs' \ + | jq "map(select(.head_commit.id == \"$sha\"))[0].id" \ + ) >> "$GITHUB_ENV" - run: rustup update stable && rustup default stable - run: | rustc scripts/publish.rs ./publish publish env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - - run: | - # Download the published versions of the adapters - wget https://github.com/bytecodealliance/wasmtime/releases/download/${{github.event.release.tag_name}}/wasi_snapshot_preview1.command.wasm -O crates/wasi-preview1-component-adapter/provider/artefacts/wasi_snapshot_preview1.command.wasm - wget https://github.com/bytecodealliance/wasmtime/releases/download/${{github.event.release.tag_name}}/wasi_snapshot_preview1.reactor.wasm -O crates/wasi-preview1-component-adapter/provider/artefacts/wasi_snapshot_preview1.reactor.wasm - wget https://github.com/bytecodealliance/wasmtime/releases/download/${{github.event.release.tag_name}}/wasi_snapshot_preview1.proxy.wasm -O crates/wasi-preview1-component-adapter/provider/artefacts/wasi_snapshot_preview1.proxy.wasm - - # Materialise the adapter provider crate inside the workspace - cp crates/wasi-preview1-component-adapter/provider/Cargo.toml.in crates/wasi-preview1-component-adapter/provider/Cargo.toml - sed -i '/"crates\/wasi-preview1-component-adapter",/a\ \ "crates\/wasi-preview1-component-adapter\/provider",' Cargo.toml - - cargo publish -p wasi-preview1-component-adapter-provider --allow-dirty + + # Manifest and publish the wasi-preview1-component-adapter-provider + - uses: actions/download-artifact@v4 + with: + name: bins-wasi-preview1-component-adapter + path: crates/wasi-preview1-component-adapter/provider/artefacts + github-token: ${{ github.token }} + run-id: ${ARTIFACT_RUN_ID} + - run: ./ci/build-wasi-preview1-component-adapter-provider.sh + - run: cargo publish -p wasi-preview1-component-adapter-provider --allow-dirty env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} From fa0ad8f1049b1b93b5f2a0bad20fb7e538bae110 Mon Sep 17 00:00:00 2001 From: Juniper Tyree <50025784+juntyr@users.noreply.github.com> Date: Thu, 27 Jun 2024 08:20:26 +0000 Subject: [PATCH 06/10] Record results from adapter provider step as well --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ca41589b9f67..5cc4de7108ef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1105,6 +1105,7 @@ jobs: - determine - miri - build-preview1-component-adapter + - build-preview1-component-adapter-provider - build-wasmtime-target-wasm32 - test-min-platform-example - check_js From 98202466e7c5ad19df93ca178366d588f2501a70 Mon Sep 17 00:00:00 2001 From: Juniper Tyree <50025784+juntyr@users.noreply.github.com> Date: Fri, 28 Jun 2024 13:03:10 +0000 Subject: [PATCH 07/10] Refactor to use composite actions --- .../actions/build-adapter-provider/action.yml | 23 +++++++++++++++++++ .github/actions/fetch-run-id/action.yml | 18 +++++++++++++++ .github/workflows/main.yml | 11 ++------- .github/workflows/publish-artifacts.yml | 11 ++------- .github/workflows/publish-to-cratesio.yml | 18 +++------------ ...asi-preview1-component-adapter-provider.sh | 15 ++++++------ 6 files changed, 55 insertions(+), 41 deletions(-) create mode 100644 .github/actions/build-adapter-provider/action.yml create mode 100644 .github/actions/fetch-run-id/action.yml diff --git a/.github/actions/build-adapter-provider/action.yml b/.github/actions/build-adapter-provider/action.yml new file mode 100644 index 000000000000..9b802048dc08 --- /dev/null +++ b/.github/actions/build-adapter-provider/action.yml @@ -0,0 +1,23 @@ +name: 'Build wasi component adapter provider' +description: 'Build the wasi-preview1-component-adapter provider using the adapter artefacts' + +inputs: + run-id: + description: 'run id of the main.yml action that produced the adapter artefacts' + required: true + +runs: + using: composite + steps: + - uses: actions/download-artifact@v4 + with: + name: bins-wasi-preview1-component-adapter + path: crates/wasi-preview1-component-adapter/provider/artefacts + github-token: ${{ github.token }} + run-id: ${{ inputs.run-id }} + + - run: rustup component add rustfmt clippy + + - name: Build and checl the adapter provider + shell: bash + run: ./ci/build-wasi-preview1-component-adapter-provider.sh diff --git a/.github/actions/fetch-run-id/action.yml b/.github/actions/fetch-run-id/action.yml new file mode 100644 index 000000000000..614f2e37c64a --- /dev/null +++ b/.github/actions/fetch-run-id/action.yml @@ -0,0 +1,18 @@ +name: 'Fetch run id for commit' +description: 'Fetch the main.yml run id for the current commit' + +runs: + using: composite + steps: + - name: Fetch run id + shell: bash + run: | + run_id=$( + gh api -H 'Accept: application/vnd.github+json' \ + /repos/${{ github.repository }}/actions/workflows/main.yml/runs\?exclude_pull_requests=true \ + | jq '.workflow_runs' \ + | jq "map(select(.head_commit.id == \"${{ github.sha }}\"))[0].id" \ + ) + echo COMMIT_RUN_ID=${run_id} >> "$GITHUB_ENV" + env: + GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5cc4de7108ef..e8181b121abd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -826,16 +826,9 @@ jobs: with: submodules: true - uses: ./.github/actions/install-rust - - run: rustup component add rustfmt clippy - - - uses: actions/download-artifact@v4 + - uses: ./.github/actions/build-adapter-provider with: - name: bins-wasi-preview1-component-adapter - path: crates/wasi-preview1-component-adapter/provider/artefacts - - - run: ./ci/build-wasi-preview1-component-adapter-provider.sh - env: - CHECK: 1 + run-id: ${{ github.run_id }} # common logic to cancel the entire run if this job fails diff --git a/.github/workflows/publish-artifacts.yml b/.github/workflows/publish-artifacts.yml index dd7f1997ef5b..4a108ff083a4 100644 --- a/.github/workflows/publish-artifacts.yml +++ b/.github/workflows/publish-artifacts.yml @@ -14,16 +14,9 @@ jobs: if: github.repository == 'bytecodealliance/wasmtime' steps: - uses: actions/checkout@v4 + - uses: ./.github/actions/fetch-run-id - run: | - sha=${{ github.sha }} - # Remember to update this logic in publish-to-cratesio.yml as well - run_id=$( - gh api -H 'Accept: application/vnd.github+json' \ - /repos/${{ github.repository }}/actions/workflows/main.yml/runs\?exclude_pull_requests=true \ - | jq '.workflow_runs' \ - | jq "map(select(.head_commit.id == \"$sha\"))[0].id" \ - ) - gh run download $run_id + gh run download ${COMMIT_RUN_ID} ls find bins-* env: diff --git a/.github/workflows/publish-to-cratesio.yml b/.github/workflows/publish-to-cratesio.yml index 1f437867f5b3..c379e5a45a10 100644 --- a/.github/workflows/publish-to-cratesio.yml +++ b/.github/workflows/publish-to-cratesio.yml @@ -17,15 +17,6 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - run: | - sha=${{ github.sha }} - # Remember to update this logic in publish-artifacts.yml as well - echo ARTIFACT_RUN_ID=$( - gh api -H 'Accept: application/vnd.github+json' \ - /repos/${{ github.repository }}/actions/workflows/main.yml/runs\?exclude_pull_requests=true \ - | jq '.workflow_runs' \ - | jq "map(select(.head_commit.id == \"$sha\"))[0].id" \ - ) >> "$GITHUB_ENV" - run: rustup update stable && rustup default stable - run: | rustc scripts/publish.rs @@ -34,13 +25,10 @@ jobs: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} # Manifest and publish the wasi-preview1-component-adapter-provider - - uses: actions/download-artifact@v4 + - uses: ./.github/actions/fetch-run-id + - uses: ./.github/actions/build-adapter-provider with: - name: bins-wasi-preview1-component-adapter - path: crates/wasi-preview1-component-adapter/provider/artefacts - github-token: ${{ github.token }} - run-id: ${ARTIFACT_RUN_ID} - - run: ./ci/build-wasi-preview1-component-adapter-provider.sh + run-id: ${COMMIT_COMMIT_RUN_ID} - run: cargo publish -p wasi-preview1-component-adapter-provider --allow-dirty env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/ci/build-wasi-preview1-component-adapter-provider.sh b/ci/build-wasi-preview1-component-adapter-provider.sh index 7606aff206bd..c8c2bf4d2086 100755 --- a/ci/build-wasi-preview1-component-adapter-provider.sh +++ b/ci/build-wasi-preview1-component-adapter-provider.sh @@ -5,11 +5,10 @@ set -ex cp crates/wasi-preview1-component-adapter/provider/Cargo.toml.in crates/wasi-preview1-component-adapter/provider/Cargo.toml sed -i '/"crates\/wasi-preview1-component-adapter",/a\ \ "crates\/wasi-preview1-component-adapter\/provider",' Cargo.toml -set +x -if [ "$CHECK" = "1" ]; then - cargo fmt -p wasi-preview1-component-adapter-provider -- --check - cargo check -p wasi-preview1-component-adapter-provider - cargo clippy -p wasi-preview1-component-adapter-provider - cargo publish -p wasi-preview1-component-adapter-provider --dry-run --allow-dirty -fi -set -x +# Check the adapter provider's code formatting and style +cargo fmt -p wasi-preview1-component-adapter-provider -- --check +cargo check -p wasi-preview1-component-adapter-provider +cargo clippy -p wasi-preview1-component-adapter-provider + +# Check that publishing the adapter provider should work +cargo publish -p wasi-preview1-component-adapter-provider --dry-run --allow-dirty From 8e786640e175f9a90fd3fb51564e3327b31b8a3a Mon Sep 17 00:00:00 2001 From: Juniper Tyree <50025784+juntyr@users.noreply.github.com> Date: Fri, 28 Jun 2024 13:09:25 +0000 Subject: [PATCH 08/10] Add missing shell property --- .github/actions/build-adapter-provider/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/build-adapter-provider/action.yml b/.github/actions/build-adapter-provider/action.yml index 9b802048dc08..60b9d08a37a0 100644 --- a/.github/actions/build-adapter-provider/action.yml +++ b/.github/actions/build-adapter-provider/action.yml @@ -16,7 +16,9 @@ runs: github-token: ${{ github.token }} run-id: ${{ inputs.run-id }} - - run: rustup component add rustfmt clippy + - name: Install required Rust components + shell: bash + run: rustup component add rustfmt clippy - name: Build and checl the adapter provider shell: bash From 9b7d9b5eaf53dcec6975d9a8bd8760940651d4d0 Mon Sep 17 00:00:00 2001 From: Juniper Tyree <50025784+juntyr@users.noreply.github.com> Date: Fri, 28 Jun 2024 15:53:09 +0000 Subject: [PATCH 09/10] Fix spelling mistake --- .github/workflows/publish-to-cratesio.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-cratesio.yml b/.github/workflows/publish-to-cratesio.yml index c379e5a45a10..323dcca34edd 100644 --- a/.github/workflows/publish-to-cratesio.yml +++ b/.github/workflows/publish-to-cratesio.yml @@ -28,7 +28,7 @@ jobs: - uses: ./.github/actions/fetch-run-id - uses: ./.github/actions/build-adapter-provider with: - run-id: ${COMMIT_COMMIT_RUN_ID} + run-id: ${COMMIT_RUN_ID} - run: cargo publish -p wasi-preview1-component-adapter-provider --allow-dirty env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} From 825bd32c7129bd343b63eb0eefdc6e86f642c50f Mon Sep 17 00:00:00 2001 From: Juniper Tyree <50025784+juntyr@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:38:19 +0000 Subject: [PATCH 10/10] Try using the env context --- .github/workflows/publish-to-cratesio.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-cratesio.yml b/.github/workflows/publish-to-cratesio.yml index 323dcca34edd..46d3611a3fe6 100644 --- a/.github/workflows/publish-to-cratesio.yml +++ b/.github/workflows/publish-to-cratesio.yml @@ -28,7 +28,7 @@ jobs: - uses: ./.github/actions/fetch-run-id - uses: ./.github/actions/build-adapter-provider with: - run-id: ${COMMIT_RUN_ID} + run-id: ${{ env.COMMIT_RUN_ID }} - run: cargo publish -p wasi-preview1-component-adapter-provider --allow-dirty env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}