diff --git a/Cargo.lock b/Cargo.lock index 9261425..acdb4c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -384,9 +384,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.21" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ "clap_builder", "clap_derive", @@ -394,9 +394,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.21" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstream", "anstyle", @@ -419,9 +419,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "colorchoice" @@ -1971,6 +1971,7 @@ dependencies = [ name = "radicle-native-ci" version = "0.5.0" dependencies = [ + "clap", "html-page", "radicle", "radicle-ci-broker", diff --git a/Cargo.toml b/Cargo.toml index 0a9c728..0de51c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ repository = "https://app.radicle.xyz/nodes/radicle.liw.fi/rad:z3qg5TKmN83afz2fj categories = ["development-tools::build-utils"] [dependencies] +clap = { version = "4.5.23", features = ["derive"] } html-page = "0.4.0" radicle = "0.13.0" radicle-ci-broker = "0.8.0" diff --git a/src/bin/rad-ci.rs b/src/bin/rad-ci.rs index 3643294..65464d7 100644 --- a/src/bin/rad-ci.rs +++ b/src/bin/rad-ci.rs @@ -3,6 +3,7 @@ use std::{ process::{exit, Command}, }; +use clap::Parser; use radicle_native_ci::{run::RUNSPEC_PATH, runspec::RunSpec}; // Exit codes for the program. @@ -34,8 +35,29 @@ fn main() { } fn fallible_main() -> Result> { + let args = Args::parse(); let runspec = RunSpec::from_file(Path::new(RUNSPEC_PATH))?; let shell = format!("set -xeuo pipefail\n{}", runspec.shell); - let exit = Command::new("bash").args(["-c", &shell]).spawn()?.wait()?; - Ok(exit.success()) + if args.dry_run { + print!("{shell}"); + Ok(true) + } else { + let exit = Command::new("bash").args(["-c", &shell]).spawn()?.wait()?; + Ok(exit.success()) + } +} + +/// Run the commands the Radicle native CI adapter would run for this +/// repository. +/// +/// The shell commands are specified in the .radicle/native.yaml file, +/// in the shell field. They are run directly on the host, using the +/// Bash shell, without any isolation. +#[derive(Debug, Parser)] +#[clap(version)] +struct Args { + /// Don't actually run anything, merely output what would be given + /// to Bash to run. + #[clap(long, alias = "no-act")] + dry_run: bool, }