Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
811969871f
commit
c05442baf6
@ -1,5 +1,5 @@
|
||||
[workspace]
|
||||
members = ["crates/*", "examples/*", "ci"]
|
||||
members = ["crates/*", "examples/*"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
@ -15,7 +15,6 @@ cuddle-components = { path = "crates/cuddle-components" }
|
||||
dagger-components = { path = "crates/dagger-components" }
|
||||
dagger-cuddle-please = { path = "crates/dagger-cuddle-please" }
|
||||
dagger-rust = { path = "crates/dagger-rust" }
|
||||
ci = { path = "ci" }
|
||||
|
||||
dagger-sdk = "0.13.7"
|
||||
eyre = "0.6"
|
||||
|
1861
ci/Cargo.lock
generated
1861
ci/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,19 +0,0 @@
|
||||
[package]
|
||||
name = "ci"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
dagger-cuddle-please.workspace = true
|
||||
dagger-rust.workspace = true
|
||||
dagger-sdk.workspace = true
|
||||
|
||||
eyre = "*"
|
||||
color-eyre = "*"
|
||||
tokio = "1"
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
futures = "0.3"
|
||||
async-scoped = { version = "0.9.0", features = ["tokio", "use-tokio"] }
|
||||
dotenv.workspace = true
|
158
ci/src/main.rs
158
ci/src/main.rs
@ -1,158 +0,0 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use clap::Args;
|
||||
use clap::Parser;
|
||||
use clap::Subcommand;
|
||||
use clap::ValueEnum;
|
||||
|
||||
use crate::please_release::run_release_please;
|
||||
|
||||
#[derive(Parser, Clone)]
|
||||
#[command(author, version, about, long_about = None, subcommand_required = true)]
|
||||
pub struct Command {
|
||||
#[command(subcommand)]
|
||||
commands: Commands,
|
||||
|
||||
#[command(flatten)]
|
||||
global: GlobalArgs,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Clone)]
|
||||
pub enum Commands {
|
||||
#[command(subcommand_required = true)]
|
||||
Local {
|
||||
#[command(subcommand)]
|
||||
command: LocalCommands,
|
||||
},
|
||||
PullRequest {},
|
||||
Main {},
|
||||
Release,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Clone)]
|
||||
pub enum LocalCommands {
|
||||
Test,
|
||||
PleaseRelease,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, ValueEnum)]
|
||||
pub enum BuildProfile {
|
||||
Debug,
|
||||
Release,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Args)]
|
||||
pub struct GlobalArgs {
|
||||
#[arg(long, global = true, help_heading = "Global")]
|
||||
dry_run: bool,
|
||||
|
||||
#[arg(long, global = true, help_heading = "Global")]
|
||||
rust_builder_image: Option<String>,
|
||||
|
||||
#[arg(long, global = true, help_heading = "Global")]
|
||||
cuddle_please_image: Option<String>,
|
||||
|
||||
#[arg(long, global = true, help_heading = "Global")]
|
||||
source: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
let _ = dotenv::dotenv();
|
||||
let _ = color_eyre::install();
|
||||
|
||||
let cli = Command::parse();
|
||||
|
||||
dagger_sdk::connect(|client| async move {
|
||||
match &cli.commands {
|
||||
Commands::Local { command } => match command {
|
||||
LocalCommands::Test => {
|
||||
test::execute(client, &cli.global).await?;
|
||||
}
|
||||
LocalCommands::PleaseRelease => todo!(),
|
||||
},
|
||||
Commands::PullRequest {} => {
|
||||
async fn test(client: dagger_sdk::Query, cli: &Command) {
|
||||
let args = &cli.global;
|
||||
|
||||
test::execute(client.clone(), args).await.unwrap();
|
||||
}
|
||||
|
||||
tokio::join!(test(client.clone(), &cli),);
|
||||
}
|
||||
Commands::Main {} => {
|
||||
async fn test(client: dagger_sdk::Query, cli: &Command) {
|
||||
let args = &cli.global;
|
||||
|
||||
test::execute(client.clone(), args).await.unwrap();
|
||||
}
|
||||
|
||||
async fn cuddle_please(client: dagger_sdk::Query, cli: &Command) {
|
||||
run_release_please(client.clone(), &cli.global)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
tokio::join!(
|
||||
test(client.clone(), &cli),
|
||||
cuddle_please(client.clone(), &cli)
|
||||
);
|
||||
}
|
||||
Commands::Release => {}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
mod please_release {
|
||||
|
||||
use dagger_cuddle_please::{models::CuddlePleaseSrcArgs, DaggerCuddlePleaseAction};
|
||||
|
||||
use crate::GlobalArgs;
|
||||
|
||||
pub async fn run_release_please(
|
||||
client: dagger_sdk::Query,
|
||||
args: &GlobalArgs,
|
||||
) -> eyre::Result<()> {
|
||||
DaggerCuddlePleaseAction::dagger(client)
|
||||
.execute_src(&CuddlePleaseSrcArgs {
|
||||
cuddle_image: args
|
||||
.cuddle_please_image
|
||||
.clone()
|
||||
.unwrap_or("kasperhermansen/cuddle-please:latest".into()),
|
||||
server: dagger_cuddle_please::models::SrcServer::Gitea {
|
||||
token: std::env::var("CUDDLE_PLEASE_TOKEN")
|
||||
.expect("CUDDLE_PLEASE_TOKEN to be present"),
|
||||
},
|
||||
log_level: Some(dagger_cuddle_please::models::LogLevel::Debug),
|
||||
})
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
mod test {
|
||||
use std::path::PathBuf;
|
||||
|
||||
use dagger_rust::build::RustVersion;
|
||||
|
||||
use crate::GlobalArgs;
|
||||
|
||||
pub async fn execute(client: dagger_sdk::Query, _args: &GlobalArgs) -> eyre::Result<()> {
|
||||
dagger_rust::test::RustTest::new(client)
|
||||
.test(
|
||||
None::<PathBuf>,
|
||||
RustVersion::Nightly,
|
||||
&["crates/*", "examples/*", "ci"],
|
||||
&[],
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user