-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasi-adapter: Implement provider crate that embeds the adapter binaries [v2] #8874
Changes from 6 commits
7455066
7481af5
a7ccb4e
0d2d898
8a68e58
fa0ad8f
9820246
8e78664
9b7d9b5
825bd32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this might be missing Also since this is duplicated with |
||
- run: rustup update stable && rustup default stable | ||
- run: | | ||
rustc scripts/publish.rs | ||
./publish publish | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
|
||
# 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 }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/Cargo.toml |
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] |
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 |
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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these steps be pulled into a composite action as well? That way this could be shared with the publish step, notably the configuration of the
download-artifact
step. Also I think it's ok to remove theCHECK
variable and run the same checks on publication since it's a quick-to-build crate and we can throw some more tools like clippy on the publish step.In theory that means that the publish step is:
That feels like a good state to me -- aka I like this refactoring 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this would be two new composite actions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, one for acquiring the run-id matching
github.sha
used during publish-artifacts and publish-to-cratesio. Another for verifying the adapter shared between main.yml and publish-to-cratesio