From fec55c6c2937e107f34632998479c01aa94ecd9f Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 11 Sep 2025 12:11:26 +0200 Subject: [PATCH 1/9] ci up --- .github/workflows/ci.yml | 78 ++++++++++++++++++++++++++++ .github/workflows/test.yml | 34 ++++++++++++ examples/historical_scanning/main.rs | 4 +- 3 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..13cabf24 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,78 @@ +name: "CI" + +on: + pull_request: + merge_group: + push: + branches: [main] + +env: + CARGO_TERM_COLOR: always + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + cargo-build: + name: Cargo Build + runs-on: ubuntu-latest + + steps: + - name: Fetch Repository + uses: actions/checkout@v5 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: cargo build + run: cargo b --workspace --all-targets --all-features + + cargo-fmt: + name: Cargo fmt + runs-on: ubuntu-latest + + steps: + - name: Fetch Repository + uses: actions/checkout@v5 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + toolchain: nightly + + - name: Rustfmt Check + run: cargo fmt --all --check + + cargo-clippy: + name: Cargo clippy + runs-on: ubuntu-latest + + steps: + - name: Fetch Repository + uses: actions/checkout@v5 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy + + - name: Clippy Check + run: cargo clippy --workspace --all-targets --all-features -- -D warnings + + typos-cli: + name: typos + runs-on: ubuntu-latest + + steps: + - name: Fetch Repository + uses: actions/checkout@v5 + + - name: Install Typos + uses: taiki-e/install-action@v2 + with: + tool: typos-cli + + - name: run typos + run: typos diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..55a793e0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,34 @@ +name: tests + +on: + pull_request: + merge_group: + push: + branches: [main] + +env: + CARGO_TERM_COLOR: always + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + cargo-next-test: + name: Cargo test + runs-on: ubuntu-latest + + steps: + - name: Fetch Repository + uses: actions/checkout@v5 + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install cargo-nextest + uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest + + - name: Cargo test + run: cargo nextest run --workspace --all-targets --all-features --no-tests=pass diff --git a/examples/historical_scanning/main.rs b/examples/historical_scanning/main.rs index c11e6bf3..827fe646 100644 --- a/examples/historical_scanning/main.rs +++ b/examples/historical_scanning/main.rs @@ -1,6 +1,6 @@ use std::{sync::Arc, time::Duration}; -use alloy::providers::{ProviderBuilder}; +use alloy::providers::ProviderBuilder; use alloy::rpc::types::Log; use alloy::sol; use alloy::sol_types::SolEvent; @@ -65,7 +65,7 @@ async fn main() -> anyhow::Result<()> { callback: Arc::new(CounterCallback), }; - counter_contract.increase().send().await?; + let _ = counter_contract.increase().send().await?.get_receipt().await?; let mut scanner = ScannerBuilder::new(anvil.ws_endpoint_url()) .add_event_filter(increase_filter) From b40c896f93b12f91e13cd5840666054d11f27353 Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 11 Sep 2025 12:41:36 +0200 Subject: [PATCH 2/9] format --- examples/historical_scanning/main.rs | 5 +---- examples/simple_counter/main.rs | 5 +---- src/lib.rs | 10 ++++++---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/examples/historical_scanning/main.rs b/examples/historical_scanning/main.rs index 827fe646..9c1db196 100644 --- a/examples/historical_scanning/main.rs +++ b/examples/historical_scanning/main.rs @@ -1,9 +1,6 @@ use std::{sync::Arc, time::Duration}; -use alloy::providers::ProviderBuilder; -use alloy::rpc::types::Log; -use alloy::sol; -use alloy::sol_types::SolEvent; +use alloy::{providers::ProviderBuilder, rpc::types::Log, sol, sol_types::SolEvent}; use alloy_node_bindings::Anvil; use async_trait::async_trait; use event_scanner::{CallbackConfig, EventCallback, EventFilter, ScannerBuilder}; diff --git a/examples/simple_counter/main.rs b/examples/simple_counter/main.rs index 8c8ff1d9..98c3b2cd 100644 --- a/examples/simple_counter/main.rs +++ b/examples/simple_counter/main.rs @@ -1,9 +1,6 @@ use std::{sync::Arc, time::Duration}; -use alloy::providers::ProviderBuilder; -use alloy::rpc::types::Log; -use alloy::sol; -use alloy::sol_types::SolEvent; +use alloy::{providers::ProviderBuilder, rpc::types::Log, sol, sol_types::SolEvent}; use alloy_node_bindings::Anvil; use async_trait::async_trait; use event_scanner::{CallbackConfig, EventCallback, EventFilter, ScannerBuilder}; diff --git a/src/lib.rs b/src/lib.rs index 9e1e8f8f..1edd8c13 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,9 @@ pub mod callback; pub mod scanner; pub mod types; -pub use crate::builder::ScannerBuilder; -pub use crate::callback::EventCallback; -pub use crate::scanner::Scanner; -pub use crate::types::{CallbackConfig, EventFilter}; +pub use crate::{ + builder::ScannerBuilder, + callback::EventCallback, + scanner::Scanner, + types::{CallbackConfig, EventFilter}, +}; From 3f8555c68e35df22a40191e62ffbab4411b8774c Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 11 Sep 2025 17:12:24 +0200 Subject: [PATCH 3/9] Update .github/workflows/ci.yml Co-authored-by: Nenad --- .github/workflows/ci.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13cabf24..dff9f8cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,10 +69,5 @@ jobs: - name: Fetch Repository uses: actions/checkout@v5 - - name: Install Typos - uses: taiki-e/install-action@v2 - with: - tool: typos-cli - - - name: run typos - run: typos + - name: Check spelling of files in the workspace + uses: crate-ci/typos@v1 From 294cea39c08facb5d2cdeb0b67e5563a15f2cefc Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 11 Sep 2025 17:12:31 +0200 Subject: [PATCH 4/9] Update .github/workflows/ci.yml Co-authored-by: Nenad --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dff9f8cf..47cab37b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1 - name: cargo build - run: cargo b --workspace --all-targets --all-features + run: cargo b --locked --all-targets --all-features cargo-fmt: name: Cargo fmt From 2f90e068688af88768d9c0bd4dd4b9ec3de0838e Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 11 Sep 2025 17:12:48 +0200 Subject: [PATCH 5/9] Update .github/workflows/test.yml Co-authored-by: Nenad --- .github/workflows/test.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 55a793e0..bd1272b7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,15 @@ jobs: - name: Install stable toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Cache cargo-nextest binary + id: cache-cargo-nextest + uses: actions/cache@v4 + with: + path: ~/.cargo/bin/cargo-nextest + key: ${{ runner.os }}-cargo-nextest-${{ hashFiles('**/Cargo.lock') }} + - name: Install cargo-nextest + if: steps.cache-cargo-nextest.outputs.cache-hit != 'true' uses: taiki-e/install-action@v2 with: tool: cargo-nextest From 810c633ffe4a7e8e92f4f29ad0d5f9d0084a7235 Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 11 Sep 2025 17:14:05 +0200 Subject: [PATCH 6/9] Update .github/workflows/ci.yml Co-authored-by: Nenad --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47cab37b..e83892e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,11 @@ jobs: components: clippy - name: Clippy Check - run: cargo clippy --workspace --all-targets --all-features -- -D warnings + uses: giraffate/clippy-action@v1 + with: + reporter: "github-pr-check" + github_token: ${{ secrets.GITHUB_TOKEN }} + clippy_flags: --all-targets --all-features -- -D warnings -D clippy::pedantic typos-cli: name: typos From 299e2def8f81cb91a9ab82c8f89fb5658731ee31 Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 11 Sep 2025 17:14:13 +0200 Subject: [PATCH 7/9] Update .github/workflows/test.yml Co-authored-by: Nenad --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bd1272b7..80101853 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,3 +40,7 @@ jobs: - name: Cargo test run: cargo nextest run --workspace --all-targets --all-features --no-tests=pass + + # https://github.com/rust-lang/cargo/issues/6669 + - name: Run doc tests + run: cargo test --locked --doc From 9d6628123455bb029c568777565735755476349d Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 11 Sep 2025 17:14:20 +0200 Subject: [PATCH 8/9] Update .github/workflows/test.yml Co-authored-by: Nenad --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 80101853..19b870f3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: tool: cargo-nextest - name: Cargo test - run: cargo nextest run --workspace --all-targets --all-features --no-tests=pass + run: cargo nextest run --locked --all-targets --all-features --no-tests=pass # https://github.com/rust-lang/cargo/issues/6669 - name: Run doc tests From 8b59a2483e2cf831492a6a38225b2c85869eafac Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 11 Sep 2025 17:22:44 +0200 Subject: [PATCH 9/9] change name --- .github/workflows/{ci.yml => check.yml} | 28 +++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) rename .github/workflows/{ci.yml => check.yml} (66%) diff --git a/.github/workflows/ci.yml b/.github/workflows/check.yml similarity index 66% rename from .github/workflows/ci.yml rename to .github/workflows/check.yml index e83892e7..e1ae14b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/check.yml @@ -1,17 +1,27 @@ -name: "CI" - +name: check +# This workflow runs whenever a PR is opened or updated, or a commit is pushed +# to main. It runs several checks: +# - fmt: checks that the code is formatted according to `rustfmt`. +# - clippy: checks that the code does not contain any `clippy` warnings. +# - doc: checks that the code can be documented without errors. +# - typos: checks for typos across the repo. +permissions: + contents: read +# This configuration allows maintainers of this repo to create a branch and +# pull request based on the new branch. Restricting the push trigger to the +# main branch ensures that the PR only gets built once. on: - pull_request: - merge_group: push: - branches: [main] - -env: - CARGO_TERM_COLOR: always - + branches: [main, v*] + pull_request: +# If new code is pushed to a PR branch, then cancel in progress workflows for +# that PR. Ensures that we don't waste CI time, and returns results quicker. +# https://github.com/jonhoo/rust-ci-conf/pull/5 concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +env: + CARGO_TERM_COLOR: always jobs: cargo-build: