From: cetra3 Date: Mon, 17 Jul 2023 15:04:14 +0000 (+0930) Subject: Cache & Optimize Woodpecker CI (#3450) X-Git-Url: http://these/git/%22https:/nerdica.net/photo/contact/80/README.ja.md?a=commitdiff_plain;h=92568956353f21649ed9aff68b42699c9d036f30;p=lemmy.git Cache & Optimize Woodpecker CI (#3450) * Try using drone cache plugin * Try another path * Include volume * Fix formatting * Include fmt * Exclude cargo dir from prettier * Don't override cargo * Just do check * Add cache key * Use different cache plugin * Add clippy * Try minio * Add quotes * Try adding secrets * Try again * Again * Use correct secret formation * Add back clippy * Use secret for the root bucket name * Try drone cache instead * Add region * Add path-style option * Include cargo clippy * Include everything again * Fix formatting * Don't run clippy twice * Add `allow` statements for tests to pass * Adjust endpoint to be a secret * Fix prettier * Merge & fix tests * Try to restart the woodpecker test * Change the ENV var name --------- Co-authored-by: Dessalines --- diff --git a/.woodpecker.yml b/.woodpecker.yml index 07b0d60b..a595744a 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -27,6 +27,29 @@ pipeline: commands: - prettier -c . '!**/volumes' '!**/dist' '!target' '!**/translations' + restore-cache: + image: meltwater/drone-cache:v1 + pull: true + settings: + restore: true + endpoint: + from_secret: MINIO_ENDPOINT + access-key: + from_secret: MINIO_WRITE_USER + secret-key: + from_secret: MINIO_WRITE_PASSWORD + bucket: + from_secret: MINIO_BUCKET + region: us-east-1 + cache_key: "rust-cache" + path-style: true + mount: + - ".cargo" + - "target" + - "api_tests/node_modules" + secrets: + [MINIO_ENDPOINT, MINIO_WRITE_USER, MINIO_WRITE_PASSWORD, MINIO_BUCKET] + taplo_check: image: tamasfe/taplo:0.8.1 commands: @@ -40,7 +63,7 @@ pipeline: CARGO_HOME: .cargo commands: # need make existing toolchain available - - cp ~/.cargo . -r + - cp -n ~/.cargo . -r - rustup toolchain install nightly-2023-07-10 - rustup component add rustfmt --toolchain nightly-2023-07-10 - cargo +nightly-2023-07-10 fmt -- --check @@ -68,7 +91,6 @@ pipeline: -D clippy::explicit_into_iter_loop -D clippy::explicit_iter_loop -D clippy::needless_collect - - cargo clippy --workspace --features console -- -D clippy::unwrap_used -D clippy::indexing_slicing # when: @@ -158,6 +180,29 @@ pipeline: # when: # platform: linux/amd64 + rebuild-cache: + image: meltwater/drone-cache:v1 + pull: true + settings: + rebuild: true + endpoint: + from_secret: MINIO_ENDPOINT + access-key: + from_secret: MINIO_WRITE_USER + secret-key: + from_secret: MINIO_WRITE_PASSWORD + bucket: + from_secret: MINIO_BUCKET + cache_key: "rust-cache" + region: us-east-1 + path-style: true + mount: + - ".cargo" + - "target" + - "api_tests/node_modules" + secrets: + [MINIO_ENDPOINT, MINIO_WRITE_USER, MINIO_WRITE_PASSWORD, MINIO_BUCKET] + publish_release_docker: image: woodpeckerci/plugin-docker-buildx secrets: [docker_username, docker_password] diff --git a/crates/api/src/lib.rs b/crates/api/src/lib.rs index 988dac27..9d3cf211 100644 --- a/crates/api/src/lib.rs +++ b/crates/api/src/lib.rs @@ -76,6 +76,9 @@ pub(crate) fn check_report_reason(reason: &str, local_site: &LocalSite) -> Resul #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use lemmy_api_common::utils::check_validator_time; use lemmy_db_schema::{ source::{ diff --git a/crates/api_common/src/request.rs b/crates/api_common/src/request.rs index dc09ecaa..82126887 100644 --- a/crates/api_common/src/request.rs +++ b/crates/api_common/src/request.rs @@ -270,6 +270,9 @@ pub fn build_user_agent(settings: &Settings) -> String { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::request::{ build_user_agent, fetch_site_metadata, diff --git a/crates/api_common/src/utils.rs b/crates/api_common/src/utils.rs index 97afeaf0..d259b9e4 100644 --- a/crates/api_common/src/utils.rs +++ b/crates/api_common/src/utils.rs @@ -731,6 +731,9 @@ pub async fn delete_user_account( #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::utils::{honeypot_check, password_length_check}; #[test] diff --git a/crates/api_crud/src/site/create.rs b/crates/api_crud/src/site/create.rs index dab504c8..540b3c6c 100644 --- a/crates/api_crud/src/site/create.rs +++ b/crates/api_crud/src/site/create.rs @@ -183,6 +183,9 @@ fn validate_create_payload(local_site: &LocalSite, create_site: &CreateSite) -> #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::site::create::validate_create_payload; use lemmy_api_common::site::CreateSite; use lemmy_db_schema::{source::local_site::LocalSite, ListingType, RegistrationMode}; diff --git a/crates/api_crud/src/site/mod.rs b/crates/api_crud/src/site/mod.rs index d7ae94ac..652b9e65 100644 --- a/crates/api_crud/src/site/mod.rs +++ b/crates/api_crud/src/site/mod.rs @@ -42,6 +42,9 @@ pub fn application_question_check( #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::site::{application_question_check, site_default_post_listing_type_check}; use lemmy_db_schema::{ListingType, RegistrationMode}; diff --git a/crates/api_crud/src/site/update.rs b/crates/api_crud/src/site/update.rs index e5c0bc5e..ea3c53aa 100644 --- a/crates/api_crud/src/site/update.rs +++ b/crates/api_crud/src/site/update.rs @@ -217,6 +217,9 @@ fn validate_update_payload(local_site: &LocalSite, edit_site: &EditSite) -> Lemm #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::site::update::validate_update_payload; use lemmy_api_common::site::EditSite; use lemmy_db_schema::{source::local_site::LocalSite, ListingType, RegistrationMode}; diff --git a/crates/apub/src/activity_lists.rs b/crates/apub/src/activity_lists.rs index 70584955..4cce3372 100644 --- a/crates/apub/src/activity_lists.rs +++ b/crates/apub/src/activity_lists.rs @@ -134,6 +134,9 @@ impl InCommunity for AnnouncableActivities { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ activity_lists::{ GroupInboxActivities, diff --git a/crates/apub/src/collections/community_moderators.rs b/crates/apub/src/collections/community_moderators.rs index 336bbfb1..17265e2d 100644 --- a/crates/apub/src/collections/community_moderators.rs +++ b/crates/apub/src/collections/community_moderators.rs @@ -100,6 +100,9 @@ impl Collection for ApubCommunityModerators { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use super::*; use crate::{ objects::{ diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index 0a318591..2954de09 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -179,6 +179,9 @@ impl Object for ApubComment { #[cfg(test)] pub(crate) mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use super::*; use crate::{ objects::{ diff --git a/crates/apub/src/objects/community.rs b/crates/apub/src/objects/community.rs index b25a60d7..75eb941b 100644 --- a/crates/apub/src/objects/community.rs +++ b/crates/apub/src/objects/community.rs @@ -204,6 +204,9 @@ impl ApubCommunity { #[cfg(test)] pub(crate) mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use super::*; use crate::{ objects::{instance::tests::parse_lemmy_instance, tests::init_context}, diff --git a/crates/apub/src/objects/instance.rs b/crates/apub/src/objects/instance.rs index 026b3727..7933d470 100644 --- a/crates/apub/src/objects/instance.rs +++ b/crates/apub/src/objects/instance.rs @@ -206,6 +206,9 @@ pub(crate) async fn remote_instance_inboxes(pool: &mut DbPool<'_>) -> Result Result<( #[cfg(test)] pub(crate) mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use activitypub_federation::config::{Data, FederationConfig}; use anyhow::anyhow; use lemmy_api_common::{context::LemmyContext, request::build_user_agent}; diff --git a/crates/apub/src/objects/person.rs b/crates/apub/src/objects/person.rs index 3c2b238b..d28f8c7c 100644 --- a/crates/apub/src/objects/person.rs +++ b/crates/apub/src/objects/person.rs @@ -195,6 +195,9 @@ impl Actor for ApubPerson { #[cfg(test)] pub(crate) mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use super::*; use crate::{ objects::{ diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index d252a8ea..48b573d3 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -280,6 +280,9 @@ impl Object for ApubPost { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use super::*; use crate::{ objects::{ diff --git a/crates/apub/src/objects/private_message.rs b/crates/apub/src/objects/private_message.rs index c986e576..69a2638a 100644 --- a/crates/apub/src/objects/private_message.rs +++ b/crates/apub/src/objects/private_message.rs @@ -136,6 +136,9 @@ impl Object for ApubPrivateMessage { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use super::*; use crate::{ objects::{ diff --git a/crates/apub/src/protocol/activities/block/mod.rs b/crates/apub/src/protocol/activities/block/mod.rs index eaf05b9a..1b00245f 100644 --- a/crates/apub/src/protocol/activities/block/mod.rs +++ b/crates/apub/src/protocol/activities/block/mod.rs @@ -3,6 +3,9 @@ pub mod undo_block_user; #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::protocol::{ activities::block::{block_user::BlockUser, undo_block_user::UndoBlockUser}, tests::test_parse_lemmy_item, diff --git a/crates/apub/src/protocol/activities/community/mod.rs b/crates/apub/src/protocol/activities/community/mod.rs index d43e111e..99a6d0b9 100644 --- a/crates/apub/src/protocol/activities/community/mod.rs +++ b/crates/apub/src/protocol/activities/community/mod.rs @@ -7,6 +7,9 @@ pub mod update; #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::protocol::{ activities::community::{ announce::AnnounceActivity, diff --git a/crates/apub/src/protocol/activities/create_or_update/mod.rs b/crates/apub/src/protocol/activities/create_or_update/mod.rs index 9e41d57f..a516bf9b 100644 --- a/crates/apub/src/protocol/activities/create_or_update/mod.rs +++ b/crates/apub/src/protocol/activities/create_or_update/mod.rs @@ -4,6 +4,9 @@ pub mod page; #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::protocol::{ activities::create_or_update::{ chat_message::CreateOrUpdateChatMessage, diff --git a/crates/apub/src/protocol/activities/deletion/mod.rs b/crates/apub/src/protocol/activities/deletion/mod.rs index fe22c001..226cd2ca 100644 --- a/crates/apub/src/protocol/activities/deletion/mod.rs +++ b/crates/apub/src/protocol/activities/deletion/mod.rs @@ -4,6 +4,9 @@ pub mod undo_delete; #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::protocol::{ activities::deletion::{delete::Delete, delete_user::DeleteUser, undo_delete::UndoDelete}, tests::test_parse_lemmy_item, diff --git a/crates/apub/src/protocol/activities/following/mod.rs b/crates/apub/src/protocol/activities/following/mod.rs index e1b36653..32980734 100644 --- a/crates/apub/src/protocol/activities/following/mod.rs +++ b/crates/apub/src/protocol/activities/following/mod.rs @@ -4,6 +4,9 @@ pub mod undo_follow; #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::protocol::{ activities::following::{accept::AcceptFollow, follow::Follow, undo_follow::UndoFollow}, tests::test_parse_lemmy_item, diff --git a/crates/apub/src/protocol/activities/mod.rs b/crates/apub/src/protocol/activities/mod.rs index a7ce3701..24095fab 100644 --- a/crates/apub/src/protocol/activities/mod.rs +++ b/crates/apub/src/protocol/activities/mod.rs @@ -16,6 +16,9 @@ pub enum CreateOrUpdateType { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::protocol::{ activities::{ community::announce::AnnounceActivity, diff --git a/crates/apub/src/protocol/activities/voting/mod.rs b/crates/apub/src/protocol/activities/voting/mod.rs index 94f759ed..26a9d01a 100644 --- a/crates/apub/src/protocol/activities/voting/mod.rs +++ b/crates/apub/src/protocol/activities/voting/mod.rs @@ -3,6 +3,9 @@ pub mod vote; #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::protocol::{ activities::voting::{undo_vote::UndoVote, vote::Vote}, tests::test_parse_lemmy_item, diff --git a/crates/apub/src/protocol/collections/mod.rs b/crates/apub/src/protocol/collections/mod.rs index 41b4a9f5..2362a998 100644 --- a/crates/apub/src/protocol/collections/mod.rs +++ b/crates/apub/src/protocol/collections/mod.rs @@ -6,6 +6,9 @@ pub(crate) mod group_outbox; #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::protocol::{ collections::{ empty_outbox::EmptyOutbox, diff --git a/crates/apub/src/protocol/mod.rs b/crates/apub/src/protocol/mod.rs index bfc9df77..dba21f99 100644 --- a/crates/apub/src/protocol/mod.rs +++ b/crates/apub/src/protocol/mod.rs @@ -89,6 +89,9 @@ pub trait InCommunity { #[cfg(test)] pub(crate) mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use activitypub_federation::protocol::context::WithContext; use assert_json_diff::assert_json_include; use lemmy_utils::error::LemmyError; diff --git a/crates/apub/src/protocol/objects/mod.rs b/crates/apub/src/protocol/objects/mod.rs index f93308bb..9a3dab18 100644 --- a/crates/apub/src/protocol/objects/mod.rs +++ b/crates/apub/src/protocol/objects/mod.rs @@ -95,6 +95,9 @@ impl LanguageTag { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::protocol::{ objects::{ chat_message::ChatMessage, diff --git a/crates/apub/src/protocol/objects/page.rs b/crates/apub/src/protocol/objects/page.rs index c48cabfa..f3308b07 100644 --- a/crates/apub/src/protocol/objects/page.rs +++ b/crates/apub/src/protocol/objects/page.rs @@ -242,6 +242,9 @@ where #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::protocol::{objects::page::Page, tests::test_parse_lemmy_item}; #[test] diff --git a/crates/db_schema/src/aggregates/comment_aggregates.rs b/crates/db_schema/src/aggregates/comment_aggregates.rs index 12b57222..e081d1a1 100644 --- a/crates/db_schema/src/aggregates/comment_aggregates.rs +++ b/crates/db_schema/src/aggregates/comment_aggregates.rs @@ -35,6 +35,9 @@ impl CommentAggregates { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ aggregates::comment_aggregates::CommentAggregates, source::{ diff --git a/crates/db_schema/src/aggregates/community_aggregates.rs b/crates/db_schema/src/aggregates/community_aggregates.rs index 61abd193..1cd23e03 100644 --- a/crates/db_schema/src/aggregates/community_aggregates.rs +++ b/crates/db_schema/src/aggregates/community_aggregates.rs @@ -19,6 +19,9 @@ impl CommunityAggregates { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ aggregates::community_aggregates::CommunityAggregates, source::{ diff --git a/crates/db_schema/src/aggregates/person_aggregates.rs b/crates/db_schema/src/aggregates/person_aggregates.rs index e03497da..43feadd4 100644 --- a/crates/db_schema/src/aggregates/person_aggregates.rs +++ b/crates/db_schema/src/aggregates/person_aggregates.rs @@ -19,6 +19,9 @@ impl PersonAggregates { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ aggregates::person_aggregates::PersonAggregates, source::{ diff --git a/crates/db_schema/src/aggregates/post_aggregates.rs b/crates/db_schema/src/aggregates/post_aggregates.rs index 8ce2d38f..02037082 100644 --- a/crates/db_schema/src/aggregates/post_aggregates.rs +++ b/crates/db_schema/src/aggregates/post_aggregates.rs @@ -35,6 +35,9 @@ impl PostAggregates { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ aggregates::post_aggregates::PostAggregates, source::{ diff --git a/crates/db_schema/src/aggregates/site_aggregates.rs b/crates/db_schema/src/aggregates/site_aggregates.rs index 1fe90e0f..ea3da85a 100644 --- a/crates/db_schema/src/aggregates/site_aggregates.rs +++ b/crates/db_schema/src/aggregates/site_aggregates.rs @@ -15,6 +15,9 @@ impl SiteAggregates { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ aggregates::site_aggregates::SiteAggregates, source::{ diff --git a/crates/db_schema/src/impls/activity.rs b/crates/db_schema/src/impls/activity.rs index adda4fc7..8c4a0a15 100644 --- a/crates/db_schema/src/impls/activity.rs +++ b/crates/db_schema/src/impls/activity.rs @@ -58,6 +58,9 @@ impl ReceivedActivity { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use super::*; use crate::utils::build_db_pool_for_tests; use serde_json::json; diff --git a/crates/db_schema/src/impls/actor_language.rs b/crates/db_schema/src/impls/actor_language.rs index eb68d2ee..313762a7 100644 --- a/crates/db_schema/src/impls/actor_language.rs +++ b/crates/db_schema/src/impls/actor_language.rs @@ -384,6 +384,9 @@ async fn convert_read_languages( #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use super::*; use crate::{ impls::actor_language::{ diff --git a/crates/db_schema/src/impls/captcha_answer.rs b/crates/db_schema/src/impls/captcha_answer.rs index fe85b78b..0404ce00 100644 --- a/crates/db_schema/src/impls/captcha_answer.rs +++ b/crates/db_schema/src/impls/captcha_answer.rs @@ -50,6 +50,9 @@ impl CaptchaAnswer { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ source::captcha_answer::{CaptchaAnswer, CaptchaAnswerForm, CheckCaptchaAnswer}, utils::build_db_pool_for_tests, diff --git a/crates/db_schema/src/impls/comment.rs b/crates/db_schema/src/impls/comment.rs index 2b5b74a1..53463432 100644 --- a/crates/db_schema/src/impls/comment.rs +++ b/crates/db_schema/src/impls/comment.rs @@ -251,6 +251,9 @@ impl Saveable for CommentSaved { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ newtypes::LanguageId, source::{ diff --git a/crates/db_schema/src/impls/comment_reply.rs b/crates/db_schema/src/impls/comment_reply.rs index c5939334..eeb171f5 100644 --- a/crates/db_schema/src/impls/comment_reply.rs +++ b/crates/db_schema/src/impls/comment_reply.rs @@ -81,6 +81,9 @@ impl CommentReply { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ source::{ comment::{Comment, CommentInsertForm}, diff --git a/crates/db_schema/src/impls/community.rs b/crates/db_schema/src/impls/community.rs index babb9a5a..258e4150 100644 --- a/crates/db_schema/src/impls/community.rs +++ b/crates/db_schema/src/impls/community.rs @@ -331,6 +331,9 @@ impl ApubActor for Community { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ source::{ community::{ diff --git a/crates/db_schema/src/impls/federation_allowlist.rs b/crates/db_schema/src/impls/federation_allowlist.rs index d4aed484..eb67acce 100644 --- a/crates/db_schema/src/impls/federation_allowlist.rs +++ b/crates/db_schema/src/impls/federation_allowlist.rs @@ -49,6 +49,9 @@ impl FederationAllowList { } #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ source::{federation_allowlist::FederationAllowList, instance::Instance}, utils::build_db_pool_for_tests, diff --git a/crates/db_schema/src/impls/language.rs b/crates/db_schema/src/impls/language.rs index e459d989..53aadbac 100644 --- a/crates/db_schema/src/impls/language.rs +++ b/crates/db_schema/src/impls/language.rs @@ -42,6 +42,9 @@ impl Language { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{source::language::Language, utils::build_db_pool_for_tests}; use serial_test::serial; diff --git a/crates/db_schema/src/impls/moderator.rs b/crates/db_schema/src/impls/moderator.rs index 32201b3c..12344f71 100644 --- a/crates/db_schema/src/impls/moderator.rs +++ b/crates/db_schema/src/impls/moderator.rs @@ -551,6 +551,9 @@ impl Crud for AdminPurgeComment { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ source::{ comment::{Comment, CommentInsertForm}, diff --git a/crates/db_schema/src/impls/password_reset_request.rs b/crates/db_schema/src/impls/password_reset_request.rs index 3d1a1e8e..ae4483d6 100644 --- a/crates/db_schema/src/impls/password_reset_request.rs +++ b/crates/db_schema/src/impls/password_reset_request.rs @@ -107,6 +107,9 @@ fn bytes_to_hex(bytes: Vec) -> String { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ source::{ instance::Instance, diff --git a/crates/db_schema/src/impls/person.rs b/crates/db_schema/src/impls/person.rs index bd9ad405..2e086dcb 100644 --- a/crates/db_schema/src/impls/person.rs +++ b/crates/db_schema/src/impls/person.rs @@ -200,6 +200,9 @@ impl PersonFollower { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ source::{ instance::Instance, diff --git a/crates/db_schema/src/impls/person_mention.rs b/crates/db_schema/src/impls/person_mention.rs index 25b199e6..27c04217 100644 --- a/crates/db_schema/src/impls/person_mention.rs +++ b/crates/db_schema/src/impls/person_mention.rs @@ -82,6 +82,9 @@ impl PersonMention { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ source::{ comment::{Comment, CommentInsertForm}, diff --git a/crates/db_schema/src/impls/post.rs b/crates/db_schema/src/impls/post.rs index b775860a..f10d0cd2 100644 --- a/crates/db_schema/src/impls/post.rs +++ b/crates/db_schema/src/impls/post.rs @@ -329,6 +329,9 @@ impl Readable for PostRead { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ source::{ community::{Community, CommunityInsertForm}, diff --git a/crates/db_schema/src/impls/private_message.rs b/crates/db_schema/src/impls/private_message.rs index 2febaa76..fb1d4b90 100644 --- a/crates/db_schema/src/impls/private_message.rs +++ b/crates/db_schema/src/impls/private_message.rs @@ -91,6 +91,9 @@ impl PrivateMessage { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ source::{ instance::Instance, diff --git a/crates/db_schema/src/utils.rs b/crates/db_schema/src/utils.rs index 5d5bfafa..94c867d6 100644 --- a/crates/db_schema/src/utils.rs +++ b/crates/db_schema/src/utils.rs @@ -406,6 +406,9 @@ where #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use super::{fuzzy_search, *}; use crate::utils::is_email_regex; diff --git a/crates/db_views/src/comment_report_view.rs b/crates/db_views/src/comment_report_view.rs index c28c7d67..a09971db 100644 --- a/crates/db_views/src/comment_report_view.rs +++ b/crates/db_views/src/comment_report_view.rs @@ -269,6 +269,9 @@ impl JoinView for CommentReportView { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::comment_report_view::{CommentReportQuery, CommentReportView}; use lemmy_db_schema::{ aggregates::structs::CommentAggregates, diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 435a3d82..9a9685c7 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -382,6 +382,9 @@ impl JoinView for CommentView { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::comment_view::{ Comment, CommentQuery, diff --git a/crates/db_views/src/post_report_view.rs b/crates/db_views/src/post_report_view.rs index fff2a2bc..50b35b1c 100644 --- a/crates/db_views/src/post_report_view.rs +++ b/crates/db_views/src/post_report_view.rs @@ -265,6 +265,9 @@ impl JoinView for PostReportView { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::post_report_view::{PostReportQuery, PostReportView}; use lemmy_db_schema::{ aggregates::structs::PostAggregates, diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index 466713e1..0e6ad703 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -473,6 +473,9 @@ impl JoinView for PostView { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::post_view::{PostQuery, PostView}; use lemmy_db_schema::{ aggregates::structs::PostAggregates, diff --git a/crates/db_views/src/private_message_report_view.rs b/crates/db_views/src/private_message_report_view.rs index bdffa42e..7ceca271 100644 --- a/crates/db_views/src/private_message_report_view.rs +++ b/crates/db_views/src/private_message_report_view.rs @@ -148,6 +148,9 @@ impl JoinView for PrivateMessageReportView { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::private_message_report_view::PrivateMessageReportQuery; use lemmy_db_schema::{ source::{ diff --git a/crates/db_views/src/registration_application_view.rs b/crates/db_views/src/registration_application_view.rs index 1ee82044..106e41e4 100644 --- a/crates/db_views/src/registration_application_view.rs +++ b/crates/db_views/src/registration_application_view.rs @@ -160,6 +160,9 @@ impl JoinView for RegistrationApplicationView { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::registration_application_view::{ RegistrationApplicationQuery, RegistrationApplicationView, diff --git a/crates/utils/src/error.rs b/crates/utils/src/error.rs index 78590a6a..ffc1723b 100644 --- a/crates/utils/src/error.rs +++ b/crates/utils/src/error.rs @@ -249,6 +249,8 @@ impl LemmyErrorExt2 for Result { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] use super::*; use actix_web::{body::MessageBody, ResponseError}; use std::fs::read_to_string; diff --git a/crates/utils/src/rate_limit/mod.rs b/crates/utils/src/rate_limit/mod.rs index 7a5c1ec6..1bb6f1b5 100644 --- a/crates/utils/src/rate_limit/mod.rs +++ b/crates/utils/src/rate_limit/mod.rs @@ -275,6 +275,9 @@ fn parse_ip(addr: &str) -> Option { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + #[test] fn test_parse_ip() { let ip_addrs = [ diff --git a/crates/utils/src/rate_limit/rate_limiter.rs b/crates/utils/src/rate_limit/rate_limiter.rs index ed3dc569..3acf23ba 100644 --- a/crates/utils/src/rate_limit/rate_limiter.rs +++ b/crates/utils/src/rate_limit/rate_limiter.rs @@ -237,6 +237,9 @@ fn split_ipv6(ip: Ipv6Addr) -> ([u8; 6], u8, u8) { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + #[test] fn test_split_ipv6() { let ip = std::net::Ipv6Addr::new( diff --git a/crates/utils/src/utils/markdown.rs b/crates/utils/src/utils/markdown.rs index 451c86bc..5f851589 100644 --- a/crates/utils/src/utils/markdown.rs +++ b/crates/utils/src/utils/markdown.rs @@ -18,6 +18,9 @@ pub fn markdown_to_html(text: &str) -> String { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::utils::markdown::markdown_to_html; #[test] diff --git a/crates/utils/src/utils/markdown/spoiler_rule.rs b/crates/utils/src/utils/markdown/spoiler_rule.rs index 1a564f07..bae858bf 100644 --- a/crates/utils/src/utils/markdown/spoiler_rule.rs +++ b/crates/utils/src/utils/markdown/spoiler_rule.rs @@ -135,6 +135,9 @@ pub fn add(markdown_parser: &mut MarkdownIt) { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::utils::markdown::spoiler_rule::add; use markdown_it::MarkdownIt; diff --git a/crates/utils/src/utils/mention.rs b/crates/utils/src/utils/mention.rs index 1dcace37..a2958e49 100644 --- a/crates/utils/src/utils/mention.rs +++ b/crates/utils/src/utils/mention.rs @@ -35,6 +35,9 @@ pub fn scrape_text_for_mentions(text: &str) -> Vec { #[cfg(test)] mod test { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::utils::mention::scrape_text_for_mentions; #[test] diff --git a/crates/utils/src/utils/slurs.rs b/crates/utils/src/utils/slurs.rs index b041eb46..cc2d6a3e 100644 --- a/crates/utils/src/utils/slurs.rs +++ b/crates/utils/src/utils/slurs.rs @@ -65,6 +65,9 @@ pub(crate) fn slurs_vec_to_str(slurs: &[&str]) -> String { #[cfg(test)] mod test { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::utils::slurs::{remove_slurs, slur_check, slurs_vec_to_str}; use regex::RegexBuilder; diff --git a/crates/utils/src/utils/validation.rs b/crates/utils/src/utils/validation.rs index b42fe1ad..0c955b12 100644 --- a/crates/utils/src/utils/validation.rs +++ b/crates/utils/src/utils/validation.rs @@ -311,6 +311,9 @@ pub fn check_url_scheme(url: &Option) -> LemmyResult<()> { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use super::build_totp_2fa; use crate::{ error::LemmyErrorType, diff --git a/scripts/fix-clippy.sh b/scripts/fix-clippy.sh index 5cf870b8..5ad3ca8b 100755 --- a/scripts/fix-clippy.sh +++ b/scripts/fix-clippy.sh @@ -17,9 +17,7 @@ cargo clippy --workspace --fix --allow-staged --allow-dirty --tests --all-target -D clippy::get_first \ -D clippy::explicit_into_iter_loop \ -D clippy::explicit_iter_loop \ - -D clippy::needless_collect - -cargo clippy --workspace --features console -- \ + -D clippy::needless_collect \ -D clippy::unwrap_used \ -D clippy::indexing_slicing diff --git a/src/lib.rs b/src/lib.rs index b50298b0..55bb9160 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -163,7 +163,7 @@ pub async fn start_lemmy_server() -> Result<(), LemmyError> { let prom_api_metrics = PrometheusMetricsBuilder::new("lemmy_api") .registry(default_registry().clone()) .build() - .unwrap(); + .expect("Should always be buildable"); // Create Http server with websocket support HttpServer::new(move || { diff --git a/src/prometheus_metrics.rs b/src/prometheus_metrics.rs index 9e0ffde3..ad964263 100644 --- a/src/prometheus_metrics.rs +++ b/src/prometheus_metrics.rs @@ -1,3 +1,5 @@ +// TODO: should really not unwrap everywhere here.... +#![allow(clippy::unwrap_used)] use actix_web::{rt::System, web, App, HttpResponse, HttpServer, Responder}; use lemmy_api_common::context::LemmyContext; use lemmy_utils::settings::structs::PrometheusConfig; diff --git a/src/scheduled_tasks.rs b/src/scheduled_tasks.rs index a4d09268..4928fe8d 100644 --- a/src/scheduled_tasks.rs +++ b/src/scheduled_tasks.rs @@ -401,6 +401,9 @@ fn update_instance_software(conn: &mut PgConnection, user_agent: &str) -> LemmyR #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use lemmy_routes::nodeinfo::NodeInfo; use reqwest::Client;