From 86f0bd04bbe2c68e3a3f926e77fc08dc1232c2b9 Mon Sep 17 00:00:00 2001 From: Frando Date: Wed, 7 May 2025 08:43:59 +0200 Subject: [PATCH 1/3] chore: expand CI workflows to build no-default-features and wasm --- .github/workflows/ci.yml | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67d2bef..85bdbe0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,8 +58,12 @@ jobs: toolchain: ${{ matrix.channel }} targets: ${{ matrix.target.toolchain }} - uses: swatinem/rust-cache@v2 - - name: cargo test + - name: cargo test (all features) run: cargo test --locked --workspace --all-features --bins --tests --examples + - name: cargo test (default features) + run: cargo test --locked --workspace --bins --tests --examples + - name: cargo test (no default features) + run: cargo test --locked --workspace --no-default-features --bins --tests --examples test-release: runs-on: ${{ matrix.target.os }} @@ -91,6 +95,27 @@ jobs: - uses: swatinem/rust-cache@v2 - name: cargo test run: cargo test --release --locked --workspace --all-features --bins --tests --examples + + wasm_build: + name: Build wasm32 + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Install stable toolchain + uses: dtolnay/rust-toolchain@stable + - name: Add wasm target + run: rustup target add wasm32-unknown-unknown + - name: Install wasm-tools + uses: bytecodealliance/actions/wasm-tools/setup@v1 + - name: wasm32 build + run: cargo build --target wasm32-unknown-unknown + # If the Wasm file contains any 'import "env"' declarations, then + # some non-Wasm-compatible code made it into the final code. + - name: Ensure no 'import "env"' in iroh-relay Wasm + run: | + ! wasm-tools print --skeleton target/wasm32-unknown-unknown/debug/irpc.wasm | grep 'import "env"' + # Checks correct runtime deps and features are requested by not including dev-dependencies. check-deps: From 8ef52df3b65d8ae0e34e8c9eba48e00e34f0b02f Mon Sep 17 00:00:00 2001 From: Frando Date: Wed, 7 May 2025 08:44:09 +0200 Subject: [PATCH 2/3] fix: build on wasm32-unknown-unknown --- Cargo.toml | 4 ++-- src/lib.rs | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index aac3d4d..75519f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ anyhow = { workspace = true, optional = true } # used in the benches futures-buffered ={ version = "0.2.9", optional = true } # for AbortOnDropHandle -n0-future = { workspace = true, optional = true } +n0-future = { workspace = true } futures-util = { workspace = true, optional = true } [target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dependencies] @@ -60,7 +60,7 @@ trybuild = "1.0.104" [features] # enable the remote transport -rpc = ["dep:quinn", "dep:postcard", "dep:anyhow", "dep:smallvec", "dep:tracing", "dep:n0-future", "tokio/io-util"] +rpc = ["dep:quinn", "dep:postcard", "dep:anyhow", "dep:smallvec", "dep:tracing", "tokio/io-util"] # add test utilities quinn_endpoint_setup = ["rpc", "dep:rustls", "dep:rcgen", "dep:anyhow", "dep:futures-buffered", "quinn/rustls-ring"] # pick up parent span when creating channel messages diff --git a/src/lib.rs b/src/lib.rs index 9198eef..a458ffc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -78,7 +78,6 @@ #![cfg_attr(quicrpc_docsrs, feature(doc_cfg))] use std::{fmt::Debug, future::Future, io, marker::PhantomData, ops::Deref}; -use n0_future::boxed::BoxFuture; use sealed::Sealed; use serde::{de::DeserializeOwned, Serialize}; @@ -141,7 +140,7 @@ pub mod channel { pub mod oneshot { use std::{fmt::Debug, future::Future, io, pin::Pin, task}; - use n0_future::boxed::BoxFuture; + use n0_future::future::Boxed as BoxFuture; use super::{RecvError, SendError}; use crate::util::FusedOneshotReceiver; @@ -179,7 +178,7 @@ pub mod channel { /// Remote receivers are always boxed, since for remote communication the boxing /// overhead is negligible. However, boxing can also be used for local communication, /// e.g. when applying a transform or filter to the message before receiving it. - pub type BoxedReceiver = crate::BoxFuture>; + pub type BoxedReceiver = BoxFuture>; /// A oneshot sender. /// @@ -1093,7 +1092,7 @@ pub mod rpc { //! Module for cross-process RPC using [`quinn`]. use std::{fmt::Debug, future::Future, io, marker::PhantomData, pin::Pin, sync::Arc}; - use n0_future::task::JoinSet; + use n0_future::{future::Boxed as BoxFuture, task::JoinSet}; use quinn::ConnectionError; use serde::{de::DeserializeOwned, Serialize}; use smallvec::SmallVec; @@ -1107,7 +1106,7 @@ pub mod rpc { RecvError, SendError, }, util::{now_or_never, AsyncReadVarintExt, WriteVarintExt}, - BoxFuture, RequestError, RpcMessage, + RequestError, RpcMessage, }; /// Error that can occur when writing the initial message when doing a From 85e5e905ae945289867561347a5ce91738a5b578 Mon Sep 17 00:00:00 2001 From: Frando Date: Wed, 7 May 2025 09:03:06 +0200 Subject: [PATCH 3/3] fix: feauture dependencies --- .github/workflows/ci.yml | 44 +++++++++++++++++++++------------------- Cargo.toml | 2 +- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85bdbe0..8582900 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,6 @@ on: branches: - main - concurrency: group: tests-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true @@ -64,6 +63,10 @@ jobs: run: cargo test --locked --workspace --bins --tests --examples - name: cargo test (no default features) run: cargo test --locked --workspace --no-default-features --bins --tests --examples + - name: cargo check (feature message_spans) + run: cargo check --no-default-features --features message_spans + - name: cargo check (feature rpc) + run: cargo check --no-default-features --features rpc test-release: runs-on: ${{ matrix.target.os }} @@ -95,27 +98,26 @@ jobs: - uses: swatinem/rust-cache@v2 - name: cargo test run: cargo test --release --locked --workspace --all-features --bins --tests --examples - - wasm_build: - name: Build wasm32 - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - name: Install stable toolchain - uses: dtolnay/rust-toolchain@stable - - name: Add wasm target - run: rustup target add wasm32-unknown-unknown - - name: Install wasm-tools - uses: bytecodealliance/actions/wasm-tools/setup@v1 - - name: wasm32 build - run: cargo build --target wasm32-unknown-unknown - # If the Wasm file contains any 'import "env"' declarations, then - # some non-Wasm-compatible code made it into the final code. - - name: Ensure no 'import "env"' in iroh-relay Wasm - run: | - ! wasm-tools print --skeleton target/wasm32-unknown-unknown/debug/irpc.wasm | grep 'import "env"' + wasm_build: + name: Build wasm32 + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Install stable toolchain + uses: dtolnay/rust-toolchain@stable + - name: Add wasm target + run: rustup target add wasm32-unknown-unknown + - name: Install wasm-tools + uses: bytecodealliance/actions/wasm-tools/setup@v1 + - name: wasm32 build + run: cargo build --target wasm32-unknown-unknown + # If the Wasm file contains any 'import "env"' declarations, then + # some non-Wasm-compatible code made it into the final code. + - name: Ensure no 'import "env"' in iroh-relay Wasm + run: | + ! wasm-tools print --skeleton target/wasm32-unknown-unknown/debug/irpc.wasm | grep 'import "env"' # Checks correct runtime deps and features are requested by not including dev-dependencies. check-deps: diff --git a/Cargo.toml b/Cargo.toml index 75519f1..5ff9b5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,7 +64,7 @@ rpc = ["dep:quinn", "dep:postcard", "dep:anyhow", "dep:smallvec", "dep:tracing", # add test utilities quinn_endpoint_setup = ["rpc", "dep:rustls", "dep:rcgen", "dep:anyhow", "dep:futures-buffered", "quinn/rustls-ring"] # pick up parent span when creating channel messages -message_spans = [] +message_spans = ["dep:tracing"] stream = ["dep:futures-util"] default = ["rpc", "quinn_endpoint_setup", "message_spans", "stream"]