diff --git a/crates/cuddle-ci/src/cli.rs b/crates/cuddle-ci/src/cli.rs index ee2bbd9..bccd6c9 100644 --- a/crates/cuddle-ci/src/cli.rs +++ b/crates/cuddle-ci/src/cli.rs @@ -1,4 +1,4 @@ -use std::{sync::Arc}; +use std::sync::Arc; use async_trait::async_trait; diff --git a/crates/cuddle-ci/src/rust_service.rs b/crates/cuddle-ci/src/rust_service.rs index 320cb8f..73b802f 100644 --- a/crates/cuddle-ci/src/rust_service.rs +++ b/crates/cuddle-ci/src/rust_service.rs @@ -334,6 +334,7 @@ pub mod architecture { mod apt; mod cargo_binstall; +mod cargo_clean; mod clap_sanity_test; mod mold; mod sqlx; @@ -341,6 +342,7 @@ mod sqlx; pub mod extensions { pub use super::apt::*; pub use super::cargo_binstall::*; + pub use super::cargo_clean::*; pub use super::clap_sanity_test::*; pub use super::mold::*; pub use super::sqlx::*; diff --git a/crates/cuddle-ci/src/rust_service/cargo_clean.rs b/crates/cuddle-ci/src/rust_service/cargo_clean.rs new file mode 100644 index 0000000..ee62689 --- /dev/null +++ b/crates/cuddle-ci/src/rust_service/cargo_clean.rs @@ -0,0 +1,35 @@ +use dagger_sdk::Container; + +use crate::dagger_middleware::DaggerMiddleware; + +use super::RustService; + +pub struct CargoClean; + +impl CargoClean { + pub fn new() -> Self { + Self {} + } +} + +impl DaggerMiddleware for CargoClean { + async fn handle(&self, container: Container) -> eyre::Result { + Ok(container.with_exec(vec!["cargo", "clean"])) + } +} + +pub trait CargoCleanExt { + fn with_cargo_clean(&mut self) -> &mut Self { + self + } +} + +impl CargoCleanExt for RustService { + fn with_cargo_clean(&mut self) -> &mut Self { + self.with_stage(super::RustServiceStage::BeforeBuild(Box::new( + CargoClean::new(), + ))); + + self + } +}