1
crates/cuddle-rust-cli-plan/.gitignore
vendored
Normal file
1
crates/cuddle-rust-cli-plan/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/target
|
15
crates/cuddle-rust-cli-plan/Cargo.toml
Normal file
15
crates/cuddle-rust-cli-plan/Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "cuddle-rust-cli-plan"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
tokio.workspace = true
|
||||
|
||||
dagger-sdk = {git = "https://github.com/kjuulh/dagger.git", branch = "feat/with-send-sync"}
|
||||
eyre = { version = "0.6.12" }
|
||||
|
||||
dagger-components = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }
|
||||
dagger-rust = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }
|
||||
cuddle-ci = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }
|
||||
async-trait = "0.1.79"
|
86
crates/cuddle-rust-cli-plan/src/main.rs
Normal file
86
crates/cuddle-rust-cli-plan/src/main.rs
Normal file
@@ -0,0 +1,86 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use cuddle_ci::cuddle_file::CuddleFile;
|
||||
use cuddle_ci::cuddle_releaser::CuddleReleaser;
|
||||
use cuddle_ci::rust_service::architecture::{Architecture, Os};
|
||||
use cuddle_ci::rust_service::RustService;
|
||||
use cuddle_ci::rust_service::{extensions::*, RustServiceContext};
|
||||
use cuddle_ci::{Context, CuddleCI, MainAction, PullRequestAction};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect().await?;
|
||||
let cuddle_file = CuddleFile::from_cuddle_file().await?;
|
||||
|
||||
let service = RustService::from(client.clone())
|
||||
.with_arch(Architecture::Amd64)
|
||||
.with_os(Os::Linux)
|
||||
.with_apt(&["libssl-dev", "libz-dev", "libpq-dev", "protobuf-compiler"])
|
||||
.with_apt_release(&["libssl-dev", "libz-dev", "libpq-dev"])
|
||||
.with_apt_ca_certificates()
|
||||
.with_crates(["crates/*"])
|
||||
.with_mold("2.3.3")
|
||||
.with_bin_name(cuddle_file.vars.service)
|
||||
.with_deployment(false)
|
||||
.to_owned();
|
||||
|
||||
let service = Arc::new(Mutex::new(service));
|
||||
|
||||
let render = Arc::new(Mutex::new(RustServiceRender::default()));
|
||||
|
||||
let deployment = Arc::new(Mutex::new(CuddleReleaser::new(client).await?));
|
||||
CuddleCI::default()
|
||||
.with_pull_request(service.clone())
|
||||
//.with_pull_request(render.clone())
|
||||
//.with_pull_request(deployment.clone())
|
||||
.with_main(service.clone())
|
||||
.with_main(render.clone())
|
||||
.with_main(deployment.clone())
|
||||
.execute(std::env::args())
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct RustServiceRender {}
|
||||
|
||||
#[async_trait]
|
||||
impl MainAction for RustServiceRender {
|
||||
async fn execute_main(&self, ctx: &mut Context) -> eyre::Result<()> {
|
||||
let image_tag = ctx
|
||||
.get_image_tag()?
|
||||
.ok_or(eyre::anyhow!("failed to find image_tag"))?;
|
||||
|
||||
cuddle_ci::cuddle_x::well_known::render(vec![
|
||||
"--cluster",
|
||||
"clank-prod",
|
||||
"--image_tag",
|
||||
&image_tag,
|
||||
])
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl PullRequestAction for RustServiceRender {
|
||||
async fn execute_pull_request(&self, ctx: &mut Context) -> eyre::Result<()> {
|
||||
let image_tag = ctx
|
||||
.get_image_tag()?
|
||||
.ok_or(eyre::anyhow!("failed to find image_tag"))?;
|
||||
|
||||
cuddle_ci::cuddle_x::well_known::render(vec![
|
||||
"--cluster",
|
||||
"clank-dev",
|
||||
"--image_tag",
|
||||
&image_tag,
|
||||
])
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user