fix(ci): stop tracing a canceled job
What does this MR do and why?
glab ci trace never returns on a canceled job. The trace loop tests for the
status cancelled, but the API reports this state as canceled:
if job.Status == "success" ||
job.Status == "failed" ||
job.Status == "cancelled" {
return nil
}The terminal check therefore never matches and the command keeps polling and re-streaming the trace until the user interrupts it.
The API client is explicit about the spelling:
// client-go/v2/types.go
Canceled BuildStateValue = "canceled"internal/commands/ci/ciutils/utils.go was the only place in the repository
using the two-L spelling. ci/delete, ci/status, ci/view, mr/merge and
runner/jobs all already use canceled.
Test coverage
A when the job was canceled case in the existing TestTraceJob table. The
mock expects exactly one GetJob call, so a loop that fails to terminate shows
up as an unexpected extra call rather than hanging the suite.
Reverting only utils.go:
--- FAIL: TestTraceJob (0.00s)
--- FAIL: TestTraceJob/when_the_job_was_canceled (0.00s)With the fix, go test ./internal/commands/ci/ciutils/ is green.
Related issues
Closes #8416 (closed)