Skip to content

Commit

Permalink
Feature/eng 477 make wasm dependencies optional (#688)
Browse files Browse the repository at this point in the history
* feat: make wasm runtime dependencies optional

* feat: feature gate next lib, update readme

* ci: rename loader feature in ci

* refactor: hyper with server feature in next features
  • Loading branch information
oddgrd authored Mar 7, 2023
1 parent 8be4742 commit a93ba51
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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:
Expand Down
31 changes: 23 additions & 8 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,28 @@ 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"
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", 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
Expand All @@ -39,11 +41,24 @@ rocket = "0.5.0-rc.2"

[dependencies.shuttle-common]
workspace = true
features = ["wasm", "service"]
features = ["service"]

[dependencies.shuttle-proto]
workspace = true

[dependencies.shuttle-service]
workspace = true
features = ["builder", "web-rocket"] # TODO: remove web-rocket

[features]
next = [
"cap-std",
"futures",
"hyper/server",
"rmp-serde",
"futures",
"wasi-common",
"wasmtime",
"wasmtime-wasi",
"shuttle-common/wasm"
]
4 changes: 2 additions & 2 deletions runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/legacy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit a93ba51

Please sign in to comment.