diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 0e8238f..a84761a 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -7,40 +7,65 @@ on: name: Codecov jobs: - test: - name: Test - env: - RUSTFLAGS: -C instrument-coverage + test-and-coverage: runs-on: ubuntu-latest + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: "-C instrument-coverage" + LLVM_PROFILE_FILE: "coverage-%p-%m.profraw" + steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Checkout submodules - run: git submodule update --init --recursive - - uses: actions/setup-go@v3 # we need go to build go-waku - with: - go-version: '1.20' - - uses: actions-rs/toolchain@v1 + # 1️⃣ Checkout the repo + - name: Checkout code + uses: actions/checkout@v4 + + # 2️⃣ Install Rust toolchain (nightly required for coverage) + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable with: - profile: minimal - toolchain: stable - override: true + toolchain: nightly components: llvm-tools-preview - - uses: actions-rs/cargo@v1 - continue-on-error: true - - run: | - cargo install grcov; - cargo test --all-features; - cargo test discv5_echo -- --ignored; - cargo test default_echo -- --ignored; - mkdir /tmp/cov; - grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o /tmp/cov/tests.lcov; - - uses: codecov/codecov-action@v3 + + # 3️⃣ Cache build artifacts for faster CI + - name: Cache cargo build + uses: actions/cache@v4 with: - token: ${{ secrets.CODECOV_TOKEN }} - directory: /tmp/cov/ - name: waku-bindings-codecov - fail_ci_if_error: true + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + # 4️⃣ Build and test with coverage instrumentation + - name: Run tests + run: | + cargo build --all-features + cargo test --all-features + # 5️⃣ Install grcov + - name: Install grcov + run: cargo install grcov + # 6️⃣ Generate lcov report + - name: Generate coverage report + run: | + mkdir -p coverage + grcov . \ + --binary-path ./target/debug/ \ + -s . \ + -t lcov \ + --branch \ + --ignore-not-existing \ + --ignore '../*' \ + --ignore "/*" \ + -o coverage/tests.lcov + + # 7️⃣ Upload to Codecov + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} # only needed for private repos + files: coverage/tests.lcov + fail_ci_if_error: true + flags: unittests + name: rust-codecov \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 72f97de..2143c4b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,6 +8,22 @@ on: name: CI +# Make sure cc linker is used on Linux/macOS +x-setup-linker: &setup-linker + - name: Setup linker + run: | + mkdir -p .cargo + cat > .cargo/config.toml < eframe::Result<()> { tcp_port: Some(60010), cluster_id: Some(16), shards: vec![1, 32, 64, 128, 256], + num_shards_in_network: Some(257), // node_key: Some(SecretKey::from_str("2fc0515879e52b7b73297cfd6ab3abf7c344ef84b7a90ff6f4cc19e05a198027").unwrap()), max_message_size: Some("1024KiB".to_string()), relay_topics: vec![String::from(&game_topic)], diff --git a/examples/toy-chat/src/main.rs b/examples/toy-chat/src/main.rs index e5890fd..1de0615 100644 --- a/examples/toy-chat/src/main.rs +++ b/examples/toy-chat/src/main.rs @@ -55,6 +55,7 @@ impl App { tcp_port: Some(60010), cluster_id: Some(16), shards: vec![1, 32, 64, 128, 256], + num_shards_in_network: Some(257), // node_key: Some(SecretKey::from_str("2fc0515879e52b7b73297cfd6ab3abf7c344ef84b7a90ff6f4cc19e05a198027").unwrap()), max_message_size: Some("1024KiB".to_string()), relay_topics: vec![String::from(&pubsub_topic)], diff --git a/waku-bindings/src/node/config.rs b/waku-bindings/src/node/config.rs index 6bf5fb0..e26a87e 100644 --- a/waku-bindings/src/node/config.rs +++ b/waku-bindings/src/node/config.rs @@ -28,8 +28,11 @@ pub struct WakuNodeConfig { #[default(Some(true))] pub relay: Option, pub relay_topics: Vec, - #[default(vec![1])] + #[default(vec![0])] pub shards: Vec, + #[default(Some(1))] + #[serde(rename = "numShardsInNetwork")] + pub num_shards_in_network: Option, #[serde(skip_serializing_if = "Option::is_none")] pub max_message_size: Option, diff --git a/waku-sys/vendor b/waku-sys/vendor index 4117449..d94cb7c 160000 --- a/waku-sys/vendor +++ b/waku-sys/vendor @@ -1 +1 @@ -Subproject commit 4117449b9af6c0304a6115dd4bc0d1d745159685 +Subproject commit d94cb7c73631ffd4b934839ba58bc622d331a135