Skip to content
Merged

ci #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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:
push:
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:
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 --locked --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
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
runs-on: ubuntu-latest

steps:
- name: Fetch Repository
uses: actions/checkout@v5

- name: Check spelling of files in the workspace
uses: crate-ci/typos@v1
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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: 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

- name: Cargo test
run: cargo nextest run --locked --all-targets --all-features --no-tests=pass

# https://github.com/rust-lang/cargo/issues/6669
- name: Run doc tests
run: cargo test --locked --doc
7 changes: 2 additions & 5 deletions examples/historical_scanning/main.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -65,7 +62,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)
Expand Down
5 changes: 1 addition & 4 deletions examples/simple_counter/main.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Copy link
Collaborator

@0xNeshi 0xNeshi Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use the rust-analyzer extension, my IDE is configured to auto-format when saving the file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have that as well but for some reason i can't get it to format using the rules in the rustfmt.toml file because it requires the nightly version of rustfmt, so my ide only formats based on naive fmt rules instead of the project ones.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird

builder::ScannerBuilder,
callback::EventCallback,
scanner::Scanner,
types::{CallbackConfig, EventFilter},
};