Watch
0
0
Fork
You've already forked hyperhive
0

seed a hyperhive/hyperhive mirror so update_meta finds it on a fresh swarm

This commit is contained in:
atlas 2026-11-09 12:19:46 +01:00
commit a6b5bafa83

View file

@ -40,6 +40,15 @@ const REV_FILE: &str = "/etc/hyperhive/swarm-controller.json";
const HYPERHIVE_OWNER: &str = "hyperhive";
const HYPERHIVE_REPO: &str = "hyperhive";
/// The error for a swarm forge with no readable hyperhive repo, naming the nix
/// option that mirrors one there.
fn missing_hyperhive() -> String {
format!(
"{HYPERHIVE_OWNER}/{HYPERHIVE_REPO} is empty or absent on the swarm forge; \
services.hyperhive.deploy.forgejo.hyperhiveUpstream mirrors it there"
)
}
/// What every agent of the swarm gets, the same on every hive.
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
@ -365,8 +374,9 @@ async fn hyperhive_pin(
let Some(flake) = committed_flake else {
let head = forge
.head_files(HYPERHIVE_OWNER, HYPERHIVE_REPO, None, &[])
.await?
.with_context(|| format!("{HYPERHIVE_OWNER}/{HYPERHIVE_REPO} is empty or absent"))?;
.await
.with_context(missing_hyperhive)?
.with_context(missing_hyperhive)?;
return Ok(HyperhivePin {
rev: head.commit,
moved: false,
@ -841,6 +851,29 @@ mod tests {
);
}
#[tokio::test]
async fn a_forge_without_hyperhive_names_the_option_that_mirrors_it() {
let mut forge = forge_with(&[]);
forge.repos.remove("hyperhive/hyperhive");
let err = update(
&forge,
&FakeLocker::locked(),
&settings(),
None,
&argus_and_reviewer(),
&[],
)
.await
.unwrap_err();
let err = format!("{err:#}");
assert!(
err.contains("hyperhive/hyperhive is empty or absent")
&& err.contains("services.hyperhive.deploy.forgejo.hyperhiveUpstream"),
"{err}"
);
assert!(forge.commits.lock().unwrap().is_empty());
}
#[tokio::test]
async fn a_refused_lock_commits_nothing() {
let forge = forge_with(&[]);