From 8e023d0ab4470952222c61940d5b4252e3d99950 Mon Sep 17 00:00:00 2001 From: oddgrd <29732646+oddgrd@users.noreply.github.com> Date: Mon, 6 Mar 2023 19:10:38 +0100 Subject: [PATCH 1/4] feat: make wasm runtime dependencies optional --- runtime/Cargo.toml | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 897f97d8b..54b5dfc9e 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -11,14 +11,12 @@ name = "rocket" [[bin]] name = "next" +required-features = ["next"] [dependencies] anyhow = { workspace = true } async-trait = { workspace = true } -cap-std = "1.0.2" clap ={ version = "4.0.18", features = ["derive"] } -hyper = { version = "0.14.23", features = ["server"] } -rmp-serde = { version = "1.1.1" } thiserror = { workspace = true } tokio = { version = "1.22.0", features = ["full"] } tokio-stream = "0.1.11" @@ -26,11 +24,15 @@ tonic = { workspace = true } tracing = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } uuid = { workspace = true, features = ["v4"] } + # TODO: bump these crates to 6.0 when we bump rust to >= 1.66 -wasi-common = "4.0.0" -wasmtime = "4.0.0" -wasmtime-wasi = "4.0.0" -futures = "0.3.25" +cap-std = { version = "1.0.2", optional = true } +futures = { version = "0.3.25", optional = true } +hyper = { version = "0.14.23", features = ["server"], optional = true } +rmp-serde = { version = "1.1.1", optional = true } +wasi-common = { version = "4.0.0", optional = true } +wasmtime = { version = "4.0.0", optional = true } +wasmtime-wasi = { version = "4.0.0", optional = true } # For rocket.rs # TODO: remove @@ -47,3 +49,15 @@ workspace = true [dependencies.shuttle-service] workspace = true features = ["builder", "web-rocket"] # TODO: remove web-rocket + +[features] +next = [ + "cap-std", + "futures", + "hyper", + "rmp-serde", + "futures", + "wasi-common", + "wasmtime", + "wasmtime-wasi" +] From 939596d5774c3a7a9db34fcf3bb8493a62a739a8 Mon Sep 17 00:00:00 2001 From: oddgrd <29732646+oddgrd@users.noreply.github.com> Date: Mon, 6 Mar 2023 19:23:32 +0100 Subject: [PATCH 2/4] feat: feature gate next lib, update readme --- runtime/Cargo.toml | 5 +++-- runtime/README.md | 4 ++-- runtime/src/legacy/mod.rs | 2 +- runtime/src/lib.rs | 5 +++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 54b5dfc9e..7d0164673 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -41,7 +41,7 @@ rocket = "0.5.0-rc.2" [dependencies.shuttle-common] workspace = true -features = ["wasm", "service"] +features = ["service"] [dependencies.shuttle-proto] workspace = true @@ -59,5 +59,6 @@ next = [ "futures", "wasi-common", "wasmtime", - "wasmtime-wasi" + "wasmtime-wasi", + "shuttle-common/wasm" ] diff --git a/runtime/README.md b/runtime/README.md index d7caf894d..6299f996a 100644 --- a/runtime/README.md +++ b/runtime/README.md @@ -21,7 +21,7 @@ make axum Run the test: ```bash -cargo test axum -- --nocapture +cargo test --features next axum -- --nocapture # or, run tests make test @@ -30,7 +30,7 @@ make test Load and run: ```bash -cargo run --bin next -- --port 6001 +cargo run --features next --bin next -- --port 6001 ``` In another terminal: diff --git a/runtime/src/legacy/mod.rs b/runtime/src/legacy/mod.rs index ea042a856..a040a8640 100644 --- a/runtime/src/legacy/mod.rs +++ b/runtime/src/legacy/mod.rs @@ -11,7 +11,7 @@ use std::{ use anyhow::Context; use async_trait::async_trait; use clap::Parser; -use futures::Future; +use core::future::Future; use shuttle_common::{ storage_manager::{StorageManager, WorkingDirStorageManager}, LogItem, diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 9d241f933..33babf1c7 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1,8 +1,9 @@ mod legacy; +#[cfg(feature = "next")] mod next; mod provisioner_factory; pub use legacy::{start, Legacy}; -pub use next::AxumWasm; -pub use next::NextArgs; +#[cfg(feature = "next")] +pub use next::{AxumWasm, NextArgs}; pub use provisioner_factory::ProvisionerFactory; From 4bc5f0f334bf3576e8a275ef4e49907549922c3f Mon Sep 17 00:00:00 2001 From: oddgrd <29732646+oddgrd@users.noreply.github.com> Date: Mon, 6 Mar 2023 20:06:10 +0100 Subject: [PATCH 3/4] ci: rename loader feature in ci --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8bf6b4686..c4aa359a7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -168,7 +168,7 @@ jobs: - run: | cargo clippy --tests \ --all-targets \ - --features="codegen,loader,<< parameters.framework >>" \ + --features="codegen,builder,<< parameters.framework >>" \ --no-deps -- \ --D warnings \ -A clippy::let-unit-value \ @@ -210,10 +210,10 @@ jobs: - restore-cargo-cache - run: name: Run unit tests - command: cargo test --package shuttle-service --features="codegen,loader" --lib -- --nocapture + command: cargo test --package shuttle-service --features="codegen,builder" --lib -- --nocapture - run: name: Run integration tests - command: cargo test --package shuttle-service --features="codegen,loader" --test '*' -- --nocapture + command: cargo test --package shuttle-service --features="codegen,builder" --test '*' -- --nocapture - save-cargo-cache platform-test: parameters: From 9adc508ee301dc627a803d7b1151eeb40d7cd8e1 Mon Sep 17 00:00:00 2001 From: oddgrd <29732646+oddgrd@users.noreply.github.com> Date: Tue, 7 Mar 2023 10:03:25 +0100 Subject: [PATCH 4/4] refactor: hyper with server feature in next features --- runtime/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 7d0164673..b9b1ff8df 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -28,7 +28,7 @@ uuid = { workspace = true, features = ["v4"] } # TODO: bump these crates to 6.0 when we bump rust to >= 1.66 cap-std = { version = "1.0.2", optional = true } futures = { version = "0.3.25", optional = true } -hyper = { version = "0.14.23", features = ["server"], optional = true } +hyper = { version = "0.14.23", optional = true } rmp-serde = { version = "1.1.1", optional = true } wasi-common = { version = "4.0.0", optional = true } wasmtime = { version = "4.0.0", optional = true } @@ -54,7 +54,7 @@ features = ["builder", "web-rocket"] # TODO: remove web-rocket next = [ "cap-std", "futures", - "hyper", + "hyper/server", "rmp-serde", "futures", "wasi-common",