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

@ -140,8 +140,16 @@ pub struct BuildFromMeta {
#[serde(tag = "state", rename_all = "kebab-case")]
pub enum FromMetaReply {
/// The toplevel built; `out_path` is its store path in the builder host's
/// store and `system` the platform the builder host builds for.
Built { out_path: String, system: String },
/// store and `system` the platform the builder host builds for. `cached`
/// is whether the builder pushed the closure to the binary cache; a failed
/// push leaves the build green with `cached` false. A builder that predates
/// the field answers without it, which reads as false.
Built {
out_path: String,
system: String,
#[serde(default)]
cached: bool,
},
/// The build did not succeed: the last lines `nix` printed, or why it
/// stopped (it timed out, or could not start). The controller holds the
/// deploy back and builds again on its next round.
@ -253,8 +261,14 @@ mod tests {
FromMetaReply::Built {
out_path: "/nix/store/x".to_owned(),
system: "x86_64-linux".to_owned(),
cached: true,
},
json!({"state": "built", "out_path": "/nix/store/x", "system": "x86_64-linux"}),
json!({
"state": "built",
"out_path": "/nix/store/x",
"system": "x86_64-linux",
"cached": true,
}),
),
(
FromMetaReply::Failed {
@ -277,6 +291,19 @@ mod tests {
}
}
#[test]
fn a_built_reply_from_a_builder_without_the_field_reads_as_not_cached() {
let old = json!({"state": "built", "out_path": "/nix/store/x", "system": "s"});
assert_eq!(
serde_json::from_value::<FromMetaReply>(old).expect("decodes"),
FromMetaReply::Built {
out_path: "/nix/store/x".to_owned(),
system: "s".to_owned(),
cached: false,
}
);
}
#[test]
fn the_subjects_are_pinned() {
assert_eq!(SUBJECT, "$SWARM.builder.build");