chore: fmt

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2023-11-25 23:14:38 +01:00
parent 82ccdefd93
commit 3939940c01
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912
10 changed files with 118 additions and 121 deletions

View File

@ -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;

View File

@ -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");

View File

@ -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<dyn DaggerMiddleware + Send + Sync>;
pub enum RustServiceStage {
BeforeBase(DynMiddleware),
AfterBase(DynMiddleware),
BeforeRelease(DynMiddleware),
AfterRelease(DynMiddleware),
}
pub struct RustService {
client: dagger_sdk::Query,
base_image: Option<dagger_sdk::Container>,
stages: Vec<RustServiceStage>,
}
impl From<dagger_sdk::Query> 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<Self> {
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<Vec<Container>> {
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;

View File

@ -0,0 +1,104 @@
use async_trait::async_trait;
use dagger_sdk::Container;
use crate::{dagger_middleware::DaggerMiddleware, MainAction, PullRequestAction};
pub type DynMiddleware = Box<dyn DaggerMiddleware + Send + Sync>;
pub enum RustServiceStage {
BeforeBase(DynMiddleware),
AfterBase(DynMiddleware),
BeforeRelease(DynMiddleware),
AfterRelease(DynMiddleware),
}
pub struct RustService {
client: dagger_sdk::Query,
base_image: Option<dagger_sdk::Container>,
stages: Vec<RustServiceStage>,
}
impl From<dagger_sdk::Query> 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<Self> {
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<Vec<Container>> {
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(())
}
}

View File

@ -1,4 +1,4 @@
use std::sync::{Arc, Mutex};
use std::sync::{Arc};
use models::{CuddlePleaseArgs, CuddlePleaseSrcArgs};
use traits::CuddlePlease;

View File

@ -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(

View File

@ -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(

View File

@ -1,6 +1,5 @@
use std::{
path::{Path, PathBuf},
sync::Arc,
};
use eyre::Context;

View File

@ -1,4 +1,4 @@
use std::{path::PathBuf, sync::Arc};
use std::{path::PathBuf};
use crate::{build::RustVersion, source::RustSource};

View File

@ -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<()> {