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 <dessalines@users.noreply.github.com>
This commit is contained in:
cetra3 2023-07-18 00:34:14 +09:30 committed by GitHub
parent 88215bfbc9
commit 9256895635
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
65 changed files with 233 additions and 6 deletions

View file

@ -27,6 +27,29 @@ pipeline:
commands: commands:
- prettier -c . '!**/volumes' '!**/dist' '!target' '!**/translations' - 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: taplo_check:
image: tamasfe/taplo:0.8.1 image: tamasfe/taplo:0.8.1
commands: commands:
@ -40,7 +63,7 @@ pipeline:
CARGO_HOME: .cargo CARGO_HOME: .cargo
commands: commands:
# need make existing toolchain available # need make existing toolchain available
- cp ~/.cargo . -r - cp -n ~/.cargo . -r
- rustup toolchain install nightly-2023-07-10 - rustup toolchain install nightly-2023-07-10
- rustup component add rustfmt --toolchain nightly-2023-07-10 - rustup component add rustfmt --toolchain nightly-2023-07-10
- cargo +nightly-2023-07-10 fmt -- --check - cargo +nightly-2023-07-10 fmt -- --check
@ -68,7 +91,6 @@ pipeline:
-D clippy::explicit_into_iter_loop -D clippy::explicit_into_iter_loop
-D clippy::explicit_iter_loop -D clippy::explicit_iter_loop
-D clippy::needless_collect -D clippy::needless_collect
- cargo clippy --workspace --features console --
-D clippy::unwrap_used -D clippy::unwrap_used
-D clippy::indexing_slicing -D clippy::indexing_slicing
# when: # when:
@ -158,6 +180,29 @@ pipeline:
# when: # when:
# platform: linux/amd64 # 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: publish_release_docker:
image: woodpeckerci/plugin-docker-buildx image: woodpeckerci/plugin-docker-buildx
secrets: [docker_username, docker_password] secrets: [docker_username, docker_password]

View file

@ -76,6 +76,9 @@ pub(crate) fn check_report_reason(reason: &str, local_site: &LocalSite) -> Resul
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use lemmy_api_common::utils::check_validator_time; use lemmy_api_common::utils::check_validator_time;
use lemmy_db_schema::{ use lemmy_db_schema::{
source::{ source::{

View file

@ -270,6 +270,9 @@ pub fn build_user_agent(settings: &Settings) -> String {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::request::{ use crate::request::{
build_user_agent, build_user_agent,
fetch_site_metadata, fetch_site_metadata,

View file

@ -731,6 +731,9 @@ pub async fn delete_user_account(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::utils::{honeypot_check, password_length_check}; use crate::utils::{honeypot_check, password_length_check};
#[test] #[test]

View file

@ -183,6 +183,9 @@ fn validate_create_payload(local_site: &LocalSite, create_site: &CreateSite) ->
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::site::create::validate_create_payload; use crate::site::create::validate_create_payload;
use lemmy_api_common::site::CreateSite; use lemmy_api_common::site::CreateSite;
use lemmy_db_schema::{source::local_site::LocalSite, ListingType, RegistrationMode}; use lemmy_db_schema::{source::local_site::LocalSite, ListingType, RegistrationMode};

View file

@ -42,6 +42,9 @@ pub fn application_question_check(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::site::{application_question_check, site_default_post_listing_type_check}; use crate::site::{application_question_check, site_default_post_listing_type_check};
use lemmy_db_schema::{ListingType, RegistrationMode}; use lemmy_db_schema::{ListingType, RegistrationMode};

View file

@ -217,6 +217,9 @@ fn validate_update_payload(local_site: &LocalSite, edit_site: &EditSite) -> Lemm
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::site::update::validate_update_payload; use crate::site::update::validate_update_payload;
use lemmy_api_common::site::EditSite; use lemmy_api_common::site::EditSite;
use lemmy_db_schema::{source::local_site::LocalSite, ListingType, RegistrationMode}; use lemmy_db_schema::{source::local_site::LocalSite, ListingType, RegistrationMode};

View file

@ -134,6 +134,9 @@ impl InCommunity for AnnouncableActivities {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
activity_lists::{ activity_lists::{
GroupInboxActivities, GroupInboxActivities,

View file

@ -100,6 +100,9 @@ impl Collection for ApubCommunityModerators {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use super::*; use super::*;
use crate::{ use crate::{
objects::{ objects::{

View file

@ -179,6 +179,9 @@ impl Object for ApubComment {
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use super::*; use super::*;
use crate::{ use crate::{
objects::{ objects::{

View file

@ -204,6 +204,9 @@ impl ApubCommunity {
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use super::*; use super::*;
use crate::{ use crate::{
objects::{instance::tests::parse_lemmy_instance, tests::init_context}, objects::{instance::tests::parse_lemmy_instance, tests::init_context},

View file

@ -206,6 +206,9 @@ pub(crate) async fn remote_instance_inboxes(pool: &mut DbPool<'_>) -> Result<Vec
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use super::*; use super::*;
use crate::{objects::tests::init_context, protocol::tests::file_to_json_object}; use crate::{objects::tests::init_context, protocol::tests::file_to_json_object};
use lemmy_db_schema::traits::Crud; use lemmy_db_schema::traits::Crud;

View file

@ -54,6 +54,9 @@ pub(crate) fn verify_is_remote_object(id: &Url, settings: &Settings) -> Result<(
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use activitypub_federation::config::{Data, FederationConfig}; use activitypub_federation::config::{Data, FederationConfig};
use anyhow::anyhow; use anyhow::anyhow;
use lemmy_api_common::{context::LemmyContext, request::build_user_agent}; use lemmy_api_common::{context::LemmyContext, request::build_user_agent};

View file

@ -195,6 +195,9 @@ impl Actor for ApubPerson {
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use super::*; use super::*;
use crate::{ use crate::{
objects::{ objects::{

View file

@ -280,6 +280,9 @@ impl Object for ApubPost {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use super::*; use super::*;
use crate::{ use crate::{
objects::{ objects::{

View file

@ -136,6 +136,9 @@ impl Object for ApubPrivateMessage {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use super::*; use super::*;
use crate::{ use crate::{
objects::{ objects::{

View file

@ -3,6 +3,9 @@ pub mod undo_block_user;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::protocol::{ use crate::protocol::{
activities::block::{block_user::BlockUser, undo_block_user::UndoBlockUser}, activities::block::{block_user::BlockUser, undo_block_user::UndoBlockUser},
tests::test_parse_lemmy_item, tests::test_parse_lemmy_item,

View file

@ -7,6 +7,9 @@ pub mod update;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::protocol::{ use crate::protocol::{
activities::community::{ activities::community::{
announce::AnnounceActivity, announce::AnnounceActivity,

View file

@ -4,6 +4,9 @@ pub mod page;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::protocol::{ use crate::protocol::{
activities::create_or_update::{ activities::create_or_update::{
chat_message::CreateOrUpdateChatMessage, chat_message::CreateOrUpdateChatMessage,

View file

@ -4,6 +4,9 @@ pub mod undo_delete;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::protocol::{ use crate::protocol::{
activities::deletion::{delete::Delete, delete_user::DeleteUser, undo_delete::UndoDelete}, activities::deletion::{delete::Delete, delete_user::DeleteUser, undo_delete::UndoDelete},
tests::test_parse_lemmy_item, tests::test_parse_lemmy_item,

View file

@ -4,6 +4,9 @@ pub mod undo_follow;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::protocol::{ use crate::protocol::{
activities::following::{accept::AcceptFollow, follow::Follow, undo_follow::UndoFollow}, activities::following::{accept::AcceptFollow, follow::Follow, undo_follow::UndoFollow},
tests::test_parse_lemmy_item, tests::test_parse_lemmy_item,

View file

@ -16,6 +16,9 @@ pub enum CreateOrUpdateType {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::protocol::{ use crate::protocol::{
activities::{ activities::{
community::announce::AnnounceActivity, community::announce::AnnounceActivity,

View file

@ -3,6 +3,9 @@ pub mod vote;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::protocol::{ use crate::protocol::{
activities::voting::{undo_vote::UndoVote, vote::Vote}, activities::voting::{undo_vote::UndoVote, vote::Vote},
tests::test_parse_lemmy_item, tests::test_parse_lemmy_item,

View file

@ -6,6 +6,9 @@ pub(crate) mod group_outbox;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::protocol::{ use crate::protocol::{
collections::{ collections::{
empty_outbox::EmptyOutbox, empty_outbox::EmptyOutbox,

View file

@ -89,6 +89,9 @@ pub trait InCommunity {
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use activitypub_federation::protocol::context::WithContext; use activitypub_federation::protocol::context::WithContext;
use assert_json_diff::assert_json_include; use assert_json_diff::assert_json_include;
use lemmy_utils::error::LemmyError; use lemmy_utils::error::LemmyError;

View file

@ -95,6 +95,9 @@ impl LanguageTag {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::protocol::{ use crate::protocol::{
objects::{ objects::{
chat_message::ChatMessage, chat_message::ChatMessage,

View file

@ -242,6 +242,9 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::protocol::{objects::page::Page, tests::test_parse_lemmy_item}; use crate::protocol::{objects::page::Page, tests::test_parse_lemmy_item};
#[test] #[test]

View file

@ -35,6 +35,9 @@ impl CommentAggregates {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
aggregates::comment_aggregates::CommentAggregates, aggregates::comment_aggregates::CommentAggregates,
source::{ source::{

View file

@ -19,6 +19,9 @@ impl CommunityAggregates {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
aggregates::community_aggregates::CommunityAggregates, aggregates::community_aggregates::CommunityAggregates,
source::{ source::{

View file

@ -19,6 +19,9 @@ impl PersonAggregates {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
aggregates::person_aggregates::PersonAggregates, aggregates::person_aggregates::PersonAggregates,
source::{ source::{

View file

@ -35,6 +35,9 @@ impl PostAggregates {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
aggregates::post_aggregates::PostAggregates, aggregates::post_aggregates::PostAggregates,
source::{ source::{

View file

@ -15,6 +15,9 @@ impl SiteAggregates {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
aggregates::site_aggregates::SiteAggregates, aggregates::site_aggregates::SiteAggregates,
source::{ source::{

View file

@ -58,6 +58,9 @@ impl ReceivedActivity {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use super::*; use super::*;
use crate::utils::build_db_pool_for_tests; use crate::utils::build_db_pool_for_tests;
use serde_json::json; use serde_json::json;

View file

@ -384,6 +384,9 @@ async fn convert_read_languages(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use super::*; use super::*;
use crate::{ use crate::{
impls::actor_language::{ impls::actor_language::{

View file

@ -50,6 +50,9 @@ impl CaptchaAnswer {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
source::captcha_answer::{CaptchaAnswer, CaptchaAnswerForm, CheckCaptchaAnswer}, source::captcha_answer::{CaptchaAnswer, CaptchaAnswerForm, CheckCaptchaAnswer},
utils::build_db_pool_for_tests, utils::build_db_pool_for_tests,

View file

@ -251,6 +251,9 @@ impl Saveable for CommentSaved {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
newtypes::LanguageId, newtypes::LanguageId,
source::{ source::{

View file

@ -81,6 +81,9 @@ impl CommentReply {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
source::{ source::{
comment::{Comment, CommentInsertForm}, comment::{Comment, CommentInsertForm},

View file

@ -331,6 +331,9 @@ impl ApubActor for Community {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
source::{ source::{
community::{ community::{

View file

@ -49,6 +49,9 @@ impl FederationAllowList {
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
source::{federation_allowlist::FederationAllowList, instance::Instance}, source::{federation_allowlist::FederationAllowList, instance::Instance},
utils::build_db_pool_for_tests, utils::build_db_pool_for_tests,

View file

@ -42,6 +42,9 @@ impl Language {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{source::language::Language, utils::build_db_pool_for_tests}; use crate::{source::language::Language, utils::build_db_pool_for_tests};
use serial_test::serial; use serial_test::serial;

View file

@ -551,6 +551,9 @@ impl Crud for AdminPurgeComment {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
source::{ source::{
comment::{Comment, CommentInsertForm}, comment::{Comment, CommentInsertForm},

View file

@ -107,6 +107,9 @@ fn bytes_to_hex(bytes: Vec<u8>) -> String {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
source::{ source::{
instance::Instance, instance::Instance,

View file

@ -200,6 +200,9 @@ impl PersonFollower {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
source::{ source::{
instance::Instance, instance::Instance,

View file

@ -82,6 +82,9 @@ impl PersonMention {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
source::{ source::{
comment::{Comment, CommentInsertForm}, comment::{Comment, CommentInsertForm},

View file

@ -329,6 +329,9 @@ impl Readable for PostRead {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
source::{ source::{
community::{Community, CommunityInsertForm}, community::{Community, CommunityInsertForm},

View file

@ -91,6 +91,9 @@ impl PrivateMessage {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::{ use crate::{
source::{ source::{
instance::Instance, instance::Instance,

View file

@ -406,6 +406,9 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use super::{fuzzy_search, *}; use super::{fuzzy_search, *};
use crate::utils::is_email_regex; use crate::utils::is_email_regex;

View file

@ -269,6 +269,9 @@ impl JoinView for CommentReportView {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::comment_report_view::{CommentReportQuery, CommentReportView}; use crate::comment_report_view::{CommentReportQuery, CommentReportView};
use lemmy_db_schema::{ use lemmy_db_schema::{
aggregates::structs::CommentAggregates, aggregates::structs::CommentAggregates,

View file

@ -382,6 +382,9 @@ impl JoinView for CommentView {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::comment_view::{ use crate::comment_view::{
Comment, Comment,
CommentQuery, CommentQuery,

View file

@ -265,6 +265,9 @@ impl JoinView for PostReportView {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::post_report_view::{PostReportQuery, PostReportView}; use crate::post_report_view::{PostReportQuery, PostReportView};
use lemmy_db_schema::{ use lemmy_db_schema::{
aggregates::structs::PostAggregates, aggregates::structs::PostAggregates,

View file

@ -473,6 +473,9 @@ impl JoinView for PostView {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::post_view::{PostQuery, PostView}; use crate::post_view::{PostQuery, PostView};
use lemmy_db_schema::{ use lemmy_db_schema::{
aggregates::structs::PostAggregates, aggregates::structs::PostAggregates,

View file

@ -148,6 +148,9 @@ impl JoinView for PrivateMessageReportView {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::private_message_report_view::PrivateMessageReportQuery; use crate::private_message_report_view::PrivateMessageReportQuery;
use lemmy_db_schema::{ use lemmy_db_schema::{
source::{ source::{

View file

@ -160,6 +160,9 @@ impl JoinView for RegistrationApplicationView {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::registration_application_view::{ use crate::registration_application_view::{
RegistrationApplicationQuery, RegistrationApplicationQuery,
RegistrationApplicationView, RegistrationApplicationView,

View file

@ -249,6 +249,8 @@ impl<T> LemmyErrorExt2<T> for Result<T, LemmyError> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use super::*; use super::*;
use actix_web::{body::MessageBody, ResponseError}; use actix_web::{body::MessageBody, ResponseError};
use std::fs::read_to_string; use std::fs::read_to_string;

View file

@ -275,6 +275,9 @@ fn parse_ip(addr: &str) -> Option<IpAddr> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
#[test] #[test]
fn test_parse_ip() { fn test_parse_ip() {
let ip_addrs = [ let ip_addrs = [

View file

@ -237,6 +237,9 @@ fn split_ipv6(ip: Ipv6Addr) -> ([u8; 6], u8, u8) {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
#[test] #[test]
fn test_split_ipv6() { fn test_split_ipv6() {
let ip = std::net::Ipv6Addr::new( let ip = std::net::Ipv6Addr::new(

View file

@ -18,6 +18,9 @@ pub fn markdown_to_html(text: &str) -> String {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::utils::markdown::markdown_to_html; use crate::utils::markdown::markdown_to_html;
#[test] #[test]

View file

@ -135,6 +135,9 @@ pub fn add(markdown_parser: &mut MarkdownIt) {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::utils::markdown::spoiler_rule::add; use crate::utils::markdown::spoiler_rule::add;
use markdown_it::MarkdownIt; use markdown_it::MarkdownIt;

View file

@ -35,6 +35,9 @@ pub fn scrape_text_for_mentions(text: &str) -> Vec<MentionData> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::utils::mention::scrape_text_for_mentions; use crate::utils::mention::scrape_text_for_mentions;
#[test] #[test]

View file

@ -65,6 +65,9 @@ pub(crate) fn slurs_vec_to_str(slurs: &[&str]) -> String {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use crate::utils::slurs::{remove_slurs, slur_check, slurs_vec_to_str}; use crate::utils::slurs::{remove_slurs, slur_check, slurs_vec_to_str};
use regex::RegexBuilder; use regex::RegexBuilder;

View file

@ -311,6 +311,9 @@ pub fn check_url_scheme(url: &Option<Url>) -> LemmyResult<()> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use super::build_totp_2fa; use super::build_totp_2fa;
use crate::{ use crate::{
error::LemmyErrorType, error::LemmyErrorType,

View file

@ -17,9 +17,7 @@ cargo clippy --workspace --fix --allow-staged --allow-dirty --tests --all-target
-D clippy::get_first \ -D clippy::get_first \
-D clippy::explicit_into_iter_loop \ -D clippy::explicit_into_iter_loop \
-D clippy::explicit_iter_loop \ -D clippy::explicit_iter_loop \
-D clippy::needless_collect -D clippy::needless_collect \
cargo clippy --workspace --features console -- \
-D clippy::unwrap_used \ -D clippy::unwrap_used \
-D clippy::indexing_slicing -D clippy::indexing_slicing

View file

@ -163,7 +163,7 @@ pub async fn start_lemmy_server() -> Result<(), LemmyError> {
let prom_api_metrics = PrometheusMetricsBuilder::new("lemmy_api") let prom_api_metrics = PrometheusMetricsBuilder::new("lemmy_api")
.registry(default_registry().clone()) .registry(default_registry().clone())
.build() .build()
.unwrap(); .expect("Should always be buildable");
// Create Http server with websocket support // Create Http server with websocket support
HttpServer::new(move || { HttpServer::new(move || {

View 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 actix_web::{rt::System, web, App, HttpResponse, HttpServer, Responder};
use lemmy_api_common::context::LemmyContext; use lemmy_api_common::context::LemmyContext;
use lemmy_utils::settings::structs::PrometheusConfig; use lemmy_utils::settings::structs::PrometheusConfig;

View file

@ -401,6 +401,9 @@ fn update_instance_software(conn: &mut PgConnection, user_agent: &str) -> LemmyR
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
#![allow(clippy::indexing_slicing)]
use lemmy_routes::nodeinfo::NodeInfo; use lemmy_routes::nodeinfo::NodeInfo;
use reqwest::Client; use reqwest::Client;