use crate::harness_runtime::{Artifact, Delivery, Previous, Shape, Software};
pub(crate) const ARTIFACTS: &[Artifact] = &[
Artifact {
platform: "linux/arm64",
url: "https://x.ai/cli/grok-1.0.18-linux-aarch64",
bytes: 129_675_416,
sha256: "sha256:e5c96058b6f88b2e9ae7d61401e80ac6bcbcaf1be5681eae19e36a2b8aff121d",
shape: Shape::Raw,
member: "",
},
Artifact {
platform: "linux/x86_64",
url: "https://x.ai/cli/grok-1.0.18-linux-x86_64",
bytes: 155_510_304,
sha256: "sha256:42f6efb496feafea3e8807b75852cc1f792cba0bd0be8ecbd1c9f7ed5816a7f0",
shape: Shape::Raw,
member: "",
},
Artifact {
platform: "macos/arm64",
url: "https://x.ai/cli/grok-1.0.18-macos-aarch64",
bytes: 135_828_368,
sha256: "sha256:99b77202286face91f27f97caca0590377b36300ccca99ff18e730228f7a5ca3",
shape: Shape::Raw,
member: "",
},
Artifact {
platform: "macos/x86_64",
url: "https://x.ai/cli/grok-1.0.18-macos-x86_64",
bytes: 152_347_968,
sha256: "sha256:b6b682eb551e503dfb80368e46c2129a74ba51af598692ba8f4c59202653fd2a",
shape: Shape::Raw,
member: "",
},
Artifact {
platform: "windows/arm64",
url: "https://x.ai/cli/grok-1.0.18-windows-aarch64.exe",
bytes: 123_747_656,
sha256: "sha256:d4d38c41e7a18979ca0c591244c03d4c0909001d4a288f67d6e9e92d5ac0eca9",
shape: Shape::Raw,
member: "",
},
Artifact {
platform: "windows/x86_64",
url: "https://x.ai/cli/grok-1.0.18-windows-x86_64.exe",
bytes: 143_124_808,
sha256: "sha256:c407a08a5b987c528c8c515394ce839319cbe69a7c0f73e322348038754387eb",
shape: Shape::Raw,
member: "",
},
];
pub(crate) const PREVIOUS_ARTIFACTS: &[Artifact] = &[
Artifact {
platform: "linux/arm64",
url: "https://x.ai/cli/grok-1.0.13-linux-aarch64",
bytes: 135_641_288,
sha256: "sha256:b926fc5308374396e260e7efbd6107231a8dae13c084ddaf0fe89b7ebb3edd25",
shape: Shape::Raw,
member: "",
},
Artifact {
platform: "linux/x86_64",
url: "https://x.ai/cli/grok-1.0.13-linux-x86_64",
bytes: 166_079_904,
sha256: "sha256:edf79521581bb5e6b95abef848491a6a742e860da3e237ebe86a280d30dce4c1",
shape: Shape::Raw,
member: "",
},
Artifact {
platform: "macos/arm64",
url: "https://x.ai/cli/grok-1.0.13-macos-aarch64",
bytes: 133_486_016,
sha256: "sha256:8669e0fdadceec25b8c159c355f427ffbd82583525d774b6ab1522197ea83b80",
shape: Shape::Raw,
member: "",
},
Artifact {
platform: "macos/x86_64",
url: "https://x.ai/cli/grok-1.0.13-macos-x86_64",
bytes: 149_694_528,
sha256: "sha256:8eacec87f5ecdb9259c6d812d12ce9e2d405b1526e36ae9d7fc81ec31dbd74d6",
shape: Shape::Raw,
member: "",
},
Artifact {
platform: "windows/arm64",
url: "https://x.ai/cli/grok-1.0.13-windows-aarch64.exe",
bytes: 122_000_712,
sha256: "sha256:b8881ea0a30874a94d1a3eaec9ba30c9648f597b8bf22454c334574f2f931e7b",
shape: Shape::Raw,
member: "",
},
Artifact {
platform: "windows/x86_64",
url: "https://x.ai/cli/grok-1.0.13-windows-x86_64.exe",
bytes: 140_810_568,
sha256: "sha256:bf43dc75f5478a106eab1e86d422c963e4dbe9666cf14dab363733d27bf1e672",
shape: Shape::Raw,
member: "",
},
];
pub(crate) const SOFTWARE: Software = Software {
version: "1.0.18",
command: "grok",
delivery: Delivery::Artifacts(ARTIFACTS),
unsupported: &[],
previous: Some(Previous {
version: "1.0.13",
artifacts: PREVIOUS_ARTIFACTS,
}),
};
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used, clippy::panic)]
use crate::harness_runtime::{Delivery, Shape};
use super::SOFTWARE;
fn measured() -> serde_json::Value {
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../references/grok-baseline.json");
serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap()
}
#[test]
fn every_artifact_compiled_in_is_the_one_the_baseline_measured() {
let block = &measured()["software_artifacts"];
assert_eq!(block["version"], SOFTWARE.version);
assert_eq!(block["command"], SOFTWARE.command);
let Delivery::Artifacts(compiled) = SOFTWARE.delivery else {
assert_eq!(block["shape"], "manager");
assert!(block["platforms"].as_object().unwrap().is_empty());
return;
};
let published = block["platforms"].as_object().unwrap();
assert_eq!(
compiled.len(),
published.len(),
"the table and the baseline disagree on how many platforms exist"
);
for artifact in compiled {
let entry = &published[artifact.platform];
assert_eq!(entry["url"], artifact.url, "{}", artifact.platform);
assert_eq!(entry["bytes"], artifact.bytes, "{}", artifact.platform);
assert_eq!(entry["sha256"], artifact.sha256, "{}", artifact.platform);
let member = entry.get("member").and_then(serde_json::Value::as_str);
assert_eq!(
member.unwrap_or(""),
artifact.member,
"{} names a different member",
artifact.platform
);
assert_eq!(
artifact.shape == Shape::Raw,
member.is_none(),
"{} disagrees about whether the bytes are the program",
artifact.platform
);
}
}
#[test]
fn the_version_this_build_can_move_between_is_the_one_measured_before_it() {
let baseline = measured();
let recorded = baseline.get("previous_software_artifacts");
let Some(earlier) = SOFTWARE.previous else {
assert!(
recorded.is_none(),
"the baseline records a previous release and this build names none"
);
return;
};
let block = recorded.unwrap_or_else(|| {
panic!("this build names a previous release the baseline does not record")
});
assert_eq!(block["version"], earlier.version);
assert_ne!(
earlier.version, SOFTWARE.version,
"a second pin equal to the first is one version wearing two names"
);
let published = block["platforms"].as_object().unwrap();
assert_eq!(
earlier.artifacts.len(),
published.len(),
"the previous table and the baseline disagree on how many platforms exist"
);
for artifact in earlier.artifacts {
let entry = &published[artifact.platform];
assert_eq!(entry["url"], artifact.url, "{}", artifact.platform);
assert_eq!(entry["bytes"], artifact.bytes, "{}", artifact.platform);
assert_eq!(entry["sha256"], artifact.sha256, "{}", artifact.platform);
}
}
#[test]
fn a_platform_the_vendor_does_not_publish_is_listed_rather_than_missing() {
let block = &measured()["software_artifacts"];
let unpublished: Vec<&str> = block
.get("unpublished")
.and_then(serde_json::Value::as_array)
.map(|entries| {
entries
.iter()
.filter_map(serde_json::Value::as_str)
.collect()
})
.unwrap_or_default();
assert_eq!(unpublished, SOFTWARE.unsupported);
}
#[test]
fn no_release_calls_a_platform_both_published_and_unpublished() {
let baseline = measured();
for name in ["software_artifacts", "previous_software_artifacts"] {
let Some(block) = baseline.get(name) else {
continue;
};
let published = block["platforms"].as_object().unwrap();
let unpublished = block
.get("unpublished")
.and_then(serde_json::Value::as_array)
.into_iter()
.flatten()
.filter_map(serde_json::Value::as_str);
for platform in unpublished {
assert!(
!published.contains_key(platform),
"{name}: {platform} is both published and unpublished"
);
}
}
}
}