diff --git a/.github/workflows/CI.yml b/.github/workflows/ci.yml similarity index 89% rename from .github/workflows/CI.yml rename to .github/workflows/ci.yml index 169d665..d9c290f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/ci.yml @@ -42,3 +42,7 @@ jobs: - uses: actions/checkout@main - name: Run tests run: cargo test --verbose --all-features + - name: Run example + run: | + cargo run --bin example > log + grep '^Got 33$' log diff --git a/example/Cargo.toml b/example/Cargo.toml index fb2768a..f814437 100644 --- a/example/Cargo.toml +++ b/example/Cargo.toml @@ -10,5 +10,5 @@ license = "MIT" [dependencies] tokio = { version = "1.0", features = [ "full" ] } tokio-stream = { version = "0.1", features = [ "net" ] } -tonic = "0.7" -tonic-rpc = { path = "../tonic-rpc" } +tonic = "0.8" +tonic-rpc = { path = "../tonic-rpc", features = ["json"] } diff --git a/example/src/example.rs b/example/src/example.rs index cf48229..3e95a90 100644 --- a/example/src/example.rs +++ b/example/src/example.rs @@ -1,4 +1,3 @@ -#![cfg(feature = "json")] use tokio::net::TcpListener; use tokio_stream::wrappers::TcpListenerStream; use tonic::transport::Server; @@ -29,7 +28,7 @@ impl increment_server::Increment for State { } /// Run the server. -async fn run_server() { +pub(crate) async fn run_server() { let listener = TcpListener::bind("[::1]:8080").await.unwrap(); let addr = listener.local_addr().unwrap(); tokio::spawn(async move { diff --git a/example/src/main.rs b/example/src/main.rs index 021af13..d656255 100644 --- a/example/src/main.rs +++ b/example/src/main.rs @@ -1,8 +1,6 @@ -#[cfg(feature = "json")] +mod example; + #[tokio::main] async fn main() { - example::run_server() + example::run_server().await } - -#[cfg(not(feature = "json"))] -fn main() {}