mirror of
https://seed.radicle.dev/rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE.git
synced 2026-11-21 02:20:49 +08:00
chore: drop the rad-ci binary
It's not in its own crate. Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
@@ -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<bool, Box<dyn std::error::Error>> {
|
||||
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,
|
||||
}
|
||||
Reference in New Issue
Block a user