diff --git a/README.md b/README.md index 0fdad55..11e2dcd 100644 --- a/README.md +++ b/README.md @@ -22,39 +22,9 @@ shell: | [Radicle CI broker]: https://app.radicle.xyz/nodes/radicle.liw.fi/rad:zwTxygwuz5LDGBq255RA2CbNGrz8 -This crate also includes the program `rad-ci`, which runs the commands -the adapter runs when invoked by the CI broker. To use: install it on -your `$PATH` (using `cargo install`) and run: - -```sh -rad ci -``` - This will read `.radicle/native.yaml` and run the shell commands specified there. -Toe see `rad-ci` options, run it with the `--help` option: - -~~~sh -$ rad-ci -- --help -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. - -Usage: rad-ci [OPTIONS] - -Options: - --dry-run - Don't actually run anything, merely output what would be given to Bash to run - - -h, --help - Print help (see a summary with '-h') - - -V, --version - Print version -~~~ - ## Architecture See the [documentation](doc) directory for an architecture document. diff --git a/src/bin/rad-ci.rs b/src/bin/rad-ci.rs deleted file mode 100644 index 65464d7..0000000 --- a/src/bin/rad-ci.rs +++ /dev/null @@ -1,63 +0,0 @@ -use std::{ - path::Path, - process::{exit, Command}, -}; - -use clap::Parser; -use radicle_native_ci::{run::RUNSPEC_PATH, runspec::RunSpec}; - -// Exit codes for the program. -const EXIT_OK: i32 = 0; -const EXIT_FAILURE: i32 = 1; -const EXIT_ERROR: i32 = 2; - -/// The main program. -fn main() { - let code = match fallible_main() { - Ok(success) => { - if success { - EXIT_OK - } else { - EXIT_FAILURE - } - } - Err(e) => { - eprintln!("ERROR: {}", e); - let mut e = e.source(); - while let Some(source) = e { - eprintln!("caused by: {}", source); - e = source.source(); - } - EXIT_ERROR - } - }; - exit(code); -} - -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); - 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, -}