Skip to content

feat(hub): headless job status + artifact fetch by Job ID#2

Open
proggeramlug wants to merge 1 commit into
mainfrom
feat/headless-job-fetch
Open

feat(hub): headless job status + artifact fetch by Job ID#2
proggeramlug wants to merge 1 commit into
mainfrom
feat/headless-job-fetch

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Problem

Headless/CI clients (e.g. perry publish in a non-TTY GitHub Actions shell) can't reliably retrieve their build artifact. The only path is a long-lived WebSocket that delivers the download token via a Complete message — if the WS drops or the job sits in the queue, the artifact is unreachable, and it's lost entirely if the hub restarts (the queue is in-memory).

Fix

Two Bearer-authed (the same api_token used by perry publish) endpoints to enqueue-then-poll-then-fetch by Job ID, no socket required:

  • GET /api/v1/jobs/:jobId/statusqueued|running|completed|failed (+ artifact_url, size, sha256 when ready)
  • GET /api/v1/jobs/:jobId/artifact → the final artifact as base64 text (same encoding as /api/v1/dl)

On artifact upload the hub also writes a job-id-keyed record to disk, so a completed artifact is retrievable by Job ID and survives a hub restart. Intermediate *-precompiled sign bundles are skipped (only the CLI-facing final is recorded).

Deployed + verified live: endpoints return 401 without a valid token, 404 for unknown jobs; existing routes/WS unaffected.

Follow-up (not in this PR): persist the queue itself so queued (not-yet-built) jobs survive a restart + get re-dispatched. Pairs with PerryTS/perry#4732 (CLI no longer exits 0 without a result).

Headless/CI clients that publish over a non-TTY shell couldn't reliably
get their artifact: the only path was a long-lived WebSocket that delivers
the download token via a Complete message. If the WS dropped or the job sat
in the queue, the artifact was unreachable (and lost entirely on a hub
restart, since the queue is in-memory).

Add two Bearer-authed (api_token) endpoints so a job can be enqueued, then
polled + fetched by Job ID without holding a socket open:
- GET /api/v1/jobs/:jobId/status   -> queued|running|completed|failed + artifact_url
- GET /api/v1/jobs/:jobId/artifact -> the final artifact (base64 text, like /dl)

On artifact upload the hub now also writes a job-id-keyed record to disk, so
a completed artifact is retrievable by Job ID and survives a hub restart.
(Intermediate *-precompiled sign bundles are skipped.)
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