mirror of
https://seed.radicle.dev/rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE.git
synced 2026-10-31 00:41:00 +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:
@@ -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.
|
||||
|
||||
@@ -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