add complement wrapper xtask script

This commit is contained in:
Benjamin Lee 2024-06-20 19:06:57 -07:00
parent 3f89bc4a7c
commit ef6eb27b9b
No known key found for this signature in database
GPG key ID: FB9624E2885D55A4
10 changed files with 292 additions and 0 deletions

32
xtask/src/complement.rs Normal file
View file

@ -0,0 +1,32 @@
use std::path::PathBuf;
use miette::{IntoDiagnostic, Result, WrapErr};
use xshell::{cmd, Shell};
mod docker;
mod test2json;
use self::{docker::load_docker_image, test2json::run_complement};
#[derive(clap::Args)]
pub(crate) struct Args;
#[allow(clippy::needless_pass_by_value)]
pub(crate) fn main(_args: Args) -> Result<()> {
let sh = Shell::new().unwrap();
let toplevel = get_toplevel_path(&sh)
.wrap_err("failed to determine repository root directory")?;
let docker_image = load_docker_image(&sh, &toplevel).wrap_err(
"failed to build and load complement-grapevine docker image",
)?;
run_complement(&sh, &docker_image)
.wrap_err("failed to run complement tests")?;
Ok(())
}
/// Returns the path to the repository root
fn get_toplevel_path(sh: &Shell) -> Result<PathBuf> {
let path =
cmd!(sh, "git rev-parse --show-toplevel").read().into_diagnostic()?;
Ok(path.into())
}