diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..53879ee --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: CI +on: + pull_request: + push: + branches: [main] + +jobs: + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: nightly-2025-02-25 + components: rustfmt + - run: cargo +nightly-2025-02-25 fmt --all --check + + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: 1.85 + components: clippy + - name: Install protoc + run: | + sudo apt-get update + sudo apt-get install -y protobuf-compiler + protoc --version + - uses: Swatinem/rust-cache@v2 + - run: cargo clippy --all-targets --all-features + env: + RUSTFLAGS: -D warnings + + test-stable: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: 1.85 + - name: Install protoc + run: | + sudo apt-get update + sudo apt-get install -y protobuf-compiler + protoc --version + - uses: Swatinem/rust-cache@v2 + - run: cargo test --all-features --no-fail-fast diff --git a/src/config/logging.rs b/src/config/logging.rs index 744e2b3..d4bed5f 100644 --- a/src/config/logging.rs +++ b/src/config/logging.rs @@ -13,7 +13,7 @@ fn default_log_level() -> String { impl Default for LoggingConfig { fn default() -> Self { LoggingConfig { - log_level: default_log_level() + log_level: default_log_level(), } } } diff --git a/src/server/builder.rs b/src/server/builder.rs index 14f9111..c6e5d46 100644 --- a/src/server/builder.rs +++ b/src/server/builder.rs @@ -1,5 +1,5 @@ -use crate::server::pre_sign::PreSignHook; use crate::server::Server; +use crate::server::pre_sign::PreSignHook; use crate::signer::signature::ecdsa::EcdsaSignature; use crate::signer::{EvmSigner, Signer}; use std::collections::HashMap; diff --git a/src/server/middleware/auth.rs b/src/server/middleware/auth.rs index d903cc6..55ae992 100644 --- a/src/server/middleware/auth.rs +++ b/src/server/middleware/auth.rs @@ -15,13 +15,16 @@ const DEFAULT_HEADER_API_KEY: &str = "api-key"; #[derive(Debug, Clone, Default)] pub struct AuthMiddlewareLayer { pub store: S, - pub header_api_key: String + pub header_api_key: String, } impl AuthMiddlewareLayer { pub fn new(store: S, header_api_key: Option) -> Self { - let header_api_key = header_api_key.unwrap_or_else(|| DEFAULT_HEADER_API_KEY.to_string()); - Self { store, header_api_key } + let header_api_key = header_api_key.unwrap_or_else(|| DEFAULT_HEADER_API_KEY.to_string()); + Self { + store, + header_api_key, + } } } diff --git a/src/server/middleware/auth/store/sql.rs b/src/server/middleware/auth/store/sql.rs index e24b3a0..e1f2e48 100644 --- a/src/server/middleware/auth/store/sql.rs +++ b/src/server/middleware/auth/store/sql.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use sea_orm::{entity::EntityTrait, DatabaseConnection, DbErr, PrimaryKeyTrait}; +use sea_orm::{DatabaseConnection, DbErr, PrimaryKeyTrait, entity::EntityTrait}; use super::Store; @@ -15,14 +15,17 @@ where <::PrimaryKey as PrimaryKeyTrait>::ValueType: From, { pub fn new(db_conn: DatabaseConnection) -> Self { - Self { db_conn, _entity: PhantomData } + Self { + db_conn, + _entity: PhantomData, + } } } #[async_trait::async_trait] impl Store for SqlDb where - for <'a> <::PrimaryKey as PrimaryKeyTrait>::ValueType: From<&'a str>, + for<'a> <::PrimaryKey as PrimaryKeyTrait>::ValueType: From<&'a str>, { type Error = DbErr; async fn verify_api_key(&self, api_key: &str) -> Result<(), Self::Error> {