forge
Explore
Log in

Don't you dare go Hollow

A runner host without git fails the job with "git is not installed on the runner host" instead of a bare "No such file or directory", and forge runner check tests for git

Browse files at this commit

79e878fbf4a18624d5e666b342c16f869011a55aAhmet Kaan GümüşParent: b6feaae
Some checks failed
Show checks
  • fix
    • a runner host without git fails the job with "git is not installed on the runner host" instead of a bare "No such file or directory", and forge runner check tests for git
  • docs
    • git is a runner host requirement
Show full message
🐛 fix: a runner host without git fails the job with "git is not installed on the runner host" instead of a bare "No such file or directory", and forge runner check tests for git; 📝 docs: git is a runner host requirement
crates/forge-runner/src/check.rsmodified+13 -1
@@ -231,6 +231,18 @@ fn delegated_controllers() -> Result<Vec<String>, String> {
231 Ok(enabled.split_whitespace().map(str::to_owned).collect())231 Ok(enabled.split_whitespace().map(str::to_owned).collect())
232 }232 }
233 233
234+/// The runner checks out each job's commit with the host's `git`.
235+async fn git_line() -> Line {
236+ match Command::new("git").arg("--version").output().await {
237+ Ok(out) if out.status.success() => Line::ok(
238+ "git",
239+ String::from_utf8_lossy(&out.stdout).trim().to_owned(),
240+ ),
241+ Ok(out) => Line::fail("git", format!("git --version exited with {}", out.status)),
242+ Err(e) => Line::fail("git", format!("git is not installed on this host: {e}")),
243+ }
244+}
245+
234 /// Builds the report from the probe result. Pure, so the rules can be tested.246 /// Builds the report from the probe result. Pure, so the rules can be tested.
235 fn report(probe: Result<&Probe, &str>, controllers: Result<&[String], &str>) -> Vec<Line> {247 fn report(probe: Result<&Probe, &str>, controllers: Result<&[String], &str>) -> Vec<Line> {
236 let mut lines = Vec::new();248 let mut lines = Vec::new();
@@ -410,7 +422,7 @@ pub async fn run(helper: &Path, work_dir: &Path, mode: UsernsMode) -> bool {
410 };422 };
411 let probe = run_probe(helper, &work_dir, &map).await;423 let probe = run_probe(helper, &work_dir, &map).await;
412 let controllers = delegated_controllers();424 let controllers = delegated_controllers();
413- let mut lines = vec![Line::ok("user ids", map.describe())];425+ let mut lines = vec![Line::ok("user ids", map.describe()), git_line().await];
414 lines.extend(report(426 lines.extend(report(
415 probe.as_ref().map_err(String::as_str),427 probe.as_ref().map_err(String::as_str),
416 controllers.as_deref().map_err(String::as_str),428 controllers.as_deref().map_err(String::as_str),
crates/forge-runner/src/workspace.rsmodified+7 -1
@@ -170,7 +170,13 @@ async fn git(
170 .stderr(Stdio::piped())170 .stderr(Stdio::piped())
171 .kill_on_drop(true)171 .kill_on_drop(true)
172 .output()172 .output()
173- .await?;173+ .await
174+ .map_err(|e| match e.kind() {
175+ std::io::ErrorKind::NotFound => {
176+ WorkspaceError::Invalid("git is not installed on the runner host".to_owned())
177+ }
178+ _ => WorkspaceError::Io(e),
179+ })?;
174 if output.status.success() {180 if output.status.success() {
175 return Ok(());181 return Ok(());
176 }182 }
docs/ci.mdmodified+1 -0
@@ -487,6 +487,7 @@ but operators should use `forge runner`, which the examples below show.
487 487
488 The builtin executor needs:488 The builtin executor needs:
489 489
490+- **git** on the host. The runner checks out each job's commit with it.
490 - **Linux 5.11 or newer.** Overlayfs inside a user namespace needs it. On an older kernel, jobs491 - **Linux 5.11 or newer.** Overlayfs inside a user namespace needs it. On an older kernel, jobs
491 still run, but each one gets a full copy of the image instead of an overlay.492 still run, but each one gets a full copy of the image instead of an overlay.
492 - **Unprivileged user namespaces.** Check that `/proc/sys/user/max_user_namespaces` is above 0. On493 - **Unprivileged user namespaces.** Check that `/proc/sys/user/max_user_namespaces` is above 0. On