From 7def01a19af567c668da663d4a4c88e0b631a57e Mon Sep 17 00:00:00 2001 From: Nutomic Date: Tue, 9 Apr 2024 11:28:57 +0200 Subject: [PATCH] Avoid running ci checks twice (#105) * Avoid running ci checks twice * upgrade rust * move clippy config to cargo.toml --- .woodpecker.yml | 42 ++++++++++++++++--------------- Cargo.toml | 17 +++++++++++++ examples/live_federation/main.rs | 2 ++ examples/local_federation/main.rs | 2 ++ src/activity_queue.rs | 1 + src/activity_sending.rs | 1 + src/actix_web/inbox.rs | 1 + src/fetch/object_id.rs | 1 + src/fetch/webfinger.rs | 1 + src/http_signatures.rs | 1 + 10 files changed, 49 insertions(+), 20 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index b563544..d14bc3d 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,54 +1,56 @@ -pipeline: +variables: + - &rust_image "rust:1.77-bullseye" + +steps: cargo_fmt: image: rustdocker/rust:nightly commands: - /root/.cargo/bin/cargo fmt -- --check - - cargo_check: - image: rust:1.70-bullseye - environment: - CARGO_HOME: .cargo - commands: - - cargo check --all-features --all-targets + when: + - event: pull_request cargo_clippy: - image: rust:1.70-bullseye + image: *rust_image environment: CARGO_HOME: .cargo commands: - rustup component add clippy - - cargo clippy --all-targets --all-features -- - -D warnings -D deprecated -D clippy::perf -D clippy::complexity - -D clippy::dbg_macro -D clippy::inefficient_to_string - -D clippy::items-after-statements -D clippy::implicit_clone - -D clippy::wildcard_imports -D clippy::cast_lossless - -D clippy::manual_string_new -D clippy::redundant_closure_for_method_calls - - cargo clippy --all-features -- -D clippy::unwrap_used + - cargo clippy --all-targets --all-features + when: + - event: pull_request cargo_test: - image: rust:1.70-bullseye + image: *rust_image environment: CARGO_HOME: .cargo commands: - cargo test --all-features --no-fail-fast + when: + - event: pull_request cargo_doc: - image: rust:1.70-bullseye + image: *rust_image environment: CARGO_HOME: .cargo commands: - cargo doc --all-features + when: + - event: pull_request cargo_run_actix_example: - image: rust:1.70-bullseye + image: *rust_image environment: CARGO_HOME: .cargo commands: - cargo run --example local_federation actix-web + when: + - event: pull_request cargo_run_axum_example: - image: rust:1.70-bullseye + image: *rust_image environment: CARGO_HOME: .cargo commands: - cargo run --example local_federation axum + when: + - event: pull_request diff --git a/Cargo.toml b/Cargo.toml index 711ffc2..caef7d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,23 @@ actix-web = ["dep:actix-web"] axum = ["dep:axum", "dep:tower", "dep:hyper", "dep:http-body-util"] diesel = ["dep:diesel"] +[lints.rust] +warnings = "deny" +deprecated = "deny" + +[lints.clippy] +perf = "deny" +complexity = "deny" +dbg_macro = "deny" +inefficient_to_string = "deny" +items-after-statements = "deny" +implicit_clone = "deny" +wildcard_imports = "deny" +cast_lossless = "deny" +manual_string_new = "deny" +redundant_closure_for_method_calls = "deny" +unwrap_used = "deny" + [dependencies] chrono = { version = "0.4.34", features = ["clock"], default-features = false } serde = { version = "1.0.197", features = ["derive"] } diff --git a/examples/live_federation/main.rs b/examples/live_federation/main.rs index 4326226..3fa0b18 100644 --- a/examples/live_federation/main.rs +++ b/examples/live_federation/main.rs @@ -1,3 +1,5 @@ +#![allow(clippy::unwrap_used)] + use crate::{ database::Database, http::{http_get_user, http_post_user_inbox, webfinger}, diff --git a/examples/local_federation/main.rs b/examples/local_federation/main.rs index 1597668..d23a594 100644 --- a/examples/local_federation/main.rs +++ b/examples/local_federation/main.rs @@ -1,3 +1,5 @@ +#![allow(clippy::unwrap_used)] + use crate::{ instance::{listen, new_instance, Webserver}, objects::post::DbPost, diff --git a/src/activity_queue.rs b/src/activity_queue.rs index abb5800..20852bd 100644 --- a/src/activity_queue.rs +++ b/src/activity_queue.rs @@ -416,6 +416,7 @@ async fn retry>, A: FnMut } #[cfg(test)] +#[allow(clippy::unwrap_used)] mod tests { use super::*; use crate::http_signatures::generate_actor_keypair; diff --git a/src/activity_sending.rs b/src/activity_sending.rs index ce53f94..4af8439 100644 --- a/src/activity_sending.rs +++ b/src/activity_sending.rs @@ -224,6 +224,7 @@ pub(crate) fn generate_request_headers(inbox_url: &Url) -> HeaderMap { } #[cfg(test)] +#[allow(clippy::unwrap_used)] mod tests { use super::*; use crate::{config::FederationConfig, http_signatures::generate_actor_keypair}; diff --git a/src/actix_web/inbox.rs b/src/actix_web/inbox.rs index b9c6379..7c10659 100644 --- a/src/actix_web/inbox.rs +++ b/src/actix_web/inbox.rs @@ -45,6 +45,7 @@ where } #[cfg(test)] +#[allow(clippy::unwrap_used)] mod test { use super::*; use crate::{ diff --git a/src/fetch/object_id.rs b/src/fetch/object_id.rs index 50e75bc..d30fe0a 100644 --- a/src/fetch/object_id.rs +++ b/src/fetch/object_id.rs @@ -339,6 +339,7 @@ const _IMPL_DIESEL_NEW_TYPE_FOR_OBJECT_ID: () = { }; #[cfg(test)] +#[allow(clippy::unwrap_used)] pub mod tests { use super::*; use crate::traits::tests::DbUser; diff --git a/src/fetch/webfinger.rs b/src/fetch/webfinger.rs index f065618..7ca4903 100644 --- a/src/fetch/webfinger.rs +++ b/src/fetch/webfinger.rs @@ -245,6 +245,7 @@ pub struct WebfingerLink { } #[cfg(test)] +#[allow(clippy::unwrap_used)] mod tests { use super::*; use crate::{ diff --git a/src/http_signatures.rs b/src/http_signatures.rs index bc27ee5..7e26e8d 100644 --- a/src/http_signatures.rs +++ b/src/http_signatures.rs @@ -275,6 +275,7 @@ pub(crate) fn verify_body_hash( } #[cfg(test)] +#[allow(clippy::unwrap_used)] pub mod test { use super::*; use crate::activity_sending::generate_request_headers;