Initialize llvm submodule if not already the case to run citool
This commit is contained in:
parent
69619535d9
commit
4baf9208a1
2 changed files with 21 additions and 1 deletions
|
|
@ -24,7 +24,7 @@ use crate::github::JobInfoResolver;
|
|||
use crate::jobs::RunType;
|
||||
use crate::metrics::{JobMetrics, download_auto_job_metrics, download_job_metrics, load_metrics};
|
||||
use crate::test_dashboard::generate_test_dashboard;
|
||||
use crate::utils::{load_env_var, output_details};
|
||||
use crate::utils::{init_submodule_if_needed, load_env_var, output_details};
|
||||
|
||||
const CI_DIRECTORY: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/..");
|
||||
pub const DOCKER_DIRECTORY: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../docker");
|
||||
|
|
@ -121,6 +121,8 @@ fn run_workflow_locally(db: JobDatabase, job_type: JobType, name: String) -> any
|
|||
(key.clone(), value)
|
||||
}));
|
||||
|
||||
init_submodule_if_needed("src/llvm-project/")?;
|
||||
|
||||
let mut cmd = Command::new(Path::new(DOCKER_DIRECTORY).join("run.sh"));
|
||||
cmd.arg(job.image());
|
||||
cmd.envs(custom_env);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use std::borrow::Cow;
|
||||
use std::convert::AsRef;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
use anyhow::Context;
|
||||
|
||||
|
|
@ -34,3 +36,19 @@ where
|
|||
pub fn normalize_path_delimiters(name: &str) -> Cow<'_, str> {
|
||||
if name.contains("\\") { name.replace('\\', "/").into() } else { name.into() }
|
||||
}
|
||||
|
||||
pub fn init_submodule_if_needed<P: AsRef<Path>>(path_to_submodule: P) -> anyhow::Result<()> {
|
||||
let path_to_submodule = path_to_submodule.as_ref();
|
||||
|
||||
if let Ok(mut iter) = path_to_submodule.read_dir()
|
||||
&& iter.any(|entry| entry.is_ok())
|
||||
{
|
||||
// Seems like the submodule is already initialized, nothing to be done here.
|
||||
return Ok(());
|
||||
}
|
||||
let mut child = Command::new("git")
|
||||
.args(&["submodule", "update", "--init"])
|
||||
.arg(path_to_submodule)
|
||||
.spawn()?;
|
||||
if !child.wait()?.success() { Err(anyhow::anyhow!("git command failed")) } else { Ok(()) }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue