Skip to content

Commit d9d41eb

Browse files
tanut32039Tanut Lertwarachai
andauthored
[Feat] add ci (#10)
* add ci * add protoc install * add eof * add eof --------- Co-authored-by: Tanut Lertwarachai <tanutlertwarachai@Tanuts-MacBook-Pro.local>
1 parent f74edfc commit d9d41eb

5 files changed

Lines changed: 63 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
fmt:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: dtolnay/rust-toolchain@master
13+
with:
14+
toolchain: nightly-2025-02-25
15+
components: rustfmt
16+
- run: cargo +nightly-2025-02-25 fmt --all --check
17+
18+
clippy:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: dtolnay/rust-toolchain@master
23+
with:
24+
toolchain: 1.85
25+
components: clippy
26+
- name: Install protoc
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y protobuf-compiler
30+
protoc --version
31+
- uses: Swatinem/rust-cache@v2
32+
- run: cargo clippy --all-targets --all-features
33+
env:
34+
RUSTFLAGS: -D warnings
35+
36+
test-stable:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: dtolnay/rust-toolchain@master
41+
with:
42+
toolchain: 1.85
43+
- name: Install protoc
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install -y protobuf-compiler
47+
protoc --version
48+
- uses: Swatinem/rust-cache@v2
49+
- run: cargo test --all-features --no-fail-fast

src/config/logging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn default_log_level() -> String {
1313
impl Default for LoggingConfig {
1414
fn default() -> Self {
1515
LoggingConfig {
16-
log_level: default_log_level()
16+
log_level: default_log_level(),
1717
}
1818
}
1919
}

src/server/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::server::pre_sign::PreSignHook;
21
use crate::server::Server;
2+
use crate::server::pre_sign::PreSignHook;
33
use crate::signer::signature::ecdsa::EcdsaSignature;
44
use crate::signer::{EvmSigner, Signer};
55
use std::collections::HashMap;

src/server/middleware/auth.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ const DEFAULT_HEADER_API_KEY: &str = "api-key";
1515
#[derive(Debug, Clone, Default)]
1616
pub struct AuthMiddlewareLayer<S: Store> {
1717
pub store: S,
18-
pub header_api_key: String
18+
pub header_api_key: String,
1919
}
2020

2121
impl<S: Store> AuthMiddlewareLayer<S> {
2222
pub fn new(store: S, header_api_key: Option<String>) -> Self {
23-
let header_api_key = header_api_key.unwrap_or_else(|| DEFAULT_HEADER_API_KEY.to_string());
24-
Self { store, header_api_key }
23+
let header_api_key = header_api_key.unwrap_or_else(|| DEFAULT_HEADER_API_KEY.to_string());
24+
Self {
25+
store,
26+
header_api_key,
27+
}
2528
}
2629
}
2730

src/server/middleware/auth/store/sql.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::marker::PhantomData;
22

3-
use sea_orm::{entity::EntityTrait, DatabaseConnection, DbErr, PrimaryKeyTrait};
3+
use sea_orm::{DatabaseConnection, DbErr, PrimaryKeyTrait, entity::EntityTrait};
44

55
use super::Store;
66

@@ -15,14 +15,17 @@ where
1515
<<E as EntityTrait>::PrimaryKey as PrimaryKeyTrait>::ValueType: From<String>,
1616
{
1717
pub fn new(db_conn: DatabaseConnection) -> Self {
18-
Self { db_conn, _entity: PhantomData }
18+
Self {
19+
db_conn,
20+
_entity: PhantomData,
21+
}
1922
}
2023
}
2124

2225
#[async_trait::async_trait]
2326
impl<E: EntityTrait> Store for SqlDb<E>
2427
where
25-
for <'a> <<E as EntityTrait>::PrimaryKey as PrimaryKeyTrait>::ValueType: From<&'a str>,
28+
for<'a> <<E as EntityTrait>::PrimaryKey as PrimaryKeyTrait>::ValueType: From<&'a str>,
2629
{
2730
type Error = DbErr;
2831
async fn verify_api_key(&self, api_key: &str) -> Result<(), Self::Error> {

0 commit comments

Comments
 (0)