Watch
0
0
Fork
You've already forked hyperhive
0

push green meta builds to the attic cache and record cached

This commit is contained in:
atlas 2026-10-27 10:12:35 +01:00
commit 0849afec80

View file

@ -306,13 +306,18 @@ pub(crate) async fn run(
}
Outcome::Failed(error_tail)
}
Ok(FromMetaReply::Built { out_path, system }) => {
Ok(FromMetaReply::Built {
out_path,
system,
cached,
}) => {
let built_rev = meta_rev.clone();
let closure = AgentClosure {
meta_rev,
store_path: out_path.clone(),
system,
built_unix: unix_now(),
cached,
};
match queue.record(&agent, &closure).await {
Ok(()) => {
@ -415,9 +420,14 @@ mod tests {
}
fn built() -> Self {
Self::built_cached(false)
}
fn built_cached(cached: bool) -> Self {
Self::answering(Ok(FromMetaReply::Built {
out_path: "/nix/store/x-toplevel".to_owned(),
system: "x86_64-linux".to_owned(),
cached,
}))
}
}
@ -470,6 +480,22 @@ mod tests {
assert_eq!(closure.store_path, "/nix/store/x-toplevel");
assert_eq!(closure.system, "x86_64-linux");
assert!(closure.built_unix > 0);
assert!(!closure.cached);
}
/// The record says what the builder said about the cache, both ways.
#[tokio::test]
async fn the_record_carries_whether_the_builder_cached_the_closure() {
for cached in [true, false] {
let queue = FakeQueue::built_cached(cached);
let outcome = run_with(&FakeHead::reading(Ok(Some(REV))), &queue).await;
assert_eq!(outcome, Outcome::Done);
let recorded = queue.recorded.lock().unwrap();
let [(_, closure)] = recorded.as_slice() else {
panic!("one record: {recorded:?}")
};
assert_eq!(closure.cached, cached);
}
}
/// Any `nix` failure, a timeout included, fails the node at once with what
@ -749,6 +775,7 @@ mod tests {
store_path: "/nix/store/a".to_owned(),
system: "x86_64-linux".to_owned(),
built_unix: 1,
cached: false,
};
client.record("atlas", &closure).await.expect("written");
closure.store_path = "/nix/store/b".to_owned();