-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[23.0.0] wasi-adapter: Implement provider crate that embeds the adapt…
…er binaries (#8916) * wasi-adapter: Implement provider crate that embeds the adapter binaries [v2] (#8874) * Add wasi adapter provider template which is materialised in CI * Add rustfmt component to adapter CI * Draft an extra publish step for the adapter provider * Check adapter provider in a separate step with adapter artifacts * Use artifact downloads in the publish action as well * Record results from adapter provider step as well * Refactor to use composite actions * Add missing shell property * Fix spelling mistake * Try using the env context * Add release note --------- Co-authored-by: Juniper Tyree <50025784+juntyr@users.noreply.github.com>
- Loading branch information
1 parent
e9d340d
commit ea0aa02
Showing
12 changed files
with
181 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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 }} | ||
|
||
- name: Install required Rust components | ||
shell: bash | ||
run: rustup component add rustfmt clippy | ||
|
||
- name: Build and checl the adapter provider | ||
shell: bash | ||
run: ./ci/build-wasi-preview1-component-adapter-provider.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/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 | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/Cargo.toml |
19 changes: 19 additions & 0 deletions
19
crates/wasi-preview1-component-adapter/provider/Cargo.toml.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] |
3 changes: 3 additions & 0 deletions
3
crates/wasi-preview1-component-adapter/provider/artefacts/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/wasi_snapshot_preview1.reactor.wasm | ||
/wasi_snapshot_preview1.command.wasm | ||
/wasi_snapshot_preview1.proxy.wasm |
51 changes: 51 additions & 0 deletions
51
crates/wasi-preview1-component-adapter/provider/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); |