mirror of
https://github.com/devvmhq/ciwatch.git
synced 2026-12-01 06:13:17 -10:00
main
21
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
51c5299692 |
feat(cli): say which crash inputs came from an earlier attempt
After a rerun, jobs and logs come from the reported attempt, but crash artifacts are listed for the whole run. Since upload-artifact v4 an artifact name can be used only once per run, so when attempt 2 crashes the same target again, the crash artifact the run lists is attempt 1's. For a run reported at attempt 2 or later with at least one crash artifact, ciwatch now asks once when that attempt started, with the same retries as the artifact listing. A crash artifact created strictly before that start is marked: one stderr line names it, as "was uploaded by attempt 1, not attempt 2" or, from attempt 3, "by an attempt before attempt N", and --json gets "earlier_attempt": true. The input is still listed and still fetched with --fetch-crashes, and exit codes don't change. If the lookup fails, ciwatch warns once and marks nothing; after it runs out of network retries, later runs' lookups aren't retried. Ctrl-C during it exits 4 before anything is fetched. Attempts 0 and 1, and runs without crash artifacts, make no call. An artifact with no usable created_at is never marked. The comparison rests on GitHub rerunning only completed runs and on both timestamps coming from GitHub's clock. If that is wrong, an artifact created within moments of the attempt's start could be mislabelled; only the label and one stderr line are affected. gh.Artifact gains CreatedAt, Artifacts asks for created_at, and the new Runner.AttemptStarted reads run_started_at. docs/json.md, the README and AGENTS.md are updated. The tests add a fake attempts call, a recorded attempt-start fixture and a hand-written artifacts fixture. AC-1's "calls unchanged" at attempt 1 means no attempts call and the same sequence of gh calls; the artifacts --jq now asks for created_at at every attempt. Left from review: - internal/gh/gh.go: the artifacts --jq asks for created_at at attempt 1 too, so AC-1's "calls byte-for-byte unchanged" doesn't hold literally; making the query depend on the attempt wasn't worth the complexity. Backlog: - TestFuzzAttemptOneUnchanged doesn't compare stdout and stderr byte for byte with a run before the change, as AC-1 words it. Off the path: test tightness, the behaviour works. - When the attempt start doesn't parse, the warning ends with "decoding gh api output: parsing time ...", which doesn't name the attempts call. Off the path: message clarity, the line already names the run. Spec: acceptance cases AC-1: A failed run at attempt 1 with a crash artifact. Stdout, stderr, `--json` and the `gh` calls are byte-for-byte what they are today. There is no attempts call and no `earlier_attempt` field. Exit 1. AC-2: A failed run at attempt 2, where `crash-FuzzParse` has `created_at` 2026-11-13T23:58:40Z and attempt 2 started at 2026-11-14T00:15:04Z. - stderr gets exactly one line: `ciwatch: crash-FuzzParse of run 43529187615 (CI) was uploaded by attempt 1, not attempt 2` - `--json` has `"earlier_attempt": true` on that crash. - With `--fetch-crashes` it is still downloaded to the same place as today. - Exit 1, as today. AC-3: The same run, with `crash-FuzzOther` created at 2026-11-14T00:21:02Z (after attempt 2 started). No line and no field for that artifact. If a run has one artifact of each kind, only the earlier one is marked. AC-4: A run at attempt 3 with an artifact created before attempt 3 started. The line reads `… was uploaded by an attempt before attempt 3`. We can't tell whether that was attempt 1 or 2. AC-5: A run at attempt 2 where the attempts call fails (not a network error). - stderr gets exactly one line: `ciwatch: can't tell which crash inputs of run 43529187615 (CI) came from an earlier attempt: <error>` - No crash is marked, the output is otherwise as today, and the exit code doesn't change. - A network or temporary error is retried like the artifact listing, and the warning comes after the retries run out. AC-6: Ctrl-C during the attempts call, or during its backoff, prints `ciwatch: context canceled` with no table and exits 4. Nothing has been fetched yet at that point. AC-7: A run at attempt 0 (gh didn't say), or a failed run at attempt 2 with no crash artifacts. There is no attempts call and the output is as today. AC-8: A run at attempt 2 whose artifact has no `created_at`, or one that doesn't parse. That artifact is not marked and gets no line. This is the case for the existing recorded fixture, which lacks the field. Spec: non-goals - Handling two artifacts with the same name (upload-artifact v4+ makes that impossible). - Downloading by artifact ID. - Showing artifacts per attempt, or naming exactly which earlier attempt when N ≥ 3. - Changing exit codes, or skipping or refusing to fetch earlier-attempt inputs. - Marking earlier-attempt inputs in the table output (stderr carries it). - Artifacts other than `crash-Fuzz*`. Spec: inference There is one place: comparing artifact `created_at` against attempt N's `run_started_at`. It rests on two things: GitHub reruns only a completed run, and both timestamps come from GitHub's own clock. If that's wrong, an artifact created within moments of attempt N's start could be labelled the wrong way. The comparison is strict (`created_at` before start), so equal times count as the current attempt. If the guess is wrong, the only effect is a wrong label and one stderr line: fetching and exit codes don't change. Spec: approved with Approved under CJ's standing delegation, including the single-boundary inference: a wrong guess only mislabels and adds one stderr line, and fetching and exit codes don't change. Your three answers are accepted: no table mark, no mark without created_at, and no attempts call without crash artifacts. Record the attempt-start fixture read-only from the real call as planned. Built in steps: - test(cli): cover marking crash inputs from an earlier attempt - feat(cli): say which crash inputs came from an earlier attempt - docs: describe crash inputs from an earlier attempt in the README - fix(cli): polish from review Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
ee089d0c5d |
feat(cli): report a job that hit its time limit
GitHub marks a job that runs past its timeout-minutes as cancelled, and
gh run view --log-failed prints nothing for it, so ciwatch showed an
unexplained cancelled job. The only sign of the timeout is the check-run
annotation "The job has exceeded the maximum execution time of <limit>".
For each cancelled job in a completed run, ciwatch now fetches its
annotations through the usual retries. When one matches that message
exactly, the job is reported as timed out after the limit: on stderr, in
the job's block header and as timed_out_after in --json. ciwatch then
reads the full job log (gh run view --log --job) and shows the cancelled
step's last lines the way failed steps are shown.
This reads GitHub's annotation text. A job without the annotation is
reported exactly as before, so a reworded message can only miss a
timeout, never invent one. A failed annotations call warns and leaves
the job as it was. A failed log call keeps the timed-out verdict and
shows (log unavailable) and log_error. Ctrl-C in either call exits 4
with no table. Conclusions, exit codes and the rerun hint are unchanged.
The full log labels each line with its step, and the steps before the
cancelled one start in the same second, so the cancelled step's lines
are picked out by that label before steplog.Parse finds its window. If
no line carries the step's name, the whole log is parsed by the step's
times instead.
Runner gains Annotations and JobLog. docs/json.md, the README and
AGENTS.md name the new field and calls. The fixtures are the recorded
timeout and the recorded annotations of the concurrency-cancelled job.
Backlog:
- The jobResult and failedLogs comments in internal/cli/cli.go still
speak of failed jobs and the failed-step log; they now also cover
timed-out jobs and the full log. Off path: comments only, behaviour is
correct.
- A timed-out job with no cancelled step, or whose cancelled step has no
lines, says "(no failed step in the log)"; "(no cancelled step in the
log)" would be more exact. Off path: wording only, the verdict and
exit code are correct.
- The annotation fixtures are the raw API JSON, not the [{message}]
shape --jq produces, so no test checks the jq expression. Off path:
test tightness; the fixtures are unedited recordings and the decoder
ignores the extra fields.
- If only some lines of a timed-out job's log carry the step's name and
the rest are UNKNOWN STEP, stepLines drops the unlabelled ones. Off
path: the same log-layout inference the design accepts for failed
steps; the verdict and exit code don't depend on it.
Spec: acceptance cases
1. **AC-1:** Fixtures: the recorded timeout (run 45339081512, job 138258094336 "slow", its annotations and its full log). ciwatch:
- writes `ciwatch: job 138258094336 (slow) of run 45339081512 (Timeout) timed out after 1m0s` to stderr.
- In the table, the job's block starts `slow (Timeout, run 45339081512): timed out after 1m0s`. Under `Sleep past the limit:` it shows these 8 lines, in order, with colour codes removed: `##[group]Run echo "starting to sleep"`, `echo "starting to sleep"`, `sleep 150`, `echo "never printed"`, `shell: /usr/bin/bash -e {0}`, `##[endgroup]`, `starting to sleep`, `##[error]The operation was canceled.`. None of the "Print before" lines and none of the "Complete job" lines (`Cleaning up orphan processes`, …) appear.
- In `--json`, the job has `"timed_out_after":"1m0s"` and `steps` holding that one step with `omitted: 0`.
- Exit code 3.
2. **AC-2:** The concurrency cancel (`run-list-cancelled.json`, run 44707997310, cancelled job 136192284970). Its annotations have no timeout message. stdout, stderr, the newer-run line and exit code 3 are all byte-for-byte what they are today. The job gets no block and no `timed_out_after`, and the full log isn't fetched.
3. **AC-3:** The annotations call for a cancelled job fails, after the usual retries for network and temporary errors. ciwatch writes `ciwatch: can't fetch the annotations of job <id> (<name>) of run <id> (<workflow>): <err>` to stderr. That job is then reported as it is today, with no block and no `timed_out_after`, and the exit code is unchanged (3).
4. **AC-4:** The annotation says the job timed out, but the full-log call fails. The job is still reported as timed out on stderr and in the block header. The block shows `(log unavailable)`, `--json` has `log_error`, the usual `can't fetch the log` warning appears, and the exit code is unchanged.
5. **AC-5:** The exit code doesn't change. A run whose only problem is a timed-out job exits 3. In a mixed set (one failed run plus one timed-out run) the exit code is whatever `exitCode` gives today. The rerun hint still counts only failed runs.
6. **AC-6:** Ctrl-C during the annotations call or the full-log call: no partial table, exit 4, the same as during the failed-log fetch today.
7. **AC-7:** An annotation whose message only resembles the timeout message (for example `The operation was canceled.`, or the timeout text without the "of <limit>" ending) doesn't make the job timed out.
Spec: non-goals
- Guessing a timeout from durations or from `timeout-minutes` in the workflow file.
- Jobs whose conclusion is `failure`, or the existing `timed_out` handling. That stays as it is.
- Changing exit codes, the run's or job's `conclusion` value, or the table's CONCLUSION column, which stays `cancelled`, as GitHub says.
- Runs that are still in progress, including with `--once`. Logs are only served once a run has completed.
- Changing the newer-run lookup for a cancelled run whose cancellation was really a timeout.
- Suggesting a rerun for a timed-out job.
- Paging past the first 100 annotations of a job.
Spec: inference
- **GitHub's annotation text.** A job counts as timed out only when one of its annotation messages matches `^The job has exceeded the maximum execution time of (\S+)$`. The limit is the captured text, shown as given. If GitHub rewords the message, ciwatch misses the timeout and reports the job as a plain cancelled job, which is today's behaviour. It can't invent a timeout from other text.
- **Where the cancelled step's lines are in the log.** This reuses `steplog.Parse`, which finds a step's lines by the step's start and end times in the jobs JSON. It starts at the `##[group]` line and ends at the last `##[error]` line, which is what keeps "Complete job" out. If GitHub changes the log layout, the block shows the wrong lines or none (`(no failed step in the log)`). The timed-out verdict and the exit code don't depend on this. Failed steps already rely on the same inference.
Spec: approved with
Approved under CJ's standing delegation (2026-11-24), including the inference: matching GitHub's annotation text can only miss a timeout, never invent one, and the step window reuses the approved steplog.Parse. Answers: (1) record job 136192284970's real annotations read-only with gh api repos/devvmhq/devvm/check-runs/136192284970/annotations into testdata/gh/ (they hold 'Canceling since a higher priority waiting request…' and 'The operation was canceled.', no timeout message), instead of a hand-written []; (2) the *-timed-out.json fixtures stay; (3) the newer-run hint stays unchanged; (4) don't copy job-log-failed.log.
Built in steps:
- test(cli): cover reporting a job that hit its time limit
- feat(cli): report a job that hit its time limit
- docs(cli): say that timed-out jobs get steps and tests too
- test(cli): compare the unchanged cancelled job byte for byte
- fix(cli): parse a timed-out job's whole log if no line names its step
- fix(docs): polish from review
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
||
|
|
d108f34228 |
feat(steplog): start a step's log window at its group line
The jobs JSON gives whole seconds, so lines the previous step printed in the second a failed step started fell inside the step's window. They were counted in its earlier lines, and a previous ##[error] line could end the window early. In the recorded devvm log, the lint step's two "Finished in" lines were counted for the test step. Parse now treats the first ##[group] line stamped in a step's start second as the start of the step's own lines. Lines taken before it in that second, and untimestamped lines that follow them, are dropped, and a dropped ##[error] line no longer ends the window. If no ##[group] line falls in the start second, including a log that ends in it, the window is exactly what it was. Nothing outside the start second changes. For the recorded devvm log the tail is unchanged and its omitted count goes from 263 to 261. The change relies on GitHub writing a log in order and starting each step with a ##[group] line. A step that prints a ##[group] line in its first second without a header of its own loses its lines before that group; that is under a second of output. Memory stays bounded: the lines go straight into the span's tail, which keeps at most 2*Tail lines. Tests cover the shared-second cut, an untimestamped follower, a previous ##[error] line with and without the step's own, two group lines in the start second, and the cases that must not change. A new fixture, written by hand from real lines of the recorded devvm log, drives a CLI test. Backlog: - TestRunStepLeavesOutPreviousStepsSameSecond (internal/cli): the "omitted":0 check in --json also passes with the old code, since the fixture's window is short. Asserting on the first line or the line count would tighten it. Off path: the test as a whole already fails on the old code. - The design's AC-1 case 5 (a step with only pre-group lines is left out) can't be reached, because the group line is in the window and is kept. No test row covers it. Rewording the case or pinning the intended behaviour would remove the ambiguity. Off path: spec wording; no reachable input gives wrong output. Spec: acceptance cases 1. **AC-1:** The step's span starts at 10:00:05. The log has `prev a` (10:00:05.1), `prev b` (10:00:05.2), `##[group]Run go test` (10:00:05.3), `go test` (10:00:05.4) and `##[error]x` (10:00:06). The step's lines are `##[group]Run go test`, `go test`, `##[error]x`, with `Omitted` 0. 2. **AC-1:** A line without a timestamp after `prev b` (it belongs to `prev b`) is left out with it. 3. **AC-1:** If the previous step's lines in the shared second include `##[error]prev`, the failed step's window doesn't end at that line. Its tail ends at its own `##[error]` line, as in AC-1 case 1. If the step has no `##[error]` of its own, its tail ends at its last line in the window. 4. **AC-1:** If the start second has more than one `##[group]` line (the step's header, then a group the step itself prints), the cut is at the first one. The step's own group and the lines after it are kept. 5. **AC-1:** If the step's only lines are in its start second and come before its `##[group]` line, then nothing is left. The step is left out, as a step with no lines is today. 6. **AC-2:** For the recorded `devvm-44705166834.log` and the span `Run mise run test` from 08:47:47 to 08:52:20, the tail is unchanged, but `Omitted` drops by the 2 lint lines. Its 40 lines go from 263 omitted to 261: the 301 lines from line 400 to line 700, less 40. With a short log written by hand from the same real lines, `ciwatch HEAD` exits 1, and the step's block starts `##[group]Run mise run test`, with no `[lint:code]` or `Finished in` line. 7. **AC-3:** If no `##[group]` line falls in the step's start second, the window is exactly what it is today. That covers start-second lines with no group line, a group line stamped before `startedAt`, and every existing `TestParse` case. `devvm-short-step.log` also keeps its current output. 8. **AC-3:** If the start second's lines are the last lines of the log (EOF before the second ends), they're kept as today, unless a `##[group]` line came first. Spec: non-goals - Using step names from the log (`##[group]Run <name>`), or matching the `Run ` prefix. - The other end of the window: lines of the next step within a second of the failed step's completion. These are still kept when the step has no `##[error]` line. - Showing passed steps; changing `Whole`, `--json` fields or exit codes. - Logs where gh labels lines with real step names (the attempt logs). They're treated by time as today. Spec: inference - **That the step's lines start at its own `##[group]` line, and that GitHub writes the log in order.** In the start second, a line before the first `##[group]` line is taken to be the previous step's. GitHub starts every `run:` and `uses:` step with `##[group]Run …`, and the log comes in the order it was written. - **When the guess is wrong:** Take a step that doesn't start with a group header (say a post step) but prints a `##[group]` in its first second. Its own lines from before that group are dropped. That's under a second of output, and only when a group line appears in that same second. If the previous step prints a `##[group]` in the shared second, the cut lands at that group line. Some of the previous step's lines are then still shown, which is today's behaviour, never worse. With no group line in the start second, nothing changes. Spec: approved with Approved by CJ as designed, including the inference (the first ##[group] line in the step's start second marks where its lines begin) and your two assumed answers: cut at any ##[group], and AC-2 shown by the Omitted count plus the short fixture from real lines. Built in steps: - test(steplog): cut a step's window at its group line - feat(steplog): start a step's window at its group line - fix(steplog): polish from review Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
c2cee2baa4 |
feat(cli): fetch jobs and logs for the reported attempt
ciwatch now asks for the jobs and the failed-step logs of every run by
the attempt on the run's row, so the row, its jobs, its steps and its
logs come from one attempt. Before, only a run that stopped being listed
after a rerun had its jobs fetched by attempt. When a rerun call failed
but GitHub reran the jobs anyway, the table mixed attempt 1's run with
attempt 2's jobs, and gh refused the log while attempt 2 was running.
FailedLog takes the attempt and passes --attempt before --log-failed
when it is 1 or more. App.Run always calls RunJobsAttempt, which leaves
out --attempt for a run whose attempt gh didn't report, so those calls
are as they were. watchAttempts no longer returns the runs that went
missing, since nothing else needs them. The usage text says the jobs and
logs shown are those of the attempt reported. Retries and Ctrl-C work as
before, and every retry carries the same --attempt.
Tests cover each case: the gh call for attempts 0, 1 and 2, a failed
rerun call with attempt 2 in progress, a run that vanishes after a
rerun, a single-attempt run, and the retries. The fixtures are the logs
gh printed for two attempts of one run, recorded read-only, and a
hand-written in-progress jobs file derived from a recorded run.
Backlog:
- Crash artifacts are still listed and downloaded for the whole run, so
after a rerun they can include inputs from an earlier attempt. GitHub
can't select artifacts by attempt, so this needs a timing inference
and is off the path of this change.
- TestSingleAttemptCallsUnchanged compares only the table output of
attempt 1 with attempt 0; it could compare the --json output too. The
encoder doesn't read the attempt differently, so this only tightens
the test.
- When another run's rerun succeeds, watchAttempts lists the runs again,
so a run whose rerun call failed but was reran anyway shows up at its
new attempt. Its jobs and logs still match. Re-listing after a failed
rerun call is a non-goal, and a separate task covers saying so.
Spec: acceptance cases
1. **AC-1:** A run reported at attempt N ≥ 1 has its jobs fetched with `gh run view <id> --attempt N --json jobs`. This holds for every run, not only runs that stopped being listed. The job rows come from attempt N even when GitHub's latest attempt is N+1.
2. **AC-2:** `--rerun-failed`, the rerun call for run R fails (for example a network error), and GitHub holds attempt 2 of R, still in progress. ciwatch reports R at attempt 1, `completed`/`failure`, with attempt 1's jobs. Each failed job's log is fetched with `gh run view R --attempt 1 --log-failed --job <job>`, and its failed-step lines are shown. There is no "can't fetch the log" warning. The exit code is 1.
3. **AC-3:** A run whose attempt gh didn't report (`attempt` 0) has its jobs and logs fetched exactly as today, with no `--attempt`. The table, the `--json` output (the golden files stay as they are) and the exit codes don't change.
4. **AC-4:** Without `--rerun-failed`, a run at attempt 1 gets `--attempt 1` on its jobs and log calls. Apart from that argument, the calls are the same and so are the output and the exit code.
5. **AC-5:** A run that stops being listed after a rerun is still reported at its last known attempt, with its jobs and logs fetched by that attempt. This is today's behaviour for jobs; logs are new.
6. **AC-6:** Network retries and Ctrl-C work as they do now for the jobs and log calls. The `--attempt` argument is the same on every retry.
Spec: non-goals
- Showing or comparing more than one attempt of a run.
- Telling the user that a failed rerun call reran anyway. That's the blocked task "Say when a failed rerun call reran anyway".
- Tying crash artifacts to an attempt. `GET /actions/runs/{id}/artifacts` and `gh run download` have no attempt filter. Artifacts are still listed and downloaded for the whole run, as today (see Follow-up tasks).
- Re-listing runs after a failed rerun call to pick up the new attempt.
Spec: inference
none. ciwatch passes the attempt from gh's own `attempt` field to gh's `--attempt` flag. Nothing is guessed from timing or from text.
Spec: approved with
Approved under CJ's standing delegation. Answers: (1) yes, narrow AC-2 to jobs and logs; GitHub can't select artifacts by attempt, and the artifact follow-up needs a timing inference, so it goes to CJ separately, not into this task; (2) confirmed read-only: devvmhq/devvm run 43529187615 has two attempts, and gh run view --attempt 1/2 --log-failed --job returns different failed jobs (132242348233 and 132254736456) and different logs, so gh honours --attempt with --log-failed; record its jobs and logs read-only as the two-attempt fixture; (3) yes, attempt-1 runs get --attempt 1 too.
Built in steps:
- test(cli): jobs and logs come from the reported attempt
- feat(cli): fetch jobs and logs for the reported attempt
- test(gh): ask for the logs by the run they were recorded from
- fix(gh): polish from review
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
||
|
|
9f43de9344 |
feat(cli): name the run that replaced a cancelled run
For a cancelled run, ciwatch named the newest run of its workflow on the branch, which is whatever ran last today, not the run that came straight after. It now makes one lookup limited to runs created at or after the cancelled run, using the new gh.Runner.RunsSince in place of LatestRun. It passes --branch, --workflow by ID, --created with the cancelled run's createdAt in RFC 3339 UTC, and --limit 100. From the result, firstAfter names the earliest run that is for another commit and was created strictly after the cancelled run, the lowest ID on a tie. The order gh prints the runs in doesn't matter. When no run qualifies, including a rerun of the same commit or a run of another commit created in the same second, the run stays plainly cancelled. If the lookup returns 100 runs, the oldest may have been cut off, so the run stays plainly cancelled and stderr says that ciwatch can't name the run after it. The row note, the hint line, newer_run, the retries, the Ctrl-C handling and the exit codes are unchanged. The README and docs/json.md say "first run after it" instead of "newer run", and the README notes that gh run list --created needs a recent gh, tested with 2.103.3. The tests use a lookup recorded read-only from devvmhq/devvm, where the run after 43361281082 is 43361860563 for 90694a4, not the newest run. Backlog: - testdata/gh/run-list-latest-newer.json is no longer used by any test. Deleting it is housekeeping, not behaviour, and AGENTS.md says to ask before deleting anything not created by the task. - The "cancelled run itself" case in TestCancelledWithoutNewerRun still uses run-list-latest-self.json, which was recorded from the old --limit 1 call. Recording a --created lookup would make it faithful, but it is test tightness: the behaviour already works and is checked. Spec: acceptance cases - AC-1: For each completed cancelled run on a branch, ciwatch runs exactly one `gh run list --branch <branch> --workflow <workflow id> --created >=<createdAt as RFC 3339 UTC> --limit 100 --json <run fields>`. It names the run in the result whose commit differs from the cancelled run's and whose `createdAt` is strictly later, with the earliest `createdAt`, lowest ID on a tie. The order gh prints the runs in doesn't matter. - AC-2: For devvm's cancelled run 43361281082 (commit 8da71a0, created 2026-11-13T03:47:33Z), fed the recorded lookup output, the named run is the first one created after it. That is presumably 43361860563 for 90694a4; I'll confirm it when the output is recorded. It is not the newest run in the list. The table shows `CI completed cancelled (newer run 43361860563 for 90694a4)`, the last stderr line is `ciwatch: run 43361281082 (CI) was cancelled; to watch the newer run: ciwatch 90694a4…`, and the exit code is 3. - AC-3: When no run qualifies, the run is reported as plainly cancelled, with no note, no hint, no `newer_run`, and exit code 3. That covers four results: an empty result, only the cancelled run itself, only runs of the same commit (for example a rerun of it), and only runs of another commit created in the same second. - AC-4: If the lookup returns 100 runs, the oldest may have been cut off. The run stays plainly cancelled and stderr gets `ciwatch: can't name the run after run 43361281082 (CI): 100 or more runs since it`. The exit code is still 3. - AC-5: Task C's behaviour holds with the new call. A failed lookup warns and keeps the run plainly cancelled after the retries. Ctrl-C during a lookup reports the interrupt once and exits 4. Two cancelled runs get two lookups and two hints in table order. A failure alongside a cancellation still exits 1. Spec: non-goals - Proving why the run was cancelled, whether by concurrency, by hand, or by a timeout. - Following chains: the named run is not looked up in turn, even if it was cancelled too. - More than one lookup per cancelled run, including paging past 100 runs. - Runs of other branches or other workflows, and runs created before the cancelled one. - Changing the note, hint or JSON wording, or the docs' field descriptions beyond "newest" → "first after". Spec: inference - **The first run after is the one that replaced it.** ciwatch infers this from the order of `createdAt` timestamps. If the run was cancelled by hand and another commit's run came later for an unrelated reason, ciwatch still names that run. That's no worse than task C, which named the newest run, and the hint only names a run to watch; it doesn't claim a cause. - **Timestamps are whole seconds.** A run of another commit created in the same second can't be ordered against the cancelled run, so it isn't named (AC-3). If it really was the replacement, the run is shown plainly cancelled, which is the safe failure. - **gh lists newest first.** The selection doesn't depend on that (AC-1). Only the 100-run guard in AC-4 does: it assumes a full page may be missing the oldest runs. Being wrong only costs a warning. Spec: approved with Approved by CJ, including its inference (first run of another commit created strictly after the cancel, by createdAt) and its assumed answers: strictly later, --limit 100 with the AC-4 guard, and a README note on the gh version (checked: gh 2.103.3 has --created). Record the AC-2 fixture read-only from devvmhq/devvm and confirm the named run from it. Built in steps: - test(cli): name the first run after a cancelled run - feat(cli): name the run that replaced a cancelled run - docs(cli): say a full page also leaves a run plainly cancelled - test(cli): cover the lowest-ID tie-break for the named run - fix(cli): polish from review |
||
|
|
ec5df75774 |
feat(cli): rerun failed jobs with --rerun-failed
When a run ends in failure or timed_out, ciwatch now ends its stderr with a hint naming --rerun-failed, after the crash and newer-run hints. With the flag, it makes one gh run rerun <id> --failed call for each such run, then goes back to watching the commit until every run has completed and every accepted rerun has a higher attempt than the one it was rerun from. The table, the --json document and the exit code are of the new attempts only. The attempt number comes from gh run list, which now asks for the attempt field. The progress lines add (attempt N) from the second attempt on, and --json gives attempt on each run; it is 0 when gh doesn't report it, which docs/json.md says. The rerun call is never retried, since a rerun isn't safe to repeat. A call that fails is a warning on stderr, ciwatch doesn't wait for that run's new attempt, and its original attempt is reported. Each run is rerun at most once per invocation, so a second failure, or a run first seen failing after the reruns, is reported and not rerun. Runs that passed or were cancelled are never rerun. --rerun-failed with --once is a usage error, caught before any gh call, because --once doesn't wait for new attempts. Runner.RerunFailed joins the calls without --json in AGENTS.md. The README documents the flag and the gh version it was tested with. Backlog: - watchAttempts waits forever if a rerun run drops out of the gh run list output; warn, or treat a missing run as done. - If gh run rerun fails with a network error after GitHub accepted the rerun, its new attempt is waited for but no line says a rerun happened. - After a failed rerun call, jobs, logs and artifacts are fetched without --attempt, so they can mix attempts with the run row. - The rerun hint is printed with --once while runs are in progress, next to the 'drop --once' line; check that it reads well. Built in steps: - test(cli): rerun failed jobs with --rerun-failed - feat(cli): rerun failed jobs with --rerun-failed - docs: fix the README's claim about the last stderr line - fix(docs): polish from review Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
78e454b2ed |
feat(cli): find fuzz crash inputs from run artifacts
For each failed run (failure or timed_out), ciwatch now lists the run's artifacts once and takes those named crash-<Target> as fuzz crash inputs, instead of guessing from test names in logs. They are listed under the table, given as fuzz_crashes on the run in --json, and the last stderr line names --fetch-crashes. Runs with no such artifacts show nothing about fuzzing and make no download. With --fetch-crashes, each input is downloaded with gh run download into testdata/fuzz/<Target>/ beside the one _test.go file in the checkout that declares the target. The new fuzztarget package finds that file, skipping testdata, vendor and dot or underscore directories. If no file or more than one declares the target, ciwatch warns, names the files it found, and skips that download. Output says where each input went, and --json adds fetched_to or fetch_error. A failed listing or download is a warning and a JSON field (artifacts_error, fetch_error), never a change to the exit code. Both calls retry network errors with the shared backoff. A run with more than 100 artifacts is checked only for the first 100, and says so. The gh runner gains Artifacts, DownloadArtifact and Toplevel; docs/json.md, the README, the usage text and AGENTS.md are updated, and a golden file records the new JSON. Left from review: none; the one minor finding (Toplevel marking a git error as a network error, internal/gh/gh.go) was fixed. Backlog: - fuzztarget.Declaring stops the walk on any unreadable entry; it could skip them instead. - fetchCrashes walks the checkout once per crash input; one walk could collect all the targets. - Declaring doesn't skip node_modules or other large directories that Go doesn't ignore. - Ctrl-C during --fetch-crashes exits 4 with no table, so inputs already written to disk go unreported. - When --fetch-crashes skips or fails a download, there is no closing hint line saying what to do next. Built in steps: - test(cli): fuzz crash inputs from run artifacts - feat(cli): fetch fuzz crash inputs from run artifacts - fix(cli): test the missing-checkout path, rewrap usage - fix(gh): polish from review Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
c282df82ff |
feat(cli): name the newer run for a cancelled run
A cancelled run is now reported once. For each completed cancelled run on a branch, ciwatch makes one `gh run list --branch <branch> --workflow <id> --limit 1` call for the newest run of the same workflow on that branch. If that run is for another commit and was created after the cancelled run, the table row ends in `(newer run <id> for <short sha>)`, `--json` adds `newer_run` with `id` and `sha` to the run, and stderr ends with one hint line per such run, in table order, giving the command to watch it: `ciwatch <sha>`. Otherwise the run is reported as plainly cancelled. A run created in the same second as the cancelled one is not named. Exit codes are unchanged: 3 for a cancelled run, and 1 if another run failed. ciwatch no longer claims the newer run caused the cancellation and does not follow chains. The `--follow` flag, `followed_from`, `superseded_by` and the chain, time-window and event logic are removed with their tests and fixtures, so `--follow` is now a usage error (exit 2). A lookup that runs out of retries warns on stderr and leaves the run plainly cancelled, and Ctrl-C during a lookup prints no table and is reported once. The usage text, README, docs/json.md and AGENTS.md describe the new behaviour, and the report-doc test now looks inside nested objects so `newer_run.id` and `newer_run.sha` are held to the schema doc. Backlog: - A cancelled run with an empty headBranch, such as one from a tag or a detached ref, gets no lookup, and no test covers that skip. - When a cancelled run was re-run and the re-run is still in progress, nothing is named; a hint saying the commit is being re-run might help. Built in steps: - test(cli): hold cancelled runs to the newest-run lookup - feat(cli): name the newer run for a cancelled run - fix(cli): polish from review Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
66aca3d68e |
feat(cli): show the end of each failed step's log
For a failed job, ciwatch now shows the last 40 lines of each failed step, whatever language or tool the step ran, instead of only the failing Go tests. It fetches the job's log once with gh run view --log-failed, which labels every line UNKNOWN STEP, so the new internal/steplog package finds each step's lines by the step's startedAt and completedAt from the jobs JSON. It strips gh's prefix, the timestamp, a byte order mark, a trailing carriage return and both forms of colour code, and ends a step at its last ##[error] line. A failed job with no failed step in the jobs JSON shows the end of the whole log as (job log); a failed step with no line in its window shows (no failed step in the log). The table puts "… N earlier lines" above a step's lines when some were left out, and --json gives each step as name, lines and omitted, with omitted 0 when nothing was left out. A log that can't be fetched keeps its warning and the runs' exit code, shows (log unavailable) and sets log_error, which replaces tests_error. The Go test parser now runs only with the new --go-tests flag, and its failing tests follow the steps in the table and in --json. The jobs fetch also decodes each step's name, conclusion and times through RunJobsWithSteps. The golden file, docs/json.md, the README and AGENTS.md change with the output. Backlog: - Start each step's window after the previous step's completion, so the previous step's last lines from the same second aren't counted (internal/steplog). - Treat a cancelled step in a timed_out job as the failed step, so it is named instead of falling back to (job log). Built in steps: - test(cli): hold failed-step log tails to the approved cases - feat(cli): show the end of each failed step's log - test(cli): drop a redundant check from the few-lines test - fix(gh): polish from review Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
60cc0091e2 |
feat(cli): make --json a versioned, documented contract
The --json output now carries a top-level "schema" field, currently 1, beside "sha" and "runs". The encoder's types move out of cli.go into an exported Report, Run, Job and Test in report.go, and both the JSON and the table are written from that one structure, so every run and job in the JSON has its row in the table. The output is otherwise unchanged: no field changes its meaning, and the table prints exactly what it did before. docs/json.md describes every field of schema 1 with its type and when it is present, and lists the exit codes 0 to 4. It says schema 1 freezes at the first release. Tests hold the contract: one fails if the encoder writes a field the document does not list, or the document lists a field the encoder lacks or gives it another type; one checks that the exit codes in the document match the constants; a golden file in testdata/golden holds the output for the recorded run-list-failure fixture byte for byte, so changing the output means updating it in the same commit. AGENTS.md and the README point at the new files. Backlog: - Extend walkFields in report_test.go for bool, struct and map fields (such as a future newer_run object) before the later v1 tasks add them. - Make TestExitCodesDocumented check the exit codes' meanings, not only their numbers. - Make TestTableFromReport's shape-check message give each run's job count, not only the number of runs. Built in steps: - test(cli): hold --json to a versioned, documented contract - feat(cli): version the --json output and draw the table from it Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
dadc040524 |
test(cli): check which jobs' logs a timed-out run fetches
TestRunTimedOutJobGetsFailingTests used a fake gh that answered the log call with the jobs JSON, so it never checked that the log was fetched for the timed-out job only, nor that the job's failing tests reached the output. It now uses fakeWith with the gotestsum-failures.log fixture from testdata/logs and two new gh fixtures, a timed-out run and its jobs (the timed-out job and a skipped one). It checks the exact job ids whose logs were fetched, which are the timed-out job's only, and that the job's failing test appears in the output. The test was first shown failing against an expectation that also listed the skipped job, then corrected. No code outside the tests changed. Left from review: - internal/cli/cli_test.go: the rewrite no longer checks the --json output, where the old test checked that the timed-out job had a tests key and the skipped job had none. - testdata/gh/run-view-44707997310-timed-out.json: this and run-list-timed-out.json are hand-edited copies of recorded run 44707997310, not captured from a real timed-out run, and their names don't say so. Built in steps: - test(cli): check which jobs' logs a timed-out run fetches - fix(cli): expect only the timed-out job's log in the timed-out test Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
0b3daf954a |
feat(cli): show the failing tests of failed jobs
For each failed or timed-out job in a completed run, ciwatch now runs gh run view --log-failed --job, parses the log with testlog, and shows only the failing tests with their lines instead of leaving you to read the whole log. Runs still in progress are skipped, since gh serves no logs for them. The table gets one block per failed job after the tabwriter flushes, so the free-form lines don't break the columns. A job that fails with no tests found says so, and a package crash is labelled with the test that was running. The table shows at most App.MaxTestLines lines of each test, 20 by default, then a line saying how many more there are. In --json a failed job gets a tests array, which is empty when nothing was found, or tests_error when the fetch failed; --json keeps every line. The fetch is retried like the jobs fetch, and after a network give-up the remaining jobs get one try each. A failed fetch warns on stderr and never changes the exit code. Ctrl-C while fetching exits 4 with no table. Runner.FailedLog is the one gh call without --json, because the log has no JSON form; AGENTS.md notes the exception. Left from review: - internal/cli/cli_test.go: TestRunTimedOutJobGetsFailingTests uses a fake gh that answers the log call with the jobs JSON, so it doesn't check that the log was fetched for the timed-out job only. It should use fakeWith with a log fixture and check the job ids fetched. Built in steps: - test(cli): failing tests of failed jobs in table and --json - feat(cli): show the failing tests of failed jobs Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
3c2ea0e621 |
fix(testlog): match build errors to their package, name crashed test
Build errors from several packages were held as one block of stray lines and given to the first package's FAIL line, so a package could get another package's errors, and the errors were dropped when an ok line came between. The parser now reads each "# pkg" header and the compiler output after it as a block of its own, which no marker discards. A block continues only on compiler output (error lines, indented notes, vet lines, "too many errors"), so a crash from the next package stays with that package. A "[build failed]" or "[setup failed]" line claims the block whose header names its package or its external test package. For a "command-line-arguments" header, the directory of a file in the error lines is matched against the package path. The claimed block becomes that package's (package) failure. Blocks nobody claims are kept in a separate (build) failure instead of being dropped. A crash during a verbose run also lost the name of the test that was running. The (package) failure now has a RunningTest field holding it, empty when unknown. The crash-detection rules are unchanged. The fixtures are real go test output generated locally from throwaway packages with compile errors and a panicking goroutine, in a temp folder outside the repository, because devvm's CI has no build failure. Paths were rewritten to /tmp/ciw and /go. Each finding has a failing test written first, plus table cases for the edge cases. Left from review: - internal/testlog/testlog.go: a package that fails only because a dependency did not compile gets no (package) entry of its own, as the errors sit under the dependency's header. - internal/testlog/testlog.go: dedupe can drop RunningTest when a go test entry repeats a gotestsum one or two entries are merged. - internal/testlog/testlog.go: a lone "# word" line from a CI script opens a build block and can produce a false (build) failure. - internal/testlog/testlog.go: the (build) failure is added after the whole log is read, not in log order. - One commit on the branch is missing the Co-Authored-By trailer. Built in steps: - test(testlog): reproduce mixed build errors and unnamed crash test - fix(testlog): split build errors by package, name the crashed test - fix(testlog): address review findings Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
b1e44b9e0a |
fix(testlog): keep crashes, every summary and plain failures
The go test log parser lost or misplaced output in four cases, and each is fixed. Indented result lines such as "--- FAIL: TestA/sub" or "--- PASS:" inside a gotestsum "=== FAIL:" block now stay in that block, so a panic after them is kept with the test instead of being cut off. A crash with no "--- FAIL:" line of its own (a goroutine panic, os.Exit, log.Fatal, or a verbose test that never finished, ending in "FAIL<TAB>pkg") is reported as a failure named "(package)" with its lines, rather than attached to the previous failure or lost. A panic without "[recovered" after a failing test, or an unindented non-panic line after it, closes that test, while a failing Example keeps its unindented got/want lines and TestMain output after the run's own "FAIL" is not taken for a crash. Every gotestsum DONE line is now kept in Result.Runs in log order, and Result.Summary is their total, so a job that runs gotestsum twice, as devvm's scripts/test.sh does, counts both runs. A fixture recorded from a devvmhq/devvm CI test job with both runs covers it. Plain go test "--- FAIL:" entries are no longer all dropped when gotestsum reported a failure. Only one that repeats a gotestsum entry is dropped, matched by name and by package, allowing for gotestsum's module-relative path. Plain entries from a separate go test step are kept, as is one whose package can't be told apart. Left from review: - internal/testlog/testlog.go: build errors from several packages are held as one block of stray lines and given to the first package's "FAIL<TAB>pkg" line, so a package can get another's errors, or the errors are dropped if an "ok" line comes between. No recorded log shows a build failure. - internal/testlog/testlog.go: the "(package)" entry doesn't name the test that was running when a verbose run died; takeOut moves its output without keeping the name. Built in steps: - test(testlog): reproduce four log parser gaps - fix(testlog): keep crashes, sub results and every summary - fix(testlog): address review findings - fix(testlog): address review findings - fix(testlog): address review findings - fix(testlog): address review findings Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
f8767bf998 |
feat(testlog): parse failing tests out of a go test log
Add internal/testlog, a parser for the log of a CI job that ran go test or gotestsum. Parse returns each failing test's package, name and the lines that follow it, plus gotestsum's DONE summary with its test, skipped, failure and error counts. It is not wired into the command yet. The parser takes off the gh job and step prefix, the Actions timestamp and ANSI colour codes, including gh's "^[" form. It reads both gotestsum's "=== FAIL:" blocks and go test's "--- FAIL:" lines, and with -v it attaches the output under a test's "=== RUN" or "=== NAME" line to that test. It drops SKIP and PASS blocks so their lines never reach a failure. Lines that look like markers but belong to a message, such as a diff's "--- Expected", and blank lines inside a message are kept. Panics are kept whole, including their blank lines. A "test timed out" panic becomes one failure for each test it lists as running. Package-level failures are named "(package)". When gotestsum and go test report the same failure, one entry is kept, with the most lines. Lines are read without a length limit, and read errors are returned with context. Tests use recorded logs from devvm's CI (Linux and macOS failures and a passing run) and small logs for go test output, in testdata/logs. AGENTS.md lists the new package and the logs. Left from review: - internal/testlog/testlog.go: an indented "--- FAIL:" line inside a gotestsum block starts a go test entry, so the lines after it, such as a panic, are lost from that test. - internal/testlog/testlog.go: in plain go test output, a crash with no "--- FAIL:" line (a background goroutine panic, os.Exit, log.Fatal) is added to the previous failure or lost. - internal/testlog/testlog.go: only the last DONE line becomes the Summary, so a job that runs gotestsum twice (unit tests, then e2e) reports only the second run. - internal/testlog/testlog.go: when a log has any gotestsum failure, all go test "--- FAIL:" entries are dropped, including those from a separate plain go test step. Built in steps: - test(testlog): add failing tests for the go test log parser - feat(testlog): parse failing tests out of a go test log - fix(testlog): report read errors with context and check counts - fix(testlog): address review findings - fix(testlog): address review findings - fix(testlog): address review findings Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
0982ecd16a |
fix(cli): say what --follow drops and why it didn't follow
With --once --follow, ciwatch moved on from a commit as soon as a cancelled run had a newer push behind it, and the commit's runs still in progress were dropped without a word. And when a cancelled run's newer commit had already been watched, nothing said why ciwatch did not follow it, so the run showed as superseded with no explanation. With --once, each run still in progress is now named on stderr before ciwatch moves on, and the line that says it is following is printed by the caller after that. A newer commit that was already watched gets its own stderr line. The README now says exactly what --once --follow does: it follows at once, and the dropped runs are not in the table. The comment on supersededBy said the event filter excludes a fork's pull request, which holds only when the cancelled run is a push; it now says so, and the long line is wrapped. The fixtures run-list-failure.json, run-list-success.json and run-list-in-progress.json had been edited by hand to add fields and lacked headBranch and headSha. They are re-recorded with the current --json field list from the same devvmhq/devvm runs, using read-only gh calls. Only the in-progress statuses are derived: run 45017063720 has since completed, so its record is set back to in_progress with no conclusion. The decoding test now expects the recorded values, including the schedule event of the Fuzz run. Left from review: - internal/cli/follow_test.go: the already-watched test only checks that "already watched" appears on stderr, not the run, the commit or that ciwatch did not follow back, and no test shows a plain chain stays silent. - internal/cli/follow_test.go: the in-progress test matches any line with "in progress" and "Docs", not the run ID or commit, and does not check that the dropped run is missing from stdout. - internal/cli/cli.go: the dropped-run line gives no hint to drop --once to wait for the run, as the other in-progress line does. Built in steps: - test(cli): cover --follow dropping runs and silent skips - fix(cli): say what --follow drops and why it didn't follow Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
23b1428833 |
feat(cli): follow a run that a newer push cancelled
When a run is cancelled because a newer commit on the same branch started its own runs, ciwatch now says so and names that commit. The table row ends in "(superseded by <sha>)", --json adds superseded_by to the run, and without --follow the last stderr line is a hint to rerun with --follow. With --follow ciwatch watches the newer commit instead, keeps following if that one is cancelled by a still newer push, stops after 20 commits with a warning, and never goes back to a commit it has already watched. The JSON sha is the last commit watched and followed_from lists the ones left behind. Nothing prompts. The newer push is the first run of the same workflow, with the same event, on the same branch, for another commit, created after the cancelled run and no later than a minute after it stopped. gh is asked for that window by workflow ID, since a name can be shared or be a file path. A run cancelled by hand with a push only long after stays plainly cancelled, as does a run replaced by a later run of the same commit, and a full page of 20 runs in the window counts as uncertain because the first push may be cut off. A lookup that runs out of retries warns and leaves the run cancelled, as the jobs fetch does, and Ctrl-C during the lookup stops without a table. gh run list now asks for the workflow ID, update time, head branch, head commit and event, and a new BranchRuns call lists a branch's runs in a window. The recorded fixtures gained those fields, and new ones record superseded, chained, by-hand and newer-commit histories. Left from review: - README.md: says ciwatch moves on only after every run of the current commit has completed, but with --once --follow it follows as soon as a cancelled run is found, dropping runs still in progress. - internal/cli/cli.go: with --follow, a run cancelled by a commit already watched shows "superseded" but nothing on stderr says why ciwatch did not follow it. - testdata/gh/run-list-failure.json, run-list-success.json and run-list-in-progress.json: edited by hand to add fields, so they lack headBranch and headSha and are no longer purely recorded output. - internal/cli/cli.go: the supersededBy comment says the event filter excludes a fork's pull request, which only holds when the cancelled run is a push; one line of it is also too long. Built in steps: - test(cli): cover following a run a newer push cancelled - feat(cli): name and follow a run that a newer push cancelled - fix(cli): print the usage on real lines and tidy the list helper - fix(cli): address review findings on following a cancelled run - fix(cli): address review findings on newer-push lookup - fix(cli): address review findings on newer-push lookup - fix(cli): address review findings on following a newer push Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
8c11dca7bc |
feat(cli): retry gh through network errors with backoff
A gh call that fails with a network error, such as a dial failure or a missing host, or with a temporary HTTP 502, 503 or 504 from GitHub, used to end the watch with exit 4 at once, throwing away a watch that might have run for minutes. Both gh run list and gh run view are now retried with capped exponential backoff, in the watch and with --once. The wait starts at 1s, doubles and stops growing at 30s, for up to 8 retries per call, and each retry writes a line to stderr naming the call, the kind of error and the cause. Only when the retries run out does ciwatch give up and exit 4. Other errors, such as HTTP 401 and 404, and a cancelled context still fail at once, and Ctrl-C during a backoff wait stops immediately. The gh package marks these failures with ErrNetwork and ErrTemporary, matched on the error text in RunList and RunJobs so it also works when tests replace Exec. The marked error keeps gh's own text. The cli package wraps both calls in a generic retry helper driven by new Backoff, MaxBackoff and Retries fields on App, set to 1s, 30s and 8 by New. The clock is the injected one, so no test sleeps. The README describes the retries. When gh run view runs out of retries, the run list was already read, so the exit code still comes from the runs, with a warning and (jobs unavailable) in the table. Once one run's jobs have given up, the remaining runs get a single try each instead of a full backoff apiece. Existing tests that used HTTP 502 as an error that is not retried now use HTTP 401. The recorded stderr fixtures are in testdata/gh. Left from review: - internal/gh/gh.go: markNetwork searches the whole error text, including the request URL, so a non-network error whose URL contains a marker, such as a repository named no-such-host, would be retried. - internal/gh/gh.go: the marker "error connecting to api.github.com" matches only github.com, so a network error against a GitHub Enterprise host is not retried. - internal/cli/cli.go: after one run's jobs give up, Retries stays 0 for the remaining runs even if a later call succeeds and the network is back. - internal/cli/cli.go: running out of retries while listing jobs keeps the runs' exit code instead of exiting 4, and the README doesn't say so; the choice is worth confirming with the task owner. - internal/cli/cli_test.go: no test cancels during a gh run view backoff wait, only during a gh run list one. Built in steps: - test(gh,cli): failing tests for retrying gh through network errors - feat(cli): retry gh through network errors with backoff - test(cli): cover gh run view running out of retries - fix(cli): address review findings Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
3ddee3a39d |
test(cli): failing tests for watching until runs are done
Add the tests for polling until every run completes: polls until all runs complete, grace period finds a late run, stops when the grace period ends, an old commit does not wait, no runs after the grace period exits 4, progress lines only on change, --json stays one document, cancelling while waiting, a list error mid-watch, and --once not waiting. Add TestRunListDecodesCreatedAt in gh, and createdAt to the recorded run lists, taken from gh run view. The fake helpers now set a fake clock, an interval and a grace period on the App, and play a different gh run list output per call. The existing in-progress tests pass --once. Every new test fails now. The cli tests do not compile because App.Clock, App.Interval and App.Grace do not exist, and the gh tests do not compile because gh.Run has no Created field. Once they compile, the args checks fail too, since gh run list does not yet ask for createdAt. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
712c9d43e5 |
test(cli): failing tests for showing each run's jobs
Add tests for gh.Runner.RunJobs and for job rows in the table and the --json output. The gh package tests do not compile yet because gh.Job and RunJobs do not exist: TestRunJobsPassesRunIDAndFields, TestRunJobsDecodesRecordedOutput, TestRunJobsReturnsGhError and TestRunJobsRejectsMalformedOutput. In the cli package the fake gh now routes run list and run view, and counts them separately. TestRunPrintsTable, TestRunJSON, TestRunInProgressPrintsJobs, TestRunCallsRunViewOncePerRun and the view-call counts in TestRunExitCodes fail because no run view is run and no job rows or jobs arrays are printed. TestRunJobsDoNotChangeExitCode fails on the missing job rows. TestRunJobsErrorKeepsRunExitCode and TestRunJSONJobsAreAlwaysArrays fail because there is no warning on stderr and no jobs array. TestRunCancelledWhileFetchingJobs fails because ciwatch exits 1 and prints the table instead of exiting 4 with nothing on stdout. The inline fakes in the exit code, full page and conclusion tests move to a helper that answers run view with an empty jobs list. Fixtures: the run-view-<id>.json files are recorded gh run view output for the runs in the existing run lists. The in-progress jobs fixture, run-view-45017063720-in-progress.json, is derived, not recorded: it is the finished run 45017063720 with most job statuses edited to in_progress and queued and their conclusions emptied. It stays consistent with run-list-in-progress.json. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
d56e7b9040 |
feat(cli): list a commit's workflow runs once
ciwatch <commit> now resolves the commit to its full SHA with git, lists every workflow run for it once with gh run list, and prints each run's workflow, status and conclusion as a compact table, or as JSON with --json. The flag and the commit can come in either order. The exit code sums up the runs. It is 2 for a usage error or a commit git can't resolve, 4 when gh fails, no runs are found or some runs haven't finished, 1 when a run failed, timed out, failed to start or needs action, 3 when a run was cancelled, and 0 when every run passed or was skipped. The first match in that order wins. When runs are still in progress the table is still printed, with a message on stderr, so their statuses are not hidden. Every gh and git call goes through a new internal/gh Runner, whose Exec field is the seam tests replace. The tests feed it recorded gh output from testdata/gh, so they never call GitHub. The in-progress fixture is derived from a recorded run, because every recent run of the source repository had already finished. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |