Cache & Optimize Woodpecker CI (#3450)
authorcetra3 <cetra3@hotmail.com>
Mon, 17 Jul 2023 15:04:14 +0000 (00:34 +0930)
committerGitHub <noreply@github.com>
Mon, 17 Jul 2023 15:04:14 +0000 (11:04 -0400)
* 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 <dessalines@users.noreply.github.com>
65 files changed:
.woodpecker.yml
crates/api/src/lib.rs
crates/api_common/src/request.rs
crates/api_common/src/utils.rs
crates/api_crud/src/site/create.rs
crates/api_crud/src/site/mod.rs
crates/api_crud/src/site/update.rs
crates/apub/src/activity_lists.rs
crates/apub/src/collections/community_moderators.rs
crates/apub/src/objects/comment.rs
crates/apub/src/objects/community.rs
crates/apub/src/objects/instance.rs
crates/apub/src/objects/mod.rs
crates/apub/src/objects/person.rs
crates/apub/src/objects/post.rs
crates/apub/src/objects/private_message.rs
crates/apub/src/protocol/activities/block/mod.rs
crates/apub/src/protocol/activities/community/mod.rs
crates/apub/src/protocol/activities/create_or_update/mod.rs
crates/apub/src/protocol/activities/deletion/mod.rs
crates/apub/src/protocol/activities/following/mod.rs
crates/apub/src/protocol/activities/mod.rs
crates/apub/src/protocol/activities/voting/mod.rs
crates/apub/src/protocol/collections/mod.rs
crates/apub/src/protocol/mod.rs
crates/apub/src/protocol/objects/mod.rs
crates/apub/src/protocol/objects/page.rs
crates/db_schema/src/aggregates/comment_aggregates.rs
crates/db_schema/src/aggregates/community_aggregates.rs
crates/db_schema/src/aggregates/person_aggregates.rs
crates/db_schema/src/aggregates/post_aggregates.rs
crates/db_schema/src/aggregates/site_aggregates.rs
crates/db_schema/src/impls/activity.rs
crates/db_schema/src/impls/actor_language.rs
crates/db_schema/src/impls/captcha_answer.rs
crates/db_schema/src/impls/comment.rs
crates/db_schema/src/impls/comment_reply.rs
crates/db_schema/src/impls/community.rs
crates/db_schema/src/impls/federation_allowlist.rs
crates/db_schema/src/impls/language.rs
crates/db_schema/src/impls/moderator.rs
crates/db_schema/src/impls/password_reset_request.rs
crates/db_schema/src/impls/person.rs
crates/db_schema/src/impls/person_mention.rs
crates/db_schema/src/impls/post.rs
crates/db_schema/src/impls/private_message.rs
crates/db_schema/src/utils.rs
crates/db_views/src/comment_report_view.rs
crates/db_views/src/comment_view.rs
crates/db_views/src/post_report_view.rs
crates/db_views/src/post_view.rs
crates/db_views/src/private_message_report_view.rs
crates/db_views/src/registration_application_view.rs
crates/utils/src/error.rs
crates/utils/src/rate_limit/mod.rs
crates/utils/src/rate_limit/rate_limiter.rs
crates/utils/src/utils/markdown.rs
crates/utils/src/utils/markdown/spoiler_rule.rs
crates/utils/src/utils/mention.rs
crates/utils/src/utils/slurs.rs
crates/utils/src/utils/validation.rs
scripts/fix-clippy.sh
src/lib.rs
src/prometheus_metrics.rs
src/scheduled_tasks.rs

index 07b0d60bc097c6d2d47dbc5a197dae28838e9e52..a595744ad2b74956067c6b67c068a62cb3e309f7 100644 (file)
@@ -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]
index 988dac27ab4085f95c30f216eba42343d88d336e..9d3cf211c233ef5da1df63408310b18cb69ef840 100644 (file)
@@ -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::{
index dc09ecaa7f3f69a88c852498064b71eb34ee1d53..82126887ab4c66cd4b4ed12346ff3ad6907364cc 100644 (file)
@@ -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,
index 97afeaf0c61dc20420f575b4a05cefb3c24f8e7e..d259b9e4c1c0c14130c17843ff82a3e57ab615d2 100644 (file)
@@ -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]
index dab504c8d5d8ac9c93dc3daa33f4e0c50c084159..540b3c6c1518d685127029542abd6f7117e0f007 100644 (file)
@@ -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};
index d7ae94aca7ed3a1cfdbb852fe11989eb36dc0315..652b9e6564629d0dddb5b5dea2fb4c36730881bb 100644 (file)
@@ -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};
 
index e5c0bc5e224bffadad252c08a33c519a4f7b87a0..ea3c53aa7fa4bd054c848c57750253b87d4eec2b 100644 (file)
@@ -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};
index 705849552263077a3c56abec3f5c3ebdbff2fbf5..4cce3372fa01a6cba14e67efb7e959e97fe05cf3 100644 (file)
@@ -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,
index 336bbfb12471aaa26497de42c23e75c03d080aa6..17265e2d63ea41620308408d563f2510954ecaa0 100644 (file)
@@ -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::{
index 0a31859102f6d39f84a6ec33ce938faec5449e0e..2954de0968cab4af742a911b161cfabfdb889c00 100644 (file)
@@ -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::{
index b25a60d738fbc7f6ca54de7c0baa1e0173380f4c..75eb941b1b3af0589cf29782277e4ef6e388c4c9 100644 (file)
@@ -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},
index 026b3727870342c0f29b6535d6bff55dd18e6ed9..7933d47057fde7732615922c9ba4c507f92d113f 100644 (file)
@@ -206,6 +206,9 @@ pub(crate) async fn remote_instance_inboxes(pool: &mut DbPool<'_>) -> Result<Vec
 
 #[cfg(test)]
 pub(crate) mod tests {
+  #![allow(clippy::unwrap_used)]
+  #![allow(clippy::indexing_slicing)]
+
   use super::*;
   use crate::{objects::tests::init_context, protocol::tests::file_to_json_object};
   use lemmy_db_schema::traits::Crud;
index b204efb084487f17d0060763bb4b09015e6f0d7f..b3653172ac5242a7cb255408a33baf0abce194e1 100644 (file)
@@ -54,6 +54,9 @@ pub(crate) fn verify_is_remote_object(id: &Url, settings: &Settings) -> 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};
index 3c2b238b1a690345320cf4ed2ef8cb83a7be216d..d28f8c7cf335982d07b74753ea447c9c06eed703 100644 (file)
@@ -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::{
index d252a8ea745c76e272042d1b44239c2606c8affe..48b573d30ab0dfdfd58398cdd2159ce7ee266a85 100644 (file)
@@ -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::{
index c986e576e818d959d203eb8af270a625e2f1f6c2..69a2638ad09dfc745539fcae548c1c1165aec931 100644 (file)
@@ -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::{
index eaf05b9ac8b4b34a58548bd9c0774999ea01f004..1b00245f80ff2959e050bd4985fd1b7ba05d268e 100644 (file)
@@ -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,
index d43e111e0b989b814c609e7990578ca806f33f33..99a6d0b9cc1e8252b085c170434f45b8b59d9401 100644 (file)
@@ -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,
index 9e41d57fb1a91eb4aaece13d24bf6592e62606c7..a516bf9b406c8a7ad83c34c85055694f34ee29e7 100644 (file)
@@ -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,
index fe22c001011b03d3a459d0827528ae9ed86cdebe..226cd2cac0c12e480140de6720bfaef032ee08da 100644 (file)
@@ -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,
index e1b3665300e1e47b08312af0fc47228515f2f599..3298073430d87cca5878e76abed6fce3bab5291a 100644 (file)
@@ -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,
index a7ce37015adc9f246650f226d6f5a48024c672f0..24095faba7148f0049d0d568526b63704235dd1c 100644 (file)
@@ -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,
index 94f759ed83697f166ec71bf5508957ec927d4dba..26a9d01a21786d2148c6365a7a990500507a2bdc 100644 (file)
@@ -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,
index 41b4a9f584cc9bda5af83f4785ad00b421d54b77..2362a998aaa4a94736564451bfafc4d3bc4c706f 100644 (file)
@@ -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,
index bfc9df772a25d532b7cd9ead706de4a777157f8c..dba21f99d346d016ce11b8a945f0b83826d8ca61 100644 (file)
@@ -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;
index f93308bb35c3670d7c0b63be27eebb318cb5bd62..9a3dab1859949d91c1c3b9f542fd0eb5970df1d8 100644 (file)
@@ -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,
index c48cabfa743faf6306870a20646ee24a46652793..f3308b0753078a03bec43d314e37887e2d507d1e 100644 (file)
@@ -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]
index 12b57222805cc23e82484e98085016599d697d95..e081d1a1ece3c705c1a70250998de605c89bc219 100644 (file)
@@ -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::{
index 61abd193c6b1ce427762cb85a1410a1d1772cb04..1cd23e03f0fab9a55cdfe5692c07e406272fceeb 100644 (file)
@@ -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::{
index e03497da076263a551bc5c7a55db09e8098b1f88..43feadd456524ce8e904290de0e4c4d754f2b915 100644 (file)
@@ -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::{
index 8ce2d38fe31ea4143ac9aec31db18edd9ac5f549..0203708255b0c0c8f561ecdce79dd9697f601512 100644 (file)
@@ -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::{
index 1fe90e0fe69d2ac8fcda28a727e723ea56d22c4f..ea3da85aeaf9e12c2601a834d79d0edc5a388634 100644 (file)
@@ -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::{
index adda4fc763fc771a53bba0e28112fc5a1a14733a..8c4a0a15d81c74e8052acf179d132fa01b29bf4d 100644 (file)
@@ -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;
index eb68d2eea7082c004a151d58e7db01cc6e35abe4..313762a72f97c070229989d2f3e5711a23d3060d 100644 (file)
@@ -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::{
index fe85b78b28015d0385ff0ef1a275d7a6021ef008..0404ce00561ae9abe89f444be5aaaf5171dcc08c 100644 (file)
@@ -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,
index 2b5b74a1a12f135f8b8c72d2de2e35384857d08b..5346343264036523d86359132183463de95a0b01 100644 (file)
@@ -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::{
index c5939334d1931106dbe58d791b6c427963d77d8f..eeb171f58e657276297e183005ca4524a4f36176 100644 (file)
@@ -81,6 +81,9 @@ impl CommentReply {
 
 #[cfg(test)]
 mod tests {
+  #![allow(clippy::unwrap_used)]
+  #![allow(clippy::indexing_slicing)]
+
   use crate::{
     source::{
       comment::{Comment, CommentInsertForm},
index babb9a5a1ad93cb35703bb0bff53c1e190aaef33..258e4150442b9473de31a10583381408209f6662 100644 (file)
@@ -331,6 +331,9 @@ impl ApubActor for Community {
 
 #[cfg(test)]
 mod tests {
+  #![allow(clippy::unwrap_used)]
+  #![allow(clippy::indexing_slicing)]
+
   use crate::{
     source::{
       community::{
index d4aed484655b26a6c03c058b5e13b90f3b06ad90..eb67acce8bc0ca614bdc49ce519e32285eded51b 100644 (file)
@@ -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,
index e459d9899186a3cbebaebe7719f95912bc19ecd6..53aadbac80d3b1d75e2ea5f8b2c4a7d02eeb8c0f 100644 (file)
@@ -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;
 
index 32201b3cf3a62d16c90ef6d0def3dd11d73e95c7..12344f71cff1e41d59a81a78db3c4c0e222fccee 100644 (file)
@@ -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},
index 3d1a1e8eb4f46c06c18a565956e61ea9c0e66e8b..ae4483d6ef53ef3bfdfae50a9f84ea7c6d0f92ef 100644 (file)
@@ -107,6 +107,9 @@ fn bytes_to_hex(bytes: Vec<u8>) -> String {
 
 #[cfg(test)]
 mod tests {
+  #![allow(clippy::unwrap_used)]
+  #![allow(clippy::indexing_slicing)]
+
   use crate::{
     source::{
       instance::Instance,
index bd9ad405b8bec6ef95712b54b46c5d92f7620d0a..2e086dcb6d3f1cb9a8eda5ec61ec38ca9b142103 100644 (file)
@@ -200,6 +200,9 @@ impl PersonFollower {
 
 #[cfg(test)]
 mod tests {
+  #![allow(clippy::unwrap_used)]
+  #![allow(clippy::indexing_slicing)]
+
   use crate::{
     source::{
       instance::Instance,
index 25b199e62428c756b2b377d841990c24d2080274..27c04217e0f1e0e42871fe9535471d695986f935 100644 (file)
@@ -82,6 +82,9 @@ impl PersonMention {
 
 #[cfg(test)]
 mod tests {
+  #![allow(clippy::unwrap_used)]
+  #![allow(clippy::indexing_slicing)]
+
   use crate::{
     source::{
       comment::{Comment, CommentInsertForm},
index b775860a45a31a66fe506c0ee89a8e8e860d2459..f10d0cd2793ff515dc2ff24190d02cd87e8bbdba 100644 (file)
@@ -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},
index 2febaa7698f0ae51d995f9be94f03fba4aff8396..fb1d4b905656662ba925c8431acc2b3e596728f8 100644 (file)
@@ -91,6 +91,9 @@ impl PrivateMessage {
 
 #[cfg(test)]
 mod tests {
+  #![allow(clippy::unwrap_used)]
+  #![allow(clippy::indexing_slicing)]
+
   use crate::{
     source::{
       instance::Instance,
index 5d5bfafa2af4ef2fcd1f8cfac9dedc7a60b5afd7..94c867d6b897d8f6d0c920a197c803985391d36f 100644 (file)
@@ -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;
 
index c28c7d673168b3ef4088da160143a7f8b321850f..a09971dbe00824e26382913b53396142f43b1c09 100644 (file)
@@ -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,
index 435a3d8240213ecf0c79f148b831fe906e7bcd1a..9a9685c79e4bb11747f199cd7e5c2008bac3be1d 100644 (file)
@@ -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,
index fff2a2bcc974b6fbf6d09c6425a7e39c881d5fde..50b35b1c258bbce2db25ac04c501937c7af90371 100644 (file)
@@ -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,
index 466713e1d3eb3db9f60146cf98f4a4e96feaf555..0e6ad703cff9f3780fb60521033c383142787a9c 100644 (file)
@@ -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,
index bdffa42e0bb458dd48c2d07291f9b928671eac92..7ceca271abe63a5110b2b1af30a5a932e21b0a70 100644 (file)
@@ -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::{
index 1ee820445201861aace6fc03869f0cee93713169..106e41e433fb316151302508a48ee562e975abb4 100644 (file)
@@ -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,
index 78590a6a74d71e00bc9fe6892c5a6d2f46d50b69..ffc1723b4f75e79e8c440787cf72b5156a806ed6 100644 (file)
@@ -249,6 +249,8 @@ impl<T> LemmyErrorExt2<T> for Result<T, LemmyError> {
 
 #[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;
index 7a5c1ec685759ee4a89a90562c92309d2a725edd..1bb6f1b5f4e1279f3642b8a6b2c246c4569626a2 100644 (file)
@@ -275,6 +275,9 @@ fn parse_ip(addr: &str) -> Option<IpAddr> {
 
 #[cfg(test)]
 mod tests {
+  #![allow(clippy::unwrap_used)]
+  #![allow(clippy::indexing_slicing)]
+
   #[test]
   fn test_parse_ip() {
     let ip_addrs = [
index ed3dc569ef797eabbee27ebd808bea0e39252ce4..3acf23ba42835dffafac7fc805075ea92ff6cbab 100644 (file)
@@ -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(
index 451c86bc73621f3ff008e500d79dd44fadb43c20..5f851589bdb500bfd93887dfff51d7d4ea9f89b8 100644 (file)
@@ -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]
index 1a564f07c1bc3ed62ec8d25ad82498d903937827..bae858bfd5702fc04b23780b1cc139696bbb8bb8 100644 (file)
@@ -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;
 
index 1dcace37bb6eafd2133056dce4e2e7d5ba5e45b3..a2958e499923cc60f83d14b8ba91b47226459975 100644 (file)
@@ -35,6 +35,9 @@ pub fn scrape_text_for_mentions(text: &str) -> Vec<MentionData> {
 
 #[cfg(test)]
 mod test {
+  #![allow(clippy::unwrap_used)]
+  #![allow(clippy::indexing_slicing)]
+
   use crate::utils::mention::scrape_text_for_mentions;
 
   #[test]
index b041eb46049461c1475142d290d6516108a52546..cc2d6a3e6eb0772e67ab9a1a691f3cc3c9541fa4 100644 (file)
@@ -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;
 
index b42fe1adda3e945f38c71648715f25e061710b4f..0c955b12220d08825bf258e83c2a005a7eb67c5c 100644 (file)
@@ -311,6 +311,9 @@ pub fn check_url_scheme(url: &Option<Url>) -> LemmyResult<()> {
 
 #[cfg(test)]
 mod tests {
+  #![allow(clippy::unwrap_used)]
+  #![allow(clippy::indexing_slicing)]
+
   use super::build_totp_2fa;
   use crate::{
     error::LemmyErrorType,
index 5cf870b83b5d7f20977a4107d188c84e51f4077b..5ad3ca8b425c8d9940a603e4577b7978abde40b5 100755 (executable)
@@ -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
 
index b50298b05aa53cc1181b43c3248224df451215d0..55bb91606341cdbfb8c4747cea93a884108c97fc 100644 (file)
@@ -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 || {
index 9e0ffde38c425b2b1833cc878a1dbc88c3a9f654..ad964263b01ab5af5a88ae69341cf8c9591f0c7c 100644 (file)
@@ -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;
index a4d0926817f190e0f3d4beb16fa8d2e797323c6c..4928fe8dd5c0f836757f2bb1ce92431794f5fd6f 100644 (file)
@@ -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;