Skip to content

Commit

Permalink
Cache & Optimize Woodpecker CI (#3450)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
cetra3 and dessalines authored Jul 17, 2023
1 parent 88215bf commit 9256895
Show file tree
Hide file tree
Showing 65 changed files with 233 additions and 6 deletions.
49 changes: 47 additions & 2 deletions .woodpecker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions crates/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 3 additions & 0 deletions crates/api_common/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions crates/api_common/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions crates/api_crud/src/site/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 3 additions & 0 deletions crates/api_crud/src/site/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
3 changes: 3 additions & 0 deletions crates/api_crud/src/site/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/activity_lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/collections/community_moderators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/objects/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/objects/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/objects/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/objects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/objects/person.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/objects/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/objects/private_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/protocol/activities/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/protocol/activities/community/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/protocol/activities/create_or_update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/protocol/activities/deletion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/protocol/activities/following/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/protocol/activities/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/protocol/activities/voting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/protocol/collections/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/protocol/objects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions crates/apub/src/protocol/objects/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions crates/db_schema/src/aggregates/comment_aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 3 additions & 0 deletions crates/db_schema/src/aggregates/community_aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 3 additions & 0 deletions crates/db_schema/src/aggregates/person_aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 3 additions & 0 deletions crates/db_schema/src/aggregates/post_aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 3 additions & 0 deletions crates/db_schema/src/aggregates/site_aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 3 additions & 0 deletions crates/db_schema/src/impls/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 9256895

Please sign in to comment.