From 83883c8dc22632fb7390a3869bf03673cde721f1 Mon Sep 17 00:00:00 2001 From: Tanut Lertwarachai Date: Thu, 14 Aug 2025 16:11:32 +0700 Subject: [PATCH 1/4] add ci --- .github/workflows/ci.yml | 39 +++++++++++++++++++++++++ src/config/logging.rs | 2 +- src/server/builder.rs | 2 +- src/server/middleware/auth.rs | 9 ++++-- src/server/middleware/auth/store/sql.rs | 9 ++++-- 5 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b26a227 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +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 + - 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 + - uses: Swatinem/rust-cache@v2 + - run: cargo test --all-features --no-fail-fast \ No newline at end of file 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> { From 39ece6d526f5066d6733549281f78dc4845eca71 Mon Sep 17 00:00:00 2001 From: Tanut Lertwarachai Date: Thu, 14 Aug 2025 16:17:25 +0700 Subject: [PATCH 2/4] add protoc install --- .github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b26a227..b86f0d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,11 @@ jobs: 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: @@ -35,5 +40,10 @@ jobs: - 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 \ No newline at end of file From 56bb2e82418ecee286cada2668852543dddc6283 Mon Sep 17 00:00:00 2001 From: Tanut Lertwarachai Date: Fri, 15 Aug 2025 17:47:41 +0700 Subject: [PATCH 3/4] add eof --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b86f0d5..e1aa6bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,4 +46,5 @@ jobs: sudo apt-get install -y protobuf-compiler protoc --version - uses: Swatinem/rust-cache@v2 - - run: cargo test --all-features --no-fail-fast \ No newline at end of file + - run: cargo test --all-features --no-fail-fast + \ No newline at end of file From 7e7a6b2a6ec1f5d75ab3b1e7478e04dfef2706b9 Mon Sep 17 00:00:00 2001 From: Tanut Lertwarachai Date: Fri, 15 Aug 2025 17:48:38 +0700 Subject: [PATCH 4/4] add eof --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1aa6bf..53879ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,4 +47,3 @@ jobs: protoc --version - uses: Swatinem/rust-cache@v2 - run: cargo test --all-features --no-fail-fast - \ No newline at end of file