From b7b00e2fc72876db0e8eb29b692294a8bbf8e7a6 Mon Sep 17 00:00:00 2001 From: Frank Parejo Date: Sat, 2 Nov 2024 22:33:18 +0100 Subject: [PATCH] add main github workflow action --- .github/workflows/main.yml | 38 +++++++++++++++++++++++++++++++++++ api/Cargo.toml | 17 ++++++++++++++++ api/src/github/middlewares.rs | 4 ++-- api/src/github/router.rs | 2 +- axum_redis_utils/Cargo.toml | 17 ++++++++++++++++ 5 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..9bcfe40 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,38 @@ +name: Deploy API to AWS + +on: + push: + branches: + - main + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust + run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + + - name: Run rust linter + run: cargo clippy -- -D warnings + + formatting: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust + run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + + - name: Run formatter check + run: cargo fmt --all -- --check + + + + + diff --git a/api/Cargo.toml b/api/Cargo.toml index 1d48a90..f461608 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -39,3 +39,20 @@ axum_redis_utils = { path = "../axum_redis_utils" } wiremock = "0.6.1" uuid = { version = "1.10.0", features = ["v4"] } serial_test = "3.1.1" + +[lints.clippy] +single_match = "warn" +single_match_else = "warn" +needless_match = "warn" +needless_late_init = "warn" +redundant_pattern_matching = "warn" +redundant_pattern = "warn" +redundant_guards = "warn" +collapsible_match = "warn" +match_single_binding = "warn" +match_same_arms = "warn" +match_ref_pats = "warn" +match_bool = "warn" +needless_bool = "deny" +unwrap_used = "warn" +expect_used = "warn" diff --git a/api/src/github/middlewares.rs b/api/src/github/middlewares.rs index cac2137..9dc3b4c 100644 --- a/api/src/github/middlewares.rs +++ b/api/src/github/middlewares.rs @@ -29,7 +29,7 @@ impl GithubRateLimitLayer { } } -impl<'a, S> Layer for GithubRateLimitLayer { +impl Layer for GithubRateLimitLayer { type Service = GithubRateLimitMiddleware; fn layer(&self, inner: S) -> Self::Service { @@ -40,7 +40,7 @@ impl<'a, S> Layer for GithubRateLimitLayer { pub struct GithubRateLimitServiceBuilder; impl GithubRateLimitServiceBuilder { - pub fn new( + pub fn build( state: Arc, ) -> ServiceBuilder>, Identity>>> { diff --git a/api/src/github/router.rs b/api/src/github/router.rs index 64ad962..c16562e 100644 --- a/api/src/github/router.rs +++ b/api/src/github/router.rs @@ -40,6 +40,6 @@ impl GithubRepositoryRouter { }, ))), ) - .route_layer(GithubRateLimitServiceBuilder::new(state)) + .route_layer(GithubRateLimitServiceBuilder::build(state)) } } diff --git a/axum_redis_utils/Cargo.toml b/axum_redis_utils/Cargo.toml index dcf6b36..b279c89 100644 --- a/axum_redis_utils/Cargo.toml +++ b/axum_redis_utils/Cargo.toml @@ -21,3 +21,20 @@ dotenv = "0.15.0" redis-macros = "0.4.0" reqwest = { version = "0.12.7", features = ["json"] } uuid = { version = "1.10.0", features = ["v4"] } + +[lints.clippy] +single_match = "warn" +single_match_else = "warn" +needless_match = "warn" +needless_late_init = "warn" +redundant_pattern_matching = "warn" +redundant_pattern = "warn" +redundant_guards = "warn" +collapsible_match = "warn" +match_single_binding = "warn" +match_same_arms = "warn" +match_ref_pats = "warn" +match_bool = "warn" +needless_bool = "deny" +unwrap_used = "warn" +expect_used = "warn"