fj run watch / view have no --exit-status, so a failed run exits 0 and cannot gate CI #125
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
fj run watchandfj run viewalways exit0once a run reaches a terminalstate, whether the run succeeded or failed. There is no
--exit-status(gh's
gh run watch --exit-status/gh run view --exit-status) to make theprocess exit code reflect the run conclusion. In CI this forces a fragile
"stream, then re-parse output to decide if it passed" dance instead of letting
the shell branch on
$?.Evidence
watchdeclares the run finished and returnsOk(())no matter the status(
src/cli/workflow_run.rs:410):viewis the same: it prints the summary and returnsOk(())(
src/cli/workflow_run.rs:261-278). The process exit path returns1only onan
Err,0otherwise (src/main.rs:62-63), so a red run is indistinguishablefrom a green one to a script.
docs/gh-to-fj.md:109mapsgh run watchtofj run watchbut drops gh's--exit-status, the flag CI relies on.Why it matters for CI/automation buyers
The canonical "kick a workflow and gate the pipeline on it" pattern:
Today the
|| exit 1is dead code:fj run watchexits0on a failed run, sothe deploy proceeds. The only workaround is
fj run view N --jsonplus grepping.status/.jobs[].status, exactly the brittle scripting the--jsonworkset out to remove.
Proposed shape
--exit-statustofj run watchandfj run view: when set, exitnon-zero if the run's terminal conclusion is anything but
success/skipped. Default stays0so existing piping is unaffected.watchfollows a single--job(default0) but keys completion offwhole-run
done; the exit status should reflect the whole run'sconclusion (
view.state.run.status), not just job 0, so a failure in job 1isn't reported as success. This mirrors the existing
--log-failed"don't hide a failure behind a green job 0" reasoning at
src/cli/workflow_run.rs:160.Scope
Exit-code plumbing over data already fetched; no new endpoints. Distinct from
the HTTP-error exit-code concern in rasterstate/fj#123 (that is about failed API
calls; this is about a successful command observing a failed run). Pairs
with rasterstate/fj#129 to make "trigger + gate" work end to end.
Converted to backlog item rasterstate/fj#135 (p1, size S).
This is already implemented on
main, so this can be closed as resolved.fj run watchandfj run viewboth take--exit-status:ensure_exit_status()(src/cli/workflow_run.rs) exits non-zero unless the run's conclusion issuccessorskipped. Without the flag the exit code is unchanged, so existing piping stays at 0.watchkeys the exit code off the whole-run status (view.state.run.status), not job 0, so a failure in a later job is not masked by a green job 0 (the nuance this issue raised).docs/gh-to-fj.md(thefj run view N --exit-statusandfj run watch N --exit-statusrows).ensure_exit_status_ignores_failed_runs_without_flag,ensure_exit_status_accepts_success_and_skipped,ensure_exit_status_rejects_failed_and_cancelled_runs,run_view_exit_status_flag_parses,run_watch_exit_status_flag_parses.Landed in #141 and #151. The canonical
fj run watch "$RUN" --exit-status || exit 1gate works now.