diff --git a/src/build.rs b/src/build.rs index 4132919..b734eac 100644 --- a/src/build.rs +++ b/src/build.rs @@ -1,4 +1,7 @@ -use std::collections::{HashMap, VecDeque}; +use std::{ + collections::{HashMap, VecDeque}, + rc::Rc, +}; use tokio::{ process::Command, @@ -85,7 +88,7 @@ pub async fn build_loop( }; if !paths_built.contains(&eval_job.drv_path) { paths_built.push(eval_job.drv_path.clone()); - match run_build(job.attr, eval_job.drv_path.clone()).await { + match run_build(job.attr, eval_job.drv_path.clone(), copy_tx.clone()).await { Err(e) => { let _ = result_tx .send(NixCiResult { @@ -116,8 +119,12 @@ pub async fn build_loop( } } -#[tracing::instrument(skip(drv_path))] -pub async fn run_build(attr: String, drv_path: String) -> anyhow::Result> { +#[tracing::instrument(skip(drv_path, copy_tx))] +pub async fn run_build( + attr: String, + drv_path: String, + copy_tx: Sender, +) -> anyhow::Result> { let mut child = WrappedChild::new( Command::new("nix") .args(&[ @@ -386,7 +393,40 @@ pub async fn run_build(attr: String, drv_path: String) -> anyhow::Result {} - } + }; + match entry.data.as_ref() { + Some(ActivityDataPerType::Build { drv_path, state }) => { + let result = match state { + BuildState::Done => { + tracing::info!("derivation {} built successfully", drv_path); + BuildResultType::Built + } + BuildState::Failed => { + tracing::error!("derivation {} failed to build", drv_path); + BuildResultType::Failed + } + _ => { + tracing::warn!( + "derivation {} somehow still running??", + drv_path + ); + // unknown build status -> assume it was built successfully if nix build did not return an error + BuildResultType::Unknown + } + }; + if let Err(e) = copy_tx + .send(CopyLoopMessage::Build(BuildResult { + path: drv_path.to_string(), + result: result, + })) + .await + { + tracing::error!("failed to enqueue package copy: {}", e); + break; + } + } + _ => {} + }; } } }