mirror of
https://github.com/devvmhq/ciwatch.git
synced 2026-12-01 06:13:17 -10:00
main
12
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7c4f7c74a2 |
feat(cli): show no jobs under a kept run that wasn't completed
A run that drops out of gh run list is kept at its last listed state, but its jobs were still fetched with gh run view. A run last seen in_progress could then show an in_progress row above jobs that GitHub now reports as completed. ciwatch now skips the jobs fetch for a run that the latest list doesn't have and that was last seen in any status other than completed. Its table row has no job rows under it, and in --json its jobs array is empty with no jobs_error. The existing "no longer listed" warning still explains it, and the exit code is still 4. A kept run last seen completed is fetched at its reported attempt as before, and so are runs that never drop out, runs that come back before the last list, and every run under --once. The rule is a small method on listed, keptUnfinished, and docs/json.md says when jobs is empty for this reason. The new tests cover the table for in_progress, queued, waiting, requested and pending, the --json output, and a rerun's new attempt that drops out. The test for a kept run that passed now checks the full table with its job rows, so a skip that is too broad would fail it. Backlog: TestWatchRunVanishesInProgressJSON checks only in_progress. It could loop over the same five statuses as the table test. It is off this feature's path because the behaviour works and the table subtests already cover every status that isn't completed, so it only makes the test stricter. Spec: acceptance cases 1. AC-1: A run last seen `in_progress` drops out and is still missing at the last list (`ciwatch <sha>`). The table shows its row `CI in_progress` with no job rows under it. `gh run view` isn't called for it. Stderr has the existing `ciwatch: run <id> (CI) is no longer listed for this commit` line once. Exit code is 4. 2. AC-2: Same as AC-1 with `--json`. That run's `jobs` is `[]` and it has no `jobs_error`. Its other fields come from its last listed state. Exit code is 4. 3. AC-3: Under `--rerun-failed`, a run's new attempt is last seen `in_progress` and then drops out for good. Its row is `CI in_progress` with no job rows, and there's no `gh run view` for it. The warning ends with `; not waiting for it`. Exit code is 4. 4. AC-4: A kept run last seen `completed` (failure or success) gets its jobs fetched and shown exactly as today. That includes failure blocks, `--go-tests` and crash hints. Exit codes are 1 and 0, as today. 5. AC-5: A run that drops out and comes back before the last list is reported with its jobs, exactly as today. 6. AC-6: Runs that never drop out, including in `--once` mode, which never tracks dropped runs, report their jobs exactly as today. All existing golden files stay byte-for-byte the same. 7. AC-7: Statuses other than `in_progress` that aren't completed (`queued`, `waiting`, `requested`, `pending`) on a kept run are treated like AC-1. Spec: non-goals - Looking up the missing run by ID to get its real current state. - Marking the run as kept in `--json`, or adding any new field. - A new stderr line, or a table note such as "(jobs not shown)". The existing "no longer listed" warning is the explanation. - Changing how a kept completed run's jobs are fetched, or what attempt they're fetched at. - Kept runs' artifacts, timeouts and crash lookups. These already skip runs that aren't completed. Spec: inference none. The rule rests only on two facts ciwatch already has: whether the run was missing from the last list (`listed.missing`), and the status from its last listing. **Behaviour.** No new flags, and exit codes are unchanged. Example: CI was `in_progress` when it dropped out, and Docs passed: ``` $ ciwatch abc1234 ciwatch: run 111 (CI) is no longer listed for this commit WORKFLOW STATUS CONCLUSION CI in_progress Docs completed success build completed success $ echo $? 4 ``` Today, rows such as ` test completed failure` would appear under `CI in_progress`. Spec: approved with Approved under CJ's standing delegation: no inference, and the choice removes the mismatch from both the table and --json. Your answers are accepted: no placeholder line, and kept completed runs are still fetched at their reported attempt. Built in steps: - test(cli): no job rows under a kept run that wasn't completed - feat(cli): don't fetch jobs for a kept run that wasn't completed Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
dc8f08c556 |
feat(cli): keep runs that drop out of the list in the report
A run that was listed and then missing from a later gh run list used to disappear from the table, the JSON and the exit code without a word, so a failure seen earlier could end as exit 0. Only rerun runs were kept before, and only during the wait for new attempts. A new listed type remembers the last state of every run and which runs the latest list lacks. Its observe method warns once per disappearance and returns the list with each missing run put back at its last state, before the next run of its last list that is still present. It replaces withGone. watch observes every list except under --once, checks "no runs found" on the merged list, and waits only for the runs that are listed, so a missing run isn't waited for and an empty list after a non-empty one no longer fails. watchAttempts shares watch's listed, so a run that dropped out during the first watch is warned about once in total. A rerun run keeps the "; not waiting for it" warning and other runs get the plain "is no longer listed for this commit" line. A run that comes back is reported at its latest state, in gh's order. The usage text, docs/json.md and the comments now say this applies to every run, not only reruns. Runs that never drop out, and every --once call, behave as before, and no golden file changed. The tests are in vanish_test.go. Backlog: - A kept run still has its jobs fetched when the report is built, so a run last seen in_progress can show job rows newer than its row. Off the path because looking up a missing run's real state is a non-goal. - The usage text in internal/cli/cli.go has a very short line, "known state. The", from a hand rewrap. Off the path because it is cosmetic and nothing is lost or misleading. - TestWatchRunReappears doesn't assert the fresh progress line when a run comes back. Off the path because it is test tightness on behaviour that already works. Spec: acceptance cases - AC-1: Without `--once`, poll 1 lists CI (failure) and Docs (success). From poll 2 on, only Docs is listed. Stderr gets exactly one line, `ciwatch: run <ci-id> (CI) is no longer listed for this commit`. The table shows CI `completed failure` with its jobs, in its old place before Docs. Exit code 1 (this also covers the task's AC-2). - AC-2: Same, but Docs is the run that drops out, after `completed success`, and CI is listed throughout as success. There is one warning, both rows are shown and the exit code is 0. - AC-3: A run last seen `in_progress` drops out and stays out. There is one warning, the watch doesn't wait for it, and it ends once the listed runs complete and the grace period is over. The row reads `in_progress`, the exit code is 4, and there is no "drop --once" line. - AC-4: A run is listed, missing, listed again (now with a later state), missing again, then listed for good. Stderr has the warning twice, once per disappearance. The report and exit code come from its last listed state. - AC-5: Every run is missing from a later list (the list comes back empty) after a non-empty one, once the grace period is over. Each run gets one warning, the report holds all of them at their last state, and there is no `no runs found` error. If no list ever had a run, `no runs found` and exit 4 stay as they are. - AC-6: With `--rerun-failed`, a non-rerun run (Docs, success) drops out during `watchAttempts` while CI's rerun is waited for. Docs gets one warning in the new wording, and the table still shows it as success. A rerun run that drops out still gets today's warning, ending in `; not waiting for it`. - AC-7: With `--rerun-failed`, a failed run that dropped out during `watch` and is still missing gets exactly one warning in total. It is reported at its last known state (failure, exit 1). `watchAttempts` doesn't warn about it again. - AC-8: Runs that never drop out, and every `--once` call, behave exactly as today. All existing tests and golden files pass unchanged. Spec: non-goals - Looking up a missing run by its ID (`gh run view <id>`) to get its real current state. - Telling a deleted run apart from one pushed past the 100-run list limit. - Marking a kept run in `--json` or in the table. The schema and golden files stay as they are. - Not rerunning a failed run that has dropped out. `--rerun-failed` still asks GitHub to rerun it, as it does any failed run it knows of. - Waiting for a missing run to come back. Spec: inference none. A run's absence from `gh run list --json` output is a fact. ciwatch reports the last state gh gave and doesn't guess why the run is missing. Spec: approved with Approved under CJ's standing delegation: no inference (absence from gh run list is a fact, and the last state gh gave is reported), the acceptance cases cover the task's drafts, and the non-goals hold. Your three answers are accepted: the plain warning for non-rerun runs and the '; not waiting for it' suffix for rerun runs; --rerun-failed still tries a dropped-out failed run; a run that comes back takes gh's order and gets a fresh progress line. Built in steps: - test(cli): runs that drop out of the list stay in the report - feat(cli): keep runs that drop out of the list in the report - docs(cli): say that every run that drops out is kept 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]>
|
||
|
|
60c88ccf6c |
feat(cli): stop waiting for a rerun that drops out of the list
With --rerun-failed, ciwatch waited until every rerun run showed a later attempt, so a run that stopped appearing in gh run list made it wait forever, and the run vanished from the report. It now remembers the last state it saw of each rerun run. When a poll doesn't list one, it warns once per disappearance (run <id> (<workflow>) is no longer listed for this commit; not waiting for it) and stops waiting for it. The watch ends once every listed run is complete and every rerun run that is still listed is past its attempt. A run that is listed again is waited for as before, and a second disappearance warns again. The report puts a missing run back at its last known state, in the place it had in the first list, and the exit code comes from that state. Its jobs are fetched with gh run view --attempt for the attempt it is reported at, because GitHub may already hold a later one. The advice to drop --once is now printed only with --once, since without it a pending run can only be one that dropped out of the list. The usage text and the exit codes in docs/json.md say so. The --json schema and the golden files don't change. Left from review: The artifacts of a run reported at an older attempt are listed for the whole run (internal/cli/cli.go), so a crash input from a later attempt that ran after the run dropped out could show under the older row. A normal rerun already has the same limit. Whether GitHub returns other attempts' artifacts needs checking against a real rerun. Backlog: TestRerunVanishesInProgress checks the CI row's status but not that its jobs were asked for with --attempt 2. It is test tightness: the same code path is checked in TestRerunVanishesBeforeNewAttempt. The pending > 0 && opts.once guard in internal/cli/cli.go relies on parseArgs rejecting --once with --rerun-failed. A comment or test tying the two together would help if that rule is relaxed. It is docs and style: the current behaviour is correct. Spec: acceptance cases - AC-1: A run was rerun, and a later poll doesn't list it. stderr gets `ciwatch: run <id> (<workflow>) is no longer listed for this commit; not waiting for it` once. The line isn't repeated on later polls while the run stays missing. The watch ends as soon as every listed run is complete and every rerun run that is still listed has gone past its attempt. - AC-2: The missing run was last seen as `completed failure` on attempt 1, because it dropped out before attempt 2 was ever listed. The report shows it as `completed failure` with attempt 1's jobs, and the exit code is 1. The `--rerun-failed` hint isn't printed. - AC-3: The missing run was last seen as `in_progress` on attempt 2, and every other run passed. The report shows it as `in_progress`, and the exit code is 4. stderr doesn't contain the `drop --once to wait for them` hint, because that advice is wrong here. - AC-4: Two runs are rerun and one of them drops out. ciwatch keeps polling until the other one's new attempt completes, and the report shows that new attempt's result. - AC-5: A rerun run is missing from one poll and listed again on the next, still in progress. ciwatch waits for it again until its new attempt completes, the report shows that result, and the `no longer listed` warning appeared exactly once. - AC-6: A run reappears and then drops out a second time. The warning is printed a second time, because each disappearance gets one warning. The report shows the state it had the last time it was listed. - AC-7: Ctrl-C while the run is missing behaves as it does today: `ciwatch: context canceled`, no table, and exit code 4. Spec: non-goals - Rerunning the missing run again, a time limit on waiting, and searching other commits or the run by ID. - Runs that drop out of the list without having been rerun, either in the first watch or after the reruns. Today they vanish from the report without a word. That's a separate follow-up below. - Marking a missing run in the `--json` output or the table. The stderr warning is the only signal, so the JSON schema and golden files don't change. - Telling a deleted run apart from one that fell past `gh run list`'s 100-run limit. Spec: inference none. "No longer listed" means only that the latest `gh run list` didn't include the run, which ciwatch knows for certain. It doesn't guess why, or whether the run will come back. If the run comes back while ciwatch is still watching, ciwatch picks it up (AC-5). If it comes back after ciwatch has exited, the report shows the last state ciwatch saw. Spec: approved with Approved under CJ's standing delegation (2026-11-23): Inference is none (it acts only on what gh run list returned); the acceptance cases cover the task's drafts and add the second disappearance, Ctrl-C and the --once hint; the non-goals hold. Your answers are accepted: one warning per disappearance, and no mark in --json for now. Your follow-up is created as its own dex task. Built in steps: - test(cli): cover a rerun run that drops out of the list - feat(cli): stop waiting for a rerun that drops out of the list - docs(cli): describe a missing rerun run in the watchAttempts comment - fix(cli): fetch a missing rerun run's jobs by attempt Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
0cb5a807c8 |
feat(cli): report crash inputs that are already present
With --fetch-crashes, gh refuses to overwrite a file, so a crash input that was already committed was reported as a fetch error with a warning, though it was where it belongs. Each artifact is now downloaded into a new staging directory under App.TempDir, and its files are copied into the target directory, each created only if it doesn't exist. A file that exists counts as present and is left alone. The staging directory is always removed, and a failed or interrupted download no longer leaves half an artifact in the checkout. If the copy fails partway, the files it already wrote are removed. Each attempt of a retried download starts from an empty directory. When every file was already present, the table line ends ": already present in <dir>" and the JSON entry has already_present with fetched_to and no fetch_error. A fetch that writes a new file keeps the "fetched to" line. An artifact without files is the fetch error "artifact crash-<Target> has no files". When an input is skipped or fails, the last stderr line, after the rerun hint, now says what to do next: the declaration to add, the files to download by hand, the checkout to run in, or how to try again, in the plural when several inputs failed for the same reason. The exit code still comes from the runs alone. README, the usage text and docs/json.md describe the new behaviour. Backlog: - The plural hint for several inputs declared in more than one file, "download them by hand: gh run download <run> -n <artifact> -D <package>/testdata/fuzz/<Target>", is made of placeholders, so it can't be pasted as it is. Off the path because the output matches the approved spec and the warnings above it name each file. - If Ctrl-C arrives just after gh run download succeeds, the files are still copied and not reported. Off the path because reporting what was written on interrupt is the separate Ctrl-C task. Spec: acceptance cases AC-1: Every file in the artifact already exists in `internal/p/testdata/fuzz/FuzzParse`: - The table line is ` FuzzParse (crash-FuzzParse, run 44729305066): already present in internal/p/testdata/fuzz/FuzzParse`. - Nothing on stderr mentions the input: no `can't fetch` warning and no fetch hint. - The JSON entry has `"fetched_to":"internal/p/testdata/fuzz/FuzzParse","already_present":true` and no `fetch_error`. - The existing files are left byte-for-byte unchanged. AC-2: The artifact has at least one file that doesn't exist yet in the target directory: - The new file is written there, and any existing file is left unchanged. - The line stays `…: fetched to internal/p/testdata/fuzz/FuzzParse`. - The JSON has `fetched_to`, and no `already_present` or `fetch_error`. - The target directory is created if it's missing. AC-3: Any crash input is skipped or fails. The last stderr line is a single hint, and it comes after the rerun hint: - **No `_test.go` declares the target:** `ciwatch: crash-FuzzParse of run 44729305066 not fetched; declare func FuzzParse(f *testing.F) in a _test.go file, then run: ciwatch --fetch-crashes <sha>` - **The target is declared in more than one file:** `ciwatch: crash-FuzzParse of run 44729305066 not fetched; FuzzParse is declared in more than one file, so download it by hand: gh run download 44729305066 -n crash-FuzzParse -D <package>/testdata/fuzz/FuzzParse` - **No git checkout:** `ciwatch: crash-FuzzParse of run 44729305066 not fetched; run ciwatch --fetch-crashes <sha> inside the repository's checkout` - **The download or the copy failed, including after retries:** `ciwatch: crash-FuzzParse of run 44729305066 not fetched; to try again: ciwatch --fetch-crashes <sha>` - **Several inputs not fetched:** if they all failed for the same reason, the line uses that reason's next step in the plural: `ciwatch: 2 fuzz crash inputs not fetched; to try again: …`. If the reasons differ, it's `ciwatch: 2 fuzz crash inputs not fetched; see the warnings above, then run: ciwatch --fetch-crashes <sha>`. The per-input `can't fetch …` warnings still appear above the hint. AC-4: The downloaded artifact contains no files. ciwatch reports `fetch_error` `artifact crash-FuzzParse has no files`, the line ends `: not fetched`, and the "try again" hint is printed. AC-5: The download fails, or Ctrl-C interrupts it. The checkout is unchanged and the staging directory is removed. On Ctrl-C ciwatch exits 4 with no table, as it does today. AC-6: The exit code still comes only from the runs. With a failed run, ciwatch exits 1 whether the input was fetched, already present or not fetched. Spec: non-goals - Comparing file contents. A file with the same name counts as present even if its bytes differ. - Deduplicating inputs that have different names. - Overwriting or deleting existing files. - A per-file report for an artifact that is partly present (AC-2 just says `fetched to`). - Reporting what was written when ciwatch is interrupted (the blocked task "Report written crash inputs on Ctrl-C"). - Changing the output without `--fetch-crashes`. Spec: inference none. "Already present" is decided by `O_EXCL` on our own write, not by parsing gh's error text. Spec: approved with Approved by CJ, with your four assumed answers: already-present isn't a skip and gets no hint; already-present inputs keep fetched_to; the 'which file to remove' example is dropped; the fetch hint comes after the rerun hint, as the last line. Built in steps: - test(cli): report crash inputs that are already present - feat(cli): report crash inputs that are already present - docs(cli): describe already-present crash inputs - fix(cli): 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]> |