Skip to content

wait-for-hydra: add SSE support for real-time Hydra status#41

Merged
angerman merged 1 commit into
latestfrom
wait-for-hydra/sse-support
Feb 28, 2026
Merged

wait-for-hydra: add SSE support for real-time Hydra status#41
angerman merged 1 commit into
latestfrom
wait-for-hydra/sse-support

Conversation

@angerman
Copy link
Copy Markdown
Collaborator

@angerman angerman commented Feb 28, 2026

Summary

Add SSE (Server-Sent Events) support to the wait-for-hydra action for real-time build status from hydra-github-bridge. When hydra-status-url is provided, the action connects to the bridge's SSE endpoint instead of polling the GitHub API — reducing detection latency from minutes (poll interval) to seconds (event-driven).

Without hydra-status-url, the action behaves exactly as before (GitHub API polling with exponential backoff).

New input

Input Default Description
hydra-status-url '' URL of the hydra-github-bridge (e.g. https://ci.zw3rk.com). Enables SSE mode when set.

How SSE mode works

  1. One-shot check — queries the bridge's cached status endpoint (/status/{owner}/{repo}/{sha}) to see if the build already finished
  2. SSE stream — connects to /status/{owner}/{repo}/{sha}/events and filters for events matching the requested check-run name
  3. Periodic re-check — every 120s, re-queries the one-shot endpoint as a safety net against CDN buffering (e.g. Cloudflare) swallowing events
  4. Timeout enforcementread -t 60 prevents indefinite blocking on idle streams so the global timeout is always respected
  5. Graceful fallback — if the SSE stream drops or times out without a terminal event, falls back to the existing poll loop

Other improvements in this PR

  • Debug echo in poll_github() now shows the full jq query (copy-pasteable for local debugging) and goes to stderr so it doesn't contaminate conclusion=$(poll_github) capture
  • Poll loop extracted into poll_wait() function for reuse as SSE fallback
  • classify_status() helper centralizes success/failure classification

Usage

- uses: input-output-hk/actions/wait-for-hydra@latest
  with:
    check: required
    hydra-status-url: https://ci.zw3rk.com

Test plan

  • Tested SSE one-shot path: returns immediately when build is already done
  • Tested SSE stream path: receives events through Cloudflare CDN chain
  • Tested poll fallback: works when SSE stream ends without terminal event
  • Tested in production on devx PR #241 — passed in 6 seconds
  • Verified backward compatibility: without hydra-status-url, action behaves identically to before

@angerman angerman force-pushed the wait-for-hydra/sse-support branch from c850034 to 8fb6452 Compare February 28, 2026 07:45
When `hydra-status-url` is provided, the action connects to the
hydra-github-bridge SSE endpoint for real-time build status updates
instead of polling the GitHub API. This dramatically reduces latency
from minutes (poll interval) to seconds (event-driven).

SSE mode features:
- One-shot check on cached status before opening the stream
- Event filtering by check-run name (ignores unrelated jobs)
- Process substitution to avoid subshell exit trap
- read -t 60 to enforce timeout during idle streams
- Periodic re-checks every 120s as CDN buffering safety net
- Graceful fallback to poll mode on connection failure

Without `hydra-status-url`, the action behaves exactly as before
(pure GitHub API polling with exponential backoff).

Copyright (c) Moritz Angermann <moritz.angermann@iohk.io>, Input Output Group.
SPDX-License-Identifier: Apache-2.0
@angerman angerman force-pushed the wait-for-hydra/sse-support branch from 8fb6452 to 67492d0 Compare February 28, 2026 07:48
@angerman angerman changed the title Wait for hydra/sse support wait-for-hydra: add SSE support for real-time Hydra status Feb 28, 2026
@angerman angerman added this pull request to the merge queue Feb 28, 2026
Merged via the queue into latest with commit dbb6ea6 Feb 28, 2026
@angerman angerman deleted the wait-for-hydra/sse-support branch February 28, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant