Skip to content

Commit 13c36fd

Browse files
No9Lazzaretti
andauthored
WASI support (#202)
* fix: use different claim for wasi Signed-off-by: Anton Whalley <[email protected]> * fix: remove main hyper Signed-off-by: Anton Whalley <[email protected]> * fix: ignore runtimes docs in wasi test Signed-off-by: Anton Whalley <[email protected]> * fix: reference attributed rust-claim Signed-off-by: Anton Whalley <[email protected]> * fix: use supported claims Signed-off-by: Anthony Whalley <[email protected]> * fix: update ticks Signed-off-by: Anton Whalley <[email protected]> * test: wasi target_os and hyper conditional Signed-off-by: Anton Whalley <[email protected]> * fix: revert toml format and param for target Signed-off-by: Anton Whalley <[email protected]> * fix: remove formatting of cargo file Signed-off-by: Fabrizio Lazzaretti <[email protected]> --------- Signed-off-by: Anton Whalley <[email protected]> Signed-off-by: Anthony Whalley <[email protected]> Signed-off-by: Fabrizio Lazzaretti <[email protected]> Co-authored-by: Fabrizio Lazzaretti <[email protected]>
1 parent a59c3f5 commit 13c36fd

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

.github/workflows/rust_tests.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,17 @@ jobs:
2222
- x86_64-unknown-linux-gnu
2323
- x86_64-unknown-linux-musl
2424
- wasm32-unknown-unknown
25+
- wasm32-wasi
2526
steps:
2627
- uses: actions/checkout@v2
2728

29+
# setup wasmedge
30+
- run: curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | sudo bash -s -- -p /usr/local
2831
# Setup musl if needed
2932
- run: sudo apt-get update
3033
if: matrix.target == 'x86_64-unknown-linux-musl'
3134
- run: sudo apt-get install -y musl musl-dev musl-tools cmake
3235
if: matrix.target == 'x86_64-unknown-linux-musl'
33-
3436
# # Caching stuff
3537
- uses: actions/cache@v2
3638
with:
@@ -96,7 +98,22 @@ jobs:
9698
command: build
9799
toolchain: ${{ matrix.toolchain }}
98100
args: --target wasm32-unknown-unknown --features reqwest
99-
101+
- uses: actions-rs/cargo@v1
102+
name: "Build"
103+
if: matrix.target == 'wasm32-wasi'
104+
with:
105+
command: build
106+
toolchain: ${{ matrix.toolchain }}
107+
args: --target ${{ matrix.target }} --features "http-binding hyper hyper_wasi"
108+
- uses: actions-rs/cargo@v1
109+
name: "Test"
110+
if: matrix.target == 'wasm32-wasi'
111+
with:
112+
command: test
113+
toolchain: ${{ matrix.toolchain }}
114+
args: --target ${{ matrix.target }} --features "http-binding hyper hyper_wasi"
115+
env:
116+
CARGO_TARGET_WASM32_WASI_RUNNER: wasmedge
100117
# Build examples
101118
- uses: actions-rs/cargo@v1
102119
name: "Build reqwest-wasm-example"

Cargo.toml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ async-trait = { version = "^0.1.33", optional = true }
5252
bytes = { version = "^1.0", optional = true }
5353
futures = { version = "^0.3", optional = true }
5454
http = { version = "0.2", optional = true }
55-
hyper = { version = "^0.14", optional = true }
5655
axum-lib = { version = "^0.6", optional = true, package="axum"}
5756
http-body = { version = "^0.4", optional = true }
5857
poem-lib = { version = "=1.2.34", optional = true, package = "poem" }
@@ -64,6 +63,12 @@ hostname = "^0.3"
6463
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
6564
web-sys = { version = "^0.3", features = ["Window", "Location"] }
6665

66+
[target.'cfg(not(target_os = "wasi"))'.dependencies]
67+
hyper = { version = "^0.14", optional = true }
68+
69+
[target.'cfg(all(target_arch = "wasm32", target_os = "wasi"))'.dependencies]
70+
hyper_wasi = { version = "0.15", features = ["full"], optional = true }
71+
6772
[dev-dependencies]
6873
rstest = "0.6"
6974
claims = "0.7.1"
@@ -72,11 +77,25 @@ serde_yaml = "0.8"
7277
rmp-serde = "1"
7378

7479
# runtime dev-deps
75-
actix-rt = { version = "^2" }
80+
7681
url = { version = "^2.1", features = ["serde"] }
7782
serde_json = { version = "^1.0" }
7883
chrono = { version = "^0.4", features = ["serde"] }
7984
mockito = "0.25.1"
80-
tokio = { version = "^1.0", features = ["full"] }
8185
mime = "0.3"
86+
87+
88+
[target.'cfg(not(target_os = "wasi"))'.dev-dependencies]
89+
actix-rt = { version = "^2" }
90+
tokio = { version = "^1.0", features = ["full"] }
8291
tower = { version = "0.4", features = ["util"] }
92+
93+
[target.'cfg(all(target_arch = "wasm32", target_os = "wasi"))'.dev-dependencies]
94+
tokio_wasi = { version = "1", features = [
95+
"io-util",
96+
"fs",
97+
"net",
98+
"time",
99+
"rt",
100+
"macros",
101+
] }

tests/version_number.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#[test]
2+
#[cfg_attr(target_os = "wasi", ignore)]
23
fn test_readme_deps() {
34
version_sync::assert_markdown_deps_updated!("README.md");
45
}
56

67
#[test]
8+
#[cfg_attr(target_os = "wasi", ignore)]
79
fn test_html_root_url() {
810
version_sync::assert_html_root_url_updated!("src/lib.rs");
911
}

0 commit comments

Comments
 (0)