Watch
0
0
Fork
You've already forked hyperhive
0

swarm: the notification router tells a PR's author when CI on it fails or is cancelled

This commit is contained in:
damocles 2026-11-06 21:25:08 +01:00 • committed by mara
commit c8eaa93268

View file

@ -420,6 +420,13 @@ pub(super) enum DeliveryKind {
/// the instance, kept the same way.
#[strum(serialize = "pull-request")]
PullRequest,
/// Every finished CI run that failed or was cancelled, on every repo in
/// the instance, kept the same way. Its own hook: Forgejo's hook edit
/// ignores the `workflow_run_*` events, so they can only be set when a
/// hook is created, and a `pull-request` hook registered earlier could not
/// gain them.
#[strum(serialize = "workflow-run")]
WorkflowRun,
}
/// The route prefix a registered `target_url` must point at.
@ -435,13 +442,14 @@ impl DeliveryKind {
/// Every kind, for the registration sweep. An array rather than a
/// hand-written list at the call site, so adding a kind cannot leave one
/// hook unregistered.
pub(super) const ALL: [Self; 6] = [
pub(super) const ALL: [Self; 7] = [
Self::Knowledge,
Self::ConfigPr,
Self::VcsActivity,
Self::ReviewRequest,
Self::Issues,
Self::PullRequest,
Self::WorkflowRun,
];
/// The `target_url` to register with Forgejo for this kind, given the
@ -549,8 +557,8 @@ pub(super) fn verify(
/// comment for why both this and a periodic poll write the same cache), and a
/// merge queues a deploy of the merged commit on the agent's hive. A
/// `ReviewRequest` delivery naming the review classifier's account starts a
/// review run in the background. An `Issues` or `PullRequest` delivery is
/// kept in the forge events stream for the notification router
/// review run in the background. An `Issues`, `PullRequest` or `WorkflowRun`
/// delivery is kept in the forge events stream for the notification router
/// (`crate::forge_events`).
///
/// Returns 200 on an accepted delivery so Forgejo does not retry. A refused
@ -564,7 +572,8 @@ pub(super) fn verify(
params(
("kind" = String, Path, description = "which swarm-wide hook this delivery arrived on: \
`knowledge`, `config-pr`, `vcs-activity`, \
`review-request`, `issues` or `pull-request`")
`review-request`, `issues`, `pull-request` or \
`workflow-run`")
),
request_body(
content = String,
@ -637,7 +646,7 @@ pub(super) async fn post_webhook_forge(
}
}
DeliveryKind::ReviewRequest => crate::review_classifier::review::on_delivery(&state, &body),
DeliveryKind::Issues | DeliveryKind::PullRequest => {
DeliveryKind::Issues | DeliveryKind::PullRequest | DeliveryKind::WorkflowRun => {
if let Err(not_kept) = crate::forge_events::publish(&state, &headers, body).await {
tracing::warn!(kind = <&str>::from(kind), reason = ?not_kept, "webhook: forge event not kept");
return (StatusCode::SERVICE_UNAVAILABLE, "forge event not kept").into_response();