diff --git a/crates/forge-runner/src/check.rs b/crates/forge-runner/src/check.rs index 56f516f..956184d 100644 --- a/crates/forge-runner/src/check.rs +++ b/crates/forge-runner/src/check.rs @@ -231,6 +231,18 @@ fn delegated_controllers() -> Result, String> { Ok(enabled.split_whitespace().map(str::to_owned).collect()) } +/// The runner checks out each job's commit with the host's `git`. +async fn git_line() -> Line { + match Command::new("git").arg("--version").output().await { + Ok(out) if out.status.success() => Line::ok( + "git", + String::from_utf8_lossy(&out.stdout).trim().to_owned(), + ), + Ok(out) => Line::fail("git", format!("git --version exited with {}", out.status)), + Err(e) => Line::fail("git", format!("git is not installed on this host: {e}")), + } +} + /// Builds the report from the probe result. Pure, so the rules can be tested. fn report(probe: Result<&Probe, &str>, controllers: Result<&[String], &str>) -> Vec { let mut lines = Vec::new(); @@ -410,7 +422,7 @@ pub async fn run(helper: &Path, work_dir: &Path, mode: UsernsMode) -> bool { }; let probe = run_probe(helper, &work_dir, &map).await; let controllers = delegated_controllers(); - let mut lines = vec![Line::ok("user ids", map.describe())]; + let mut lines = vec![Line::ok("user ids", map.describe()), git_line().await]; lines.extend(report( probe.as_ref().map_err(String::as_str), controllers.as_deref().map_err(String::as_str), diff --git a/crates/forge-runner/src/workspace.rs b/crates/forge-runner/src/workspace.rs index 331285c..b6c2152 100644 --- a/crates/forge-runner/src/workspace.rs +++ b/crates/forge-runner/src/workspace.rs @@ -170,7 +170,13 @@ async fn git( .stderr(Stdio::piped()) .kill_on_drop(true) .output() - .await?; + .await + .map_err(|e| match e.kind() { + std::io::ErrorKind::NotFound => { + WorkspaceError::Invalid("git is not installed on the runner host".to_owned()) + } + _ => WorkspaceError::Io(e), + })?; if output.status.success() { return Ok(()); } diff --git a/docs/ci.md b/docs/ci.md index 73c51f5..a0ab4af 100644 --- a/docs/ci.md +++ b/docs/ci.md @@ -487,6 +487,7 @@ but operators should use `forge runner`, which the examples below show. The builtin executor needs: +- **git** on the host. The runner checks out each job's commit with it. - **Linux 5.11 or newer.** Overlayfs inside a user namespace needs it. On an older kernel, jobs still run, but each one gets a full copy of the image instead of an overlay. - **Unprivileged user namespaces.** Check that `/proc/sys/user/max_user_namespaces` is above 0. On