diff --git a/ci/src/main.rs b/ci/src/main.rs index ed3ad33..f3e0122 100644 --- a/ci/src/main.rs +++ b/ci/src/main.rs @@ -1,5 +1,5 @@ use std::path::PathBuf; -use std::sync::Arc; + use clap::Args; use clap::Parser; @@ -107,7 +107,7 @@ async fn main() -> eyre::Result<()> { } mod please_release { - use std::sync::Arc; + use dagger_cuddle_please::{models::CuddlePleaseSrcArgs, DaggerCuddlePleaseAction}; @@ -136,7 +136,7 @@ mod please_release { } mod test { - use std::{path::PathBuf, sync::Arc}; + use std::{path::PathBuf}; use dagger_rust::build::RustVersion; diff --git a/crates/cuddle-ci/src/cli.rs b/crates/cuddle-ci/src/cli.rs index 60d31e6..ee2bbd9 100644 --- a/crates/cuddle-ci/src/cli.rs +++ b/crates/cuddle-ci/src/cli.rs @@ -1,4 +1,4 @@ -use std::{env::Args, sync::Arc}; +use std::{sync::Arc}; use async_trait::async_trait; @@ -50,17 +50,17 @@ impl CuddleCI { match matches.subcommand() { Some((name, args)) => match (name, args) { - ("pr", args) => { + ("pr", _args) => { eprintln!("starting pr validate"); self.pr_action.execute_pull_request().await?; eprintln!("finished pr validate"); } - ("main", args) => { + ("main", _args) => { eprintln!("starting main validate"); self.main_action.execute_main().await?; eprintln!("finished main validate"); } - ("release", args) => { + ("release", _args) => { eprintln!("starting release validate"); self.release_action.execute_release().await?; eprintln!("finished release validate"); diff --git a/crates/cuddle-ci/src/lib.rs b/crates/cuddle-ci/src/lib.rs index b735bf6..c0b451a 100644 --- a/crates/cuddle-ci/src/lib.rs +++ b/crates/cuddle-ci/src/lib.rs @@ -2,110 +2,4 @@ pub mod cli; pub use cli::*; pub mod dagger_middleware; - -pub mod rust_service { - use std::{future::Future, pin::Pin, sync::Arc}; - - use async_trait::async_trait; - use dagger_sdk::Container; - use futures::future::BoxFuture; - - use crate::{dagger_middleware::DaggerMiddleware, MainAction, PullRequestAction}; - - pub type DynMiddleware = Box; - - pub enum RustServiceStage { - BeforeBase(DynMiddleware), - AfterBase(DynMiddleware), - BeforeRelease(DynMiddleware), - AfterRelease(DynMiddleware), - } - - pub struct RustService { - client: dagger_sdk::Query, - - base_image: Option, - - stages: Vec, - } - - impl From for RustService { - fn from(value: dagger_sdk::Query) -> Self { - Self { - client: value, - base_image: None, - stages: Vec::new(), - } - } - } - - impl RustService { - pub async fn new() -> eyre::Result { - Ok(Self { - client: dagger_sdk::connect().await?, - base_image: None, - stages: Vec::new(), - }) - } - - pub fn with_base_image(&mut self, base: dagger_sdk::Container) -> &mut Self { - self.base_image = Some(base); - - self - } - - pub fn add_stage(&mut self, stage: RustServiceStage) -> &mut Self { - self - } - - pub fn with_sqlx(&mut self) -> &mut Self { - self - } - - pub async fn build_release(&self) -> eyre::Result> { - Ok(Vec::new()) - } - } - - #[async_trait] - impl PullRequestAction for RustService { - async fn execute_pull_request(&self) -> eyre::Result<()> { - self.build_release().await?; - - Ok(()) - } - } - - #[async_trait] - impl MainAction for RustService { - async fn execute_main(&self) -> eyre::Result<()> { - Ok(()) - } - } -} - -#[cfg(test)] -mod test { - use futures::FutureExt; - - use crate::{ - dagger_middleware::middleware, - rust_service::{RustService, RustServiceStage}, - }; - - use super::*; - - #[tokio::test] - async fn can_build_rust() -> eyre::Result<()> { - let client = dagger_sdk::connect().await?; - - RustService::from(client.clone()) - .with_base_image(client.container().from("rustlang/rust:nightly")) - .with_sqlx() - .add_stage(RustServiceStage::BeforeBase(middleware(|c| async move { Ok(c) }.boxed()))) - .build_release() - .await?; - - Ok(()) - } -} +pub mod rust_service; diff --git a/crates/cuddle-ci/src/rust_service.rs b/crates/cuddle-ci/src/rust_service.rs new file mode 100644 index 0000000..c91964e --- /dev/null +++ b/crates/cuddle-ci/src/rust_service.rs @@ -0,0 +1,104 @@ + + +use async_trait::async_trait; +use dagger_sdk::Container; + + +use crate::{dagger_middleware::DaggerMiddleware, MainAction, PullRequestAction}; + +pub type DynMiddleware = Box; + +pub enum RustServiceStage { + BeforeBase(DynMiddleware), + AfterBase(DynMiddleware), + BeforeRelease(DynMiddleware), + AfterRelease(DynMiddleware), +} + +pub struct RustService { + client: dagger_sdk::Query, + + base_image: Option, + + stages: Vec, +} + +impl From for RustService { + fn from(value: dagger_sdk::Query) -> Self { + Self { + client: value, + base_image: None, + stages: Vec::new(), + } + } +} + +impl RustService { + pub async fn new() -> eyre::Result { + Ok(Self { + client: dagger_sdk::connect().await?, + base_image: None, + stages: Vec::new(), + }) + } + + pub fn with_base_image(&mut self, base: dagger_sdk::Container) -> &mut Self { + self.base_image = Some(base); + + self + } + + pub fn with_stage(&mut self, _stage: RustServiceStage) -> &mut Self { + self + } + + pub fn with_sqlx(&mut self) -> &mut Self { + self + } + + pub async fn build_release(&self) -> eyre::Result> { + Ok(Vec::new()) + } +} + +#[async_trait] +impl PullRequestAction for RustService { + async fn execute_pull_request(&self) -> eyre::Result<()> { + self.build_release().await?; + + Ok(()) + } +} + +#[async_trait] +impl MainAction for RustService { + async fn execute_main(&self) -> eyre::Result<()> { + Ok(()) + } +} + +#[cfg(test)] +mod test { + use futures::FutureExt; + + use crate::{ + dagger_middleware::middleware, + rust_service::{RustService, RustServiceStage}, + }; + + + + #[tokio::test] + async fn can_build_rust() -> eyre::Result<()> { + let client = dagger_sdk::connect().await?; + + RustService::from(client.clone()) + .with_base_image(client.container().from("rustlang/rust:nightly")) + .with_sqlx() + .with_stage(RustServiceStage::BeforeBase(middleware(|c| async move { Ok(c) }.boxed()))) + .build_release() + .await?; + + Ok(()) + } +} diff --git a/crates/dagger-cuddle-please/src/lib.rs b/crates/dagger-cuddle-please/src/lib.rs index 5fa419c..07c806b 100644 --- a/crates/dagger-cuddle-please/src/lib.rs +++ b/crates/dagger-cuddle-please/src/lib.rs @@ -1,4 +1,4 @@ -use std::sync::{Arc, Mutex}; +use std::sync::{Arc}; use models::{CuddlePleaseArgs, CuddlePleaseSrcArgs}; use traits::CuddlePlease; diff --git a/crates/dagger-rust/src/htmx.rs b/crates/dagger-rust/src/htmx.rs index 7ef182c..0580b01 100644 --- a/crates/dagger-rust/src/htmx.rs +++ b/crates/dagger-rust/src/htmx.rs @@ -110,7 +110,7 @@ impl HtmxBuild { let container = match &container_image { SlimImage::Debian { image, deps, .. } => { - let target = BuildTarget::from_target(&container_image); + let _target = BuildTarget::from_target(&container_image); let build_container = self .build( diff --git a/crates/dagger-rust/src/leptos.rs b/crates/dagger-rust/src/leptos.rs index 11b4f47..13c9a73 100644 --- a/crates/dagger-rust/src/leptos.rs +++ b/crates/dagger-rust/src/leptos.rs @@ -55,7 +55,7 @@ impl LeptosBuild { .client .cache_volume(format!("rust_leptos_{}", profile.to_string())); - let mut build_options = vec!["cargo", "leptos", "build", "--release", "-vv"]; + let build_options = vec!["cargo", "leptos", "build", "--release", "-vv"]; let rust_prebuild = rust_build_image .with_workdir("/mnt/src") @@ -95,7 +95,7 @@ impl LeptosBuild { for container_image in images { let container = match &container_image { SlimImage::Debian { image, deps, .. } => { - let target = BuildTarget::from_target(&container_image); + let _target = BuildTarget::from_target(&container_image); let build_container = self .build( diff --git a/crates/dagger-rust/src/source.rs b/crates/dagger-rust/src/source.rs index 9745eae..bb90ee1 100644 --- a/crates/dagger-rust/src/source.rs +++ b/crates/dagger-rust/src/source.rs @@ -1,6 +1,5 @@ use std::{ path::{Path, PathBuf}, - sync::Arc, }; use eyre::Context; diff --git a/crates/dagger-rust/src/test.rs b/crates/dagger-rust/src/test.rs index a84efa3..3fdbc59 100644 --- a/crates/dagger-rust/src/test.rs +++ b/crates/dagger-rust/src/test.rs @@ -1,4 +1,4 @@ -use std::{path::PathBuf, sync::Arc}; +use std::{path::PathBuf}; use crate::{build::RustVersion, source::RustSource}; diff --git a/examples/leptos-build/src/main.rs b/examples/leptos-build/src/main.rs index 7b79349..524162e 100644 --- a/examples/leptos-build/src/main.rs +++ b/examples/leptos-build/src/main.rs @@ -1,4 +1,4 @@ -use dagger_rust::build::{BuildProfile, RustVersion, SlimImage}; +use dagger_rust::build::{RustVersion, SlimImage}; #[tokio::main] pub async fn main() -> eyre::Result<()> {