From 015cb6b23a397aaaae57aa83af3964c2221f771f Mon Sep 17 00:00:00 2001 From: kjuulh Date: Mon, 27 Nov 2023 13:42:13 +0100 Subject: [PATCH] feat: with cargo clean Signed-off-by: kjuulh --- crates/cuddle-ci/src/cli.rs | 2 +- crates/cuddle-ci/src/rust_service.rs | 2 ++ .../cuddle-ci/src/rust_service/cargo_clean.rs | 35 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 crates/cuddle-ci/src/rust_service/cargo_clean.rs 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 + } +}