Watch
0
0
Fork
You've already forked hyperhive
0

swarm-controller: record builder runs with nix's tail and link the status to them

This commit is contained in:
atlas 2026-10-17 23:17:00 +02:00 • committed by mara
commit d4714072a9
11 changed files with 833 additions and 48 deletions

View file

@ -600,7 +600,16 @@ async fn build_agent(
pr: u64,
) -> hive_jobq::scheduler::Outcome {
let job = swarm_queue_client::builder::BuildAgent { agent, rev, pr };
builder::run(deps.queue.as_ref(), forge.as_deref(), job).await
let builds = builder::runs::Builds::Live(deps.queue.clone());
let link_base = std::env::var(PUBLIC_URL_ENV).ok();
builder::run(
deps.queue.as_ref(),
forge.as_deref(),
&builds,
link_base.as_deref(),
job,
)
.await
}
/// The `MintBuilderForgeToken` arm, lifted out for the same reason.
@ -887,6 +896,7 @@ fn socket_path() -> PathBuf {
(name = "review-classifier", description = "trying review classifications against a PR (swarm-ui's try-out page), and the classifier's swarm-wide settings"),
(name = "pulls", description = "open pull requests, for the try-out page's dropdowns"),
(name = "alerts", description = "the swarm Grafana's current alerts (swarm-ui's alerts page)"),
(name = "builder", description = "the swarm builder's finished builds of agent config PRs, which their commit statuses link to"),
)
)]
struct ApiDoc;
@ -1022,6 +1032,8 @@ struct AppState {
reviews: Arc<review_classifier::review::Reviews>,
/// The review classifier's finished runs.
runs: review_classifier::runs::Runs,
/// The swarm builder's finished builds.
builds: builder::runs::Builds,
/// Grafana's alerts API, for `GET /api/alerts`. `None` when no Grafana URL
/// is configured.
alerts: Option<Arc<alerts::Grafana>>,
@ -3622,7 +3634,6 @@ async fn main() -> Result<()> {
// what `policy::render_agent` grants today reaches them only from here.
read_policy::ensure_agent_policies().await;
let runs = review_classifier::runs::Runs::Live(status.as_ref().map(|s| s.queue_client()));
let state = AppState {
hives: Arc::new(hives),
links: Arc::new(load_links()),
@ -3631,6 +3642,8 @@ async fn main() -> Result<()> {
agent_icons: agent_icon_reader(status.as_ref()),
reported_inference: reported_inference(status.as_ref()),
agent_login: agent_login(status.as_ref()),
runs: review_classifier::runs::Runs::Live(status.as_ref().map(|s| s.queue_client())),
builds: builder::runs::Builds::Live(status.as_ref().map(|s| s.queue_client())),
status,
jobq,
webhook_secret,
@ -3642,7 +3655,6 @@ async fn main() -> Result<()> {
accounts: linked_accounts::Accounts::Live,
try_outs: review_classifier::TryOuts::default(),
reviews: Arc::default(),
runs,
alerts: alerts::from_env(),
};
@ -3734,6 +3746,8 @@ fn build_app(state: AppState) -> axum::Router {
.routes(routes!(review_classifier::get_rules))
.routes(routes!(review_classifier::open_pr::post_open_pr))
.routes(routes!(review_classifier::runs::get_runs))
.routes(routes!(builder::runs::get_runs))
.routes(routes!(builder::runs::get_run))
.routes(routes!(
review_classifier::settings::get_settings,
review_classifier::settings::put_settings
@ -3862,6 +3876,7 @@ mod tests {
try_outs: super::review_classifier::TryOuts::default(),
reviews: std::sync::Arc::default(),
runs: super::review_classifier::runs::Runs::Live(None),
builds: super::builder::runs::Builds::Live(None),
alerts: None,
};
(state, sched)