Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
fix: with test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kjuulh committed Feb 18, 2023
1 parent a203683 commit d723130
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
54 changes: 51 additions & 3 deletions ci/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ fn main() -> eyre::Result<()> {
let matches = clap::Command::new("ci")
.subcommand_required(true)
.subcommand(clap::Command::new("pr"))
.subcommand(clap::Command::new("release"))
.get_matches();

let client = dagger_sdk::client::connect()?;

let base = select_base_image(client.clone());

match matches.subcommand() {
Some(("pr", _)) => return validate_pr(client, base),
Some(("pr", _)) => {
let base = select_base_image(client.clone());
return validate_pr(client, base);
}
Some(("release", subm)) => return release(client, subm),
Some(_) => {
panic!("invalid subcommand selected!")
}
Expand All @@ -25,6 +28,51 @@ fn main() -> eyre::Result<()> {
}
}

fn release(client: Arc<Query>, subm: &clap::ArgMatches) -> Result<(), color_eyre::Report> {
let src_dir = client.host().directory(
".".into(),
Some(HostDirectoryOpts {
exclude: Some(vec!["target/".into()]),
include: None,
}),
);
let base_image = client
.container(None)
.from("rust:latest".into())
.with_workdir("app".into())
.with_mounted_directory("/app/".into(), src_dir.id());

let container = base_image
.with_exec(
vec![
"cargo".into(),
"install".into(),
"cargo-smart-release".into(),
],
None,
)
.with_exec(
vec![
"cargo".into(),
"smart-release".into(),
"--execute".into(),
"--allow-fully-generated-changelogs".into(),
"--no-changelog-preview".into(),
"dagger-rs".into(),
"dagger-sdk".into(),
],
None,
);
let exit = container.exit_code();
if exit != 0 {
eyre::bail!("container failed with non-zero exit code");
}

println!("released pr succeeded!");

Ok(())
}

fn get_dependencies(client: Arc<Query>) -> Container {
let cargo_dir = client.host().directory(
".".into(),
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod cli;
mod cli_generate;

fn main() -> eyre::Result<()> {
// test change
color_eyre::install().unwrap();

let args = std::env::args();
Expand Down

0 comments on commit d723130

Please sign in to comment.