From 7cced29ef88e9e274dbf02287e530b8a9467af75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Casta=C3=B1o=20Arteaga?= Date: Tue, 25 Feb 2025 09:06:24 +0100 Subject: [PATCH] Upgrade dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sergio CastaƱo Arteaga --- .github/dependabot.yml | 2 +- .github/workflows/ci.yml | 2 +- Cargo.lock | 149 ++++++++++++++++-------------------- Cargo.toml | 28 +++---- dco2-aws-lambda/src/main.rs | 8 +- dco2-server/Dockerfile | 2 +- dco2-server/src/config.rs | 6 +- dco2-server/src/handlers.rs | 9 ++- dco2-server/src/main.rs | 8 +- dco2/src/dco/check/mod.rs | 8 +- dco2/src/dco/check/tests.rs | 8 +- dco2/src/dco/event/mod.rs | 15 ++-- dco2/src/dco/event/tests.rs | 10 ++- dco2/src/github/client.rs | 7 +- dco2/src/github/event.rs | 3 +- 15 files changed, 134 insertions(+), 131 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7af843c..d1e66ee 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,7 @@ updates: schedule: interval: "weekly" groups: - cli: + dco2: patterns: - "*" update-types: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 100b344..846b7a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Rust uses: dtolnay/rust-toolchain@master with: - toolchain: 1.83.0 + toolchain: 1.85.0 components: clippy, rustfmt - name: Run clippy run: cargo clippy --all-targets --all-features -- --deny warnings diff --git a/Cargo.lock b/Cargo.lock index f97e6e3..435c872 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -110,9 +110,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.94" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" +checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4" [[package]] name = "askama" @@ -193,9 +193,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.83" +version = "0.1.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d" dependencies = [ "proc-macro2", "quote", @@ -219,9 +219,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "aws_lambda_events" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7319a086b79c3ff026a33a61e80f04fd3885fbb73237981ea080d21944e1cb1c" +checksum = "52ddb91585253ccc85be3f2e0d5635529efdeadaf8a1da3230b433d3bbe43648" dependencies = [ "base64 0.22.1", "bytes", @@ -235,14 +235,14 @@ dependencies = [ [[package]] name = "axum" -version = "0.7.9" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +checksum = "6d6fd624c75e18b3b4c6b9caf42b1afe24437daaee904069137d8bab077be8b8" dependencies = [ - "async-trait", "axum-core", "axum-macros", "bytes", + "form_urlencoded", "futures-util", "http 1.2.0", "http-body", @@ -250,7 +250,7 @@ dependencies = [ "hyper", "hyper-util", "itoa", - "matchit 0.7.3", + "matchit", "memchr", "mime", "percent-encoding", @@ -260,9 +260,9 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper 1.0.1", + "sync_wrapper", "tokio", - "tower 0.5.1", + "tower 0.5.2", "tower-layer", "tower-service", "tracing", @@ -270,11 +270,10 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.5" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +checksum = "df1362f362fd16024ae199c1970ce98f9661bf5ef94b9808fee734bc3698b733" dependencies = [ - "async-trait", "bytes", "futures-util", "http 1.2.0", @@ -283,7 +282,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.1", + "sync_wrapper", "tower-layer", "tower-service", "tracing", @@ -291,9 +290,9 @@ dependencies = [ [[package]] name = "axum-macros" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d123550fa8d071b7255cb0cc04dc302baa6c8c4a79f55701552684d8399bce" +checksum = "604fde5e028fea851ce1d8570bbdc034bec850d157f7569d10f347d06808c05c" dependencies = [ "proc-macro2", "quote", @@ -383,9 +382,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" +checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" dependencies = [ "serde", ] @@ -458,9 +457,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.23" +version = "4.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" +checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767" dependencies = [ "clap_builder", "clap_derive", @@ -468,9 +467,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.23" +version = "4.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" +checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863" dependencies = [ "anstream", "anstyle", @@ -480,9 +479,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.18" +version = "4.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed" dependencies = [ "heck", "proc-macro2", @@ -578,13 +577,13 @@ dependencies = [ "indoc", "mockall", "octorust", - "pem 3.0.4", + "pem 3.0.5", "pretty_assertions", "regex", "serde", "serde_json", "serde_yaml", - "thiserror 2.0.6", + "thiserror 2.0.11", "tokio", "tracing", ] @@ -615,7 +614,7 @@ dependencies = [ "serde", "sha2", "tokio", - "tower 0.5.1", + "tower 0.5.2", "tower-http", "tracing", "tracing-subscriber", @@ -1129,9 +1128,9 @@ dependencies = [ [[package]] name = "lambda_http" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fe279be7f89f5f72c97c3a96f45c43db8edab1007320ecc6a5741273b4d6db" +checksum = "68b470cea1ec37b96e9543870a33c1f4b9e243754fe5892668efa3125ea12784" dependencies = [ "aws_lambda_events", "base64 0.22.1", @@ -1211,9 +1210,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.170" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" [[package]] name = "libm" @@ -1249,12 +1248,6 @@ dependencies = [ "regex-automata 0.1.10", ] -[[package]] -name = "matchit" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" - [[package]] name = "matchit" version = "0.8.4" @@ -1401,9 +1394,9 @@ dependencies = [ [[package]] name = "octorust" -version = "0.8.0-rc.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8e838b1aaed3dd469f9e33688b75f25340451c3537197b2a488d330ba198e8" +checksum = "84b68b0e407b85431ea87ee51b3d977c2490bb0601a8c251bc4c9ce567350334" dependencies = [ "async-recursion", "async-trait", @@ -1537,9 +1530,9 @@ dependencies = [ [[package]] name = "pem" -version = "3.0.4" +version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" +checksum = "38af38e8470ac9dee3ce1bae1af9c1671fffc44ddfd8bd1d0a3445bf349a8ef3" dependencies = [ "base64 0.22.1", "serde", @@ -1847,7 +1840,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 1.0.1", + "sync_wrapper", "tokio", "tokio-rustls", "tower-service", @@ -1861,9 +1854,9 @@ dependencies = [ [[package]] name = "reqwest-conditional-middleware" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1663d9d4fbb6e3900f91455d6d7833301c91ae3c7fc6e116fd7acd40e478a93" +checksum = "f67ad7fdf5c0a015763fcd164bee294b13fb7b6f89f1b55961d40f00c3e32d6b" dependencies = [ "async-trait", "http 1.2.0", @@ -1873,9 +1866,9 @@ dependencies = [ [[package]] name = "reqwest-middleware" -version = "0.3.3" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562ceb5a604d3f7c885a792d42c199fd8af239d0a51b2fa6a78aafa092452b04" +checksum = "64e8975513bd9a7a43aad01030e79b3498e05db14e9d945df6483e8cf9b8c4c4" dependencies = [ "anyhow", "async-trait", @@ -1888,13 +1881,12 @@ dependencies = [ [[package]] name = "reqwest-retry" -version = "0.5.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40f342894422862af74c50e1e9601cf0931accc9c6981e5eb413c46603b616b5" +checksum = "29c73e4195a6bfbcb174b790d9b3407ab90646976c55de58a6515da25d851178" dependencies = [ "anyhow", "async-trait", - "chrono", "futures", "getrandom", "http 1.2.0", @@ -1903,6 +1895,7 @@ dependencies = [ "reqwest", "reqwest-middleware", "retry-policies", + "thiserror 1.0.64", "tokio", "tracing", "wasm-timer", @@ -1910,15 +1903,15 @@ dependencies = [ [[package]] name = "reqwest-tracing" -version = "0.5.3" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdd9bfa64c72233d8dd99ab7883efcdefe9e16d46488ecb9228b71a2e2ceb45" +checksum = "d9c88a8d9cfe3319b5adc10f3ffc3db75c7346837a1f857f8269f6361f3b2744" dependencies = [ "anyhow", "async-trait", "getrandom", "http 1.2.0", - "matchit 0.8.4", + "matchit", "reqwest", "reqwest-middleware", "tracing", @@ -1926,12 +1919,10 @@ dependencies = [ [[package]] name = "retry-policies" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "493b4243e32d6eedd29f9a398896e35c6943a123b55eec97dcaee98310d25810" +checksum = "5875471e6cab2871bc150ecb8c727db5113c9338cc3354dc5ee3425b6aa40a1c" dependencies = [ - "anyhow", - "chrono", "rand", ] @@ -2066,18 +2057,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.215" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" dependencies = [ "proc-macro2", "quote", @@ -2097,9 +2088,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.133" +version = "1.0.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" dependencies = [ "itoa", "memchr", @@ -2249,12 +2240,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - [[package]] name = "sync_wrapper" version = "1.0.1" @@ -2281,11 +2266,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.6" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec2a1820ebd077e2b90c4df007bebf344cd394098a13c563957d0afc83ea47" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" dependencies = [ - "thiserror-impl 2.0.6", + "thiserror-impl 2.0.11", ] [[package]] @@ -2301,9 +2286,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.6" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d65750cab40f4ff1929fb1ba509e9914eb756131cef4210da8d5d700d26f6312" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", @@ -2368,9 +2353,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -2386,9 +2371,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", @@ -2448,14 +2433,14 @@ dependencies = [ [[package]] name = "tower" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" dependencies = [ "futures-core", "futures-util", "pin-project-lite", - "sync_wrapper 0.1.2", + "sync_wrapper", "tokio", "tower-layer", "tower-service", diff --git a/Cargo.toml b/Cargo.toml index 1421198..5b63b70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,17 +10,17 @@ members = [ version = "0.1.0" edition = "2021" license = "Apache-2.0" -rust-version = "1.83" +rust-version = "1.85" [workspace.dependencies] -anyhow = "1.0.94" +anyhow = "1.0.96" askama = "0.12.1" -async-trait = "0.1.83" -axum = { version = "0.7.9", features = ["macros"] } +async-trait = "0.1.86" +axum = { version = "0.8.1", features = ["macros"] } base64 = "0.22.1" -bytes = "1.9.0" +bytes = "1.10.0" cached = { version = "0.54.0", features = ["async"] } -clap = { version = "4.5.23", features = ["derive"] } +clap = { version = "4.5.31", features = ["derive"] } chrono = "0.4.39" email_address = "0.2.9" figment = { version = "0.10.19", features = ["yaml", "env"] } @@ -28,18 +28,18 @@ hmac = "0.12.1" hex = "0.4.3" http = "1.2.0" indoc = "2.0.5" -lambda_http = "0.13.0" +lambda_http = "0.14.0" mockall = "0.13.1" -octorust = "0.8.0-rc.1" -pem = "3.0.4" +octorust = "0.9.0" +pem = "3.0.5" pretty_assertions = "1.4.1" regex = "1.11.1" -serde = { version = "1.0.215", features = ["derive"] } -serde_json = "1.0.133" +serde = { version = "1.0.218", features = ["derive"] } +serde_json = "1.0.139" serde_yaml = "0.9.34" sha2 = "0.10.8" -thiserror = "2.0.6" -tokio = { version = "1.42.0", features = [ +thiserror = "2.0.11" +tokio = { version = "1.43.0", features = [ "macros", "process", "rt-multi-thread", @@ -47,7 +47,7 @@ tokio = { version = "1.42.0", features = [ "sync", "time", ] } -tower = "0.5.1" +tower = "0.5.2" tower-http = { version = "0.6.2", features = ["auth", "fs", "set-header", "trace"] } tracing = "0.1.41" tracing-subscriber = { version = "0.3.19", features = ["env-filter", "json"] } diff --git a/dco2-aws-lambda/src/main.rs b/dco2-aws-lambda/src/main.rs index 2ef8409..96208fc 100644 --- a/dco2-aws-lambda/src/main.rs +++ b/dco2-aws-lambda/src/main.rs @@ -1,9 +1,11 @@ +use std::{env::set_var, sync::Arc}; + use anyhow::Context; -use dco2::github::{AppConfig, GHClientOctorust}; -use dco2_server::handlers::setup_router; use figment::{providers::Env, Figment}; use lambda_http::{run, tracing, Error}; -use std::{env::set_var, sync::Arc}; + +use dco2::github::{AppConfig, GHClientOctorust}; +use dco2_server::handlers::setup_router; #[tokio::main] async fn main() -> Result<(), Error> { diff --git a/dco2-server/Dockerfile b/dco2-server/Dockerfile index 49080ce..91cd16c 100644 --- a/dco2-server/Dockerfile +++ b/dco2-server/Dockerfile @@ -10,7 +10,7 @@ WORKDIR /dco2/dco2-server RUN cargo build --release # Final stage -FROM alpine:3.21.0 +FROM alpine:3.21.3 RUN apk --no-cache add ca-certificates && addgroup -S dco2 && adduser -S dco2 -G dco2 USER dco2 WORKDIR /home/dco2 diff --git a/dco2-server/src/config.rs b/dco2-server/src/config.rs index 11c0d6c..f1fcaf3 100644 --- a/dco2-server/src/config.rs +++ b/dco2-server/src/config.rs @@ -1,13 +1,15 @@ //! This module defines some types to represent the server configuration. +use std::path::PathBuf; + use anyhow::Result; -use dco2::github::AppConfig; use figment::{ providers::{Env, Format, Serialized, Yaml}, Figment, }; use serde::{Deserialize, Serialize}; -use std::path::PathBuf; + +use dco2::github::AppConfig; /// Server configuration. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] diff --git a/dco2-server/src/handlers.rs b/dco2-server/src/handlers.rs index ef04efc..9e7105d 100644 --- a/dco2-server/src/handlers.rs +++ b/dco2-server/src/handlers.rs @@ -9,16 +9,17 @@ use axum::{ routing::{get, post}, Router, }; -use dco2::{ - dco, - github::{DynGHClient, Event, EventError, EVENT_ID_HEADER, EVENT_SIGNATURE_HEADER}, -}; use hmac::{Hmac, Mac}; use sha2::Sha256; use tower::ServiceBuilder; use tower_http::trace::TraceLayer; use tracing::{error, info, instrument}; +use dco2::{ + dco, + github::{DynGHClient, Event, EventError, EVENT_ID_HEADER, EVENT_SIGNATURE_HEADER}, +}; + /// Router's state. #[derive(Clone, FromRef)] struct RouterState { diff --git a/dco2-server/src/main.rs b/dco2-server/src/main.rs index c268dd7..f29f385 100644 --- a/dco2-server/src/main.rs +++ b/dco2-server/src/main.rs @@ -1,16 +1,18 @@ #![warn(clippy::all, clippy::pedantic)] #![allow(clippy::doc_markdown, clippy::similar_names)] +use std::{path::PathBuf, sync::Arc}; + use anyhow::{Context, Result}; use clap::Parser; use config::{Config, LogFormat}; -use dco2::github::GHClientOctorust; -use dco2_server::handlers::setup_router; -use std::{path::PathBuf, sync::Arc}; use tokio::{net::TcpListener, signal}; use tracing::{error, info}; use tracing_subscriber::EnvFilter; +use dco2::github::GHClientOctorust; +use dco2_server::handlers::setup_router; + mod config; #[derive(Debug, Parser)] diff --git a/dco2/src/dco/check/mod.rs b/dco2/src/dco/check/mod.rs index 6cbdc1b..866af75 100644 --- a/dco2/src/dco/check/mod.rs +++ b/dco2/src/dco/check/mod.rs @@ -1,14 +1,16 @@ //! This module contains the DCO check logic. -use crate::github::{Commit, Config, User}; +use std::{fmt::Display, sync::LazyLock}; + use anyhow::{bail, Result}; use askama::Template; use email_address::EmailAddress; use regex::Regex; use serde::{Deserialize, Serialize}; -use std::{fmt::Display, sync::LazyLock}; use thiserror::Error; +use crate::github::{Commit, Config, User}; + mod filters; #[cfg(test)] mod tests; @@ -153,7 +155,7 @@ pub(crate) fn check(input: &CheckInput) -> CheckOutput { // Update output status output.num_commits_with_errors = output.commits.iter().filter(|c| !c.errors.is_empty()).count(); output.only_last_commit_contains_errors = - output.num_commits_with_errors == 1 && output.commits.last().map_or(false, |c| !c.errors.is_empty()); + output.num_commits_with_errors == 1 && output.commits.last().is_some_and(|c| !c.errors.is_empty()); output } diff --git a/dco2/src/dco/check/tests.rs b/dco2/src/dco/check/tests.rs index 4020ba4..d0db745 100644 --- a/dco2/src/dco/check/tests.rs +++ b/dco2/src/dco/check/tests.rs @@ -1,10 +1,12 @@ +use std::vec; + +use indoc::indoc; +use pretty_assertions::assert_eq; + use crate::{ dco::check::{check, CheckInput, CheckOutput, CommitCheckOutput, CommitError, CommitSuccessReason}, github::{Commit, Config, ConfigAllowRemediationCommits, ConfigRequire, User}, }; -use indoc::indoc; -use pretty_assertions::assert_eq; -use std::vec; #[test] fn single_commit_no_signoff_is_merge_commit() { diff --git a/dco2/src/dco/event/mod.rs b/dco2/src/dco/event/mod.rs index 28a7816..34fd639 100644 --- a/dco2/src/dco/event/mod.rs +++ b/dco2/src/dco/event/mod.rs @@ -1,15 +1,18 @@ //! This module contains the logic to process GitHub webhook events. -use super::check::{check, CheckInput}; -use crate::github::{ - CheckRun, CheckRunAction, CheckRunConclusion, CheckRunEvent, CheckRunEventAction, CheckRunStatus, Commit, - DynGHClient, Event, MergeGroupEvent, MergeGroupEventAction, NewCheckRunInput, PullRequestEvent, - PullRequestEventAction, -}; use anyhow::{Context, Result}; use askama::Template; use chrono::Utc; +use crate::{ + dco::check::{check, CheckInput}, + github::{ + CheckRun, CheckRunAction, CheckRunConclusion, CheckRunEvent, CheckRunEventAction, CheckRunStatus, + Commit, DynGHClient, Event, MergeGroupEvent, MergeGroupEventAction, NewCheckRunInput, + PullRequestEvent, PullRequestEventAction, + }, +}; + #[cfg(test)] mod tests; diff --git a/dco2/src/dco/event/tests.rs b/dco2/src/dco/event/tests.rs index 9506811..d72bcdc 100644 --- a/dco2/src/dco/event/tests.rs +++ b/dco2/src/dco/event/tests.rs @@ -1,3 +1,9 @@ +use std::{future, sync::Arc}; + +use anyhow::{anyhow, Ok}; +use indoc::indoc; +use mockall::predicate::eq; + use crate::{ dco::{ event::{ @@ -15,10 +21,6 @@ use crate::{ RepositoryOwner, RequestedAction, User, }, }; -use anyhow::{anyhow, Ok}; -use indoc::indoc; -use mockall::predicate::eq; -use std::{future, sync::Arc}; #[tokio::test] async fn check_run_event_other_action() { diff --git a/dco2/src/github/client.rs b/dco2/src/github/client.rs index e4d7ac8..7bc5f67 100644 --- a/dco2/src/github/client.rs +++ b/dco2/src/github/client.rs @@ -1,5 +1,7 @@ //! This module defines an abstraction layer over the GitHub API. +use std::sync::Arc; + use anyhow::{bail, Result}; use async_trait::async_trait; use base64::{engine::general_purpose::STANDARD as b64, Engine as _}; @@ -9,7 +11,6 @@ use http::StatusCode; #[cfg(test)] use mockall::automock; use serde::{Deserialize, Serialize}; -use std::sync::Arc; use tracing::warn; /// Path of the configuration file in the repository. @@ -395,13 +396,13 @@ impl From for Commit { author: c.commit.author.map(|author| User { name: author.name, email: author.email, - is_bot: c.author.as_ref().map_or(false, |a| a.type_ == "Bot"), + is_bot: c.author.as_ref().is_some_and(|a| a.type_ == "Bot"), login: c.author.map(|a| a.login), }), committer: c.commit.committer.map(|committer| User { name: committer.name, email: committer.email, - is_bot: c.committer.as_ref().map_or(false, |c| c.type_ == "Bot"), + is_bot: c.committer.as_ref().is_some_and(|c| c.type_ == "Bot"), login: c.committer.map(|c| c.login), }), html_url: c.html_url, diff --git a/dco2/src/github/event.rs b/dco2/src/github/event.rs index c2c0134..8da808b 100644 --- a/dco2/src/github/event.rs +++ b/dco2/src/github/event.rs @@ -1,12 +1,13 @@ //! This module defines some types and functions to parse and deserialize //! GitHub webhook events. -use super::client::Ctx; use bytes::Bytes; use http::HeaderMap; use serde::{Deserialize, Serialize}; use thiserror::Error; +use crate::github::client::Ctx; + /// Header representing the event unique identifier. pub const EVENT_ID_HEADER: &str = "X-GitHub-Delivery";