From 9ca574cb943cfe51a221f37cbb01375d3d7ee6eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9B=A7-440729=20=5Bsophie=5D?= Date: Sat, 28 Jun 2025 00:51:57 +0200 Subject: [PATCH] try to fix unknown builds with unknown build status --- src/build.rs | 74 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 6 deletions(-) diff --git a/src/build.rs b/src/build.rs index 2f97e18..4132919 100644 --- a/src/build.rs +++ b/src/build.rs @@ -62,6 +62,7 @@ struct BuildProgress { failed: u64, started_builds: VecDeque, reported_builds: VecDeque, + unreported_builds: VecDeque, } pub async fn build_loop( @@ -208,13 +209,67 @@ pub async fn run_build(attr: String, drv_path: String) -> anyhow::Result progress_entry.failed { progress_entry.failed += 1; - progress_entry - .reported_builds - .push_back(BuildState::Failed); + if let Some(build_id) = + progress_entry.unreported_builds.pop_front() + { + if let Some(entry) = activities.get_mut(&build_id) { + match entry.r#type { + NixInternalLogLineActivityType::Build => { + let ActivityDataPerType::Build { + drv_path, + state, + } = entry.data.as_mut().unwrap() + else { + panic!( + "this can't happen (build activity without build data)" + ); + }; + tracing::info!( + "reported failed build for derivation {} after stop", + drv_path + ); + *state = BuildState::Failed; + } + _ => {} + } + } + } else { + progress_entry + .reported_builds + .push_back(BuildState::Failed); + } } while done > progress_entry.done { progress_entry.done += 1; - progress_entry.reported_builds.push_back(BuildState::Done); + if let Some(build_id) = + progress_entry.unreported_builds.pop_front() + { + if let Some(entry) = activities.get_mut(&build_id) { + match entry.r#type { + NixInternalLogLineActivityType::Build => { + let ActivityDataPerType::Build { + drv_path, + state, + } = entry.data.as_mut().unwrap() + else { + panic!( + "this can't happen (build activity without build data)" + ); + }; + tracing::info!( + "reported done build for derivation {} after stop", + drv_path + ); + *state = BuildState::Done; + } + _ => {} + } + } + } else { + progress_entry + .reported_builds + .push_back(BuildState::Done); + } } } // meta-progress counting the paths being downloaded as part of the build @@ -270,6 +325,7 @@ pub async fn run_build(attr: String, drv_path: String) -> anyhow::Result anyhow::Result {} @@ -355,7 +412,12 @@ pub async fn run_build(attr: String, drv_path: String) -> anyhow::Result { tracing::warn!("derivation {} somehow still running??", drv_path); - BuildResultType::Unknown + // unknown build status -> assume it was built successfully if nix build did not return an error + if exit_status.success() { + BuildResultType::Built + } else { + BuildResultType::Unknown + } } }; results @@ -368,7 +430,7 @@ pub async fn run_build(attr: String, drv_path: String) -> anyhow::Result { - tracing::info!("downloaded {}", store_path); + tracing::trace!("downloaded {}", store_path); } _ => {} }