push green meta builds to the attic cache and record cached
This commit is contained in:
parent
c4e8d5b540
commit
0849afec80
2 changed files with 779 additions and 31 deletions
|
|
@ -32,6 +32,10 @@ pub struct AgentClosure {
|
|||
pub system: String,
|
||||
/// When the controller recorded the build, in unix seconds.
|
||||
pub built_unix: i64,
|
||||
/// Whether the builder pushed the closure to the binary cache. A record
|
||||
/// written before the field existed reads as false.
|
||||
#[serde(default)]
|
||||
pub cached: bool,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
@ -51,12 +55,14 @@ mod tests {
|
|||
store_path: "/nix/store/x".to_owned(),
|
||||
system: "x86_64-linux".to_owned(),
|
||||
built_unix: 7,
|
||||
cached: true,
|
||||
};
|
||||
let wire = serde_json::json!({
|
||||
"meta_rev": "abc",
|
||||
"store_path": "/nix/store/x",
|
||||
"system": "x86_64-linux",
|
||||
"built_unix": 7,
|
||||
"cached": true,
|
||||
});
|
||||
assert_eq!(serde_json::to_value(&value).expect("encodes"), wire);
|
||||
assert_eq!(
|
||||
|
|
@ -64,4 +70,16 @@ mod tests {
|
|||
value
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_record_without_the_field_reads_as_not_cached() {
|
||||
let old = serde_json::json!({
|
||||
"meta_rev": "abc",
|
||||
"store_path": "/nix/store/x",
|
||||
"system": "x86_64-linux",
|
||||
"built_unix": 7,
|
||||
});
|
||||
let record = serde_json::from_value::<AgentClosure>(old).expect("decodes");
|
||||
assert!(!record.cached);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue