Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ci/citool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "citool"
version = "0.1.0"
edition = "2021"
edition = "2024"

[dependencies]
anyhow = "1"
Expand Down
4 changes: 3 additions & 1 deletion src/ci/citool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions src/ci/citool/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::borrow::Cow;
use std::convert::AsRef;
use std::path::Path;
use std::process::Command;

use anyhow::Context;

Expand Down Expand Up @@ -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