Repository navigation
feat(ci-failure): find every failure of a test, including retried ones - #14
Conversation
## Short Summary (TL;DR) `/ddev:ci-failure` gains `test-history.sh`, which lists every CI failure of one test since a date. It also counts failures that a Buildkite retry or a GitHub rerun hid behind a pass. SKILL.md says when to use it and how to read the results. ## The Issue The skill reads one build, and its history can't show how often a test fails: - The Buildkite history reads commit statuses on the default branch's last 15 commits. It leaves out PR branches and shows a build that passed on retry as a pass. - The Buildkite API leaves a retried job out of its build's `jobs`. Only the replacement job's `retry_source.job_id` names it. - The GitHub history covers one workflow. A run that passed on a rerun shows only its last attempt. Asked which TestCorepackEnable failures happened in a month, an agent found 5 of 8. The other 3 were in builds that passed on retry. ## How This PR Solves The Issue | Change | What it does | | --- | --- | | `test-history.sh TestName YYYY-MM-DD [OWNER/REPO]` | Pages through the org's Buildkite builds with `bk api` until a page comes back empty. Fetches failed jobs and retried jobs found through `retry_source`. Reads failed jobs of every attempt of failed or rerun GitHub runs. Prints one line per failure: date, pipeline or workflow, branch, link, `file:line` and error text. | | SKILL.md "Every failure of one test" | When to run the script, and how retries hide failures. Group failures by error, not by test name. Name each failure's provider. Check when the test was added before calling failures "increasing". Read open PRs on the same code first. | | SKILL.md step 4 | Prefer tests that use the workflow DDEV recommends. Check for `[no tests to run]`. When a race doesn't reproduce, read the pinned upstream source and inject the failure under a separate `DDEV_XDG_CONFIG_HOME`. | The script needs `bk auth login` for Buildkite. Without it, the script searches GitHub only. ## Manual Testing Instructions ```bash claude plugin install ddev --marketplace ddev/agent-skills bk auth login <skill dir>/test-history.sh TestCorepackEnable 2026-11-10 # Expect 6 Buildkite lines from 2026-11-11 to 2026-11-13. # 3 of them show "(passed)", because a retry hid the failure. ``` ## Automated Testing Overview Claude Code ran `shellcheck plugins/*/skills/*/*.sh` and `claude plugin validate .`. Claude Code ran the command above under macOS bash 3.2, and it found all 6 failures. Nobody ran the script on Linux or Git Bash, or tried the changed skill in a fresh session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scripts now check that `gh` and `bk` are installed and signed in. When one is missing, they print the command that fixes it, such as `gh auth login` or `bk auth login --org=ddev --token=<token>`. `test-history.sh` skips that CI system and searches the other. `failed-job.sh` stops on a GitHub run, and says to download the log instead. SKILL.md lists both CLIs, what each is for, and how to fix a missing one. It tells the agent to give the user that command and continue with what works. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
stasadev
left a comment
There was a problem hiding this comment.
The Buildkite side works on Linux, but the GitHub side misses most logs with a current gh. Details inline.
Claude Code ran test-history.sh TestCorepackEnable 2026-11-10 on Linux (GNU bash 5.3, gawk 5.4, gh 2.103.3, bk 3.67.0). It printed the same 6 Buildkite lines you got, 3 of them (passed), each with a real file:line. shellcheck and claude plugin validate . pass.
Small things:
- The error column is noisy: it picks up the
Test: TestCorepackEnable/node26line and Buildkite timestamps in the middle of a line, such as2026-11-11T18:51:43.849 Paused Mutagen sync session.
🤖 Reviewed with assistance from Claude Code
| gh api "repos/$repo/actions/runs/$run/attempts/$a/jobs?per_page=100" \ | ||
| --jq '.jobs[] | select(.conclusion == "failure") | .id' | while read -r job; do | ||
| f=$out/logs/$job.log | ||
| [ -s "$f" ] || gh api "repos/$repo/actions/jobs/$job/logs" > "$f" 2> /dev/null || continue |
There was a problem hiding this comment.
With gh 2.103.3 this fails for most logs: the response contains terminal escape sequences; pass --allow-escape-sequences to output it anyway. The 2> /dev/null || continue hides it, the empty file counts as "no failure", and the script exits 0. In one run 83 of 100 GitHub logs were empty.
failed-job.sh already handles this. Maybe the same here, and drop the empty file so a later run retries it:
raw=
gh api --help | grep -- --allow-escape-sequences > /dev/null && raw=--allow-escape-sequences
...
[ -s "$f" ] || gh api ${raw:+"$raw"} "repos/$repo/actions/jobs/$job/logs" > "$f" 2> /dev/null || { rm -f "$f"; echo "Can't download $job" >&2; continue; }The Buildkite download on line 76 has the same silent-empty-file pattern, although all 51 Buildkite logs downloaded fine here.
There was a problem hiding this comment.
Comment by Claude Code, at @stasadev's request.
With that fix applied, Claude Code ran it again: every log downloaded except 12, which the API returns HTTP 404 (BlobNotFound) for, even with --allow-escape-sequences. The web UI still shows them, such as https://github.com/ddev/ddev/actions/runs/43090584917/job/130766631233, but the attempt's log archive leaves them out too. All 12 are attempt-1 failures of runs that passed on attempt 2, from one hour on 2026-11-11, so exactly the failures this script is meant to find. Other attempt-1 logs downloaded fine. So the script should list the logs it couldn't read, with their links to check by hand, not count them as "no failure".
There was a problem hiding this comment.
Comment by Claude Code, at @rfay's request.
Fixed in 3c76f1e. The script passes --allow-escape-sequences when gh knows it. The 12 BlobNotFound logs were a second problem: on a 404, gh writes the XML error page to stdout, so the old script cached it as a non-empty log and every later run skipped it. Each download now goes to a .part file that is moved into place only on success, for Buildkite too. The script ends with a list of the logs it couldn't download, with their links. On macOS it lists the same 12 jobs, including 130766631233.
| The scripts check both and print what to do. Tell the user which one is | ||
| missing and the command that fixes it, because the user has to run it. Then | ||
| continue with what works. Public Buildkite builds and a log the user | ||
| downloads still give one failure, but not a test's history across CI. |
There was a problem hiding this comment.
Public builds can give the history too. Without a token, https://buildkite.com/ddev lists the pipelines, build numbers are sequential so builds/N.json can be walked back to the date, and builds/N/data/jobs includes the retried job with passed: false and retried_in_job_uuid, and its log downloads from download.txt. That's how Claude Code found the hidden TestCorepackEnable failures in macos-colima-vz 8180 and 8184 before bk was installed.
It's more requests and some HTML scraping, so bk is still nicer. Maybe fall back to the public endpoints when bk is missing, or at least reword this sentence?
There was a problem hiding this comment.
Comment by Claude Code, at @rfay's request.
3c76f1e rewords the sentence and adds the public route to SKILL.md as a manual step: the pipeline list on https://buildkite.com/ddev, walking builds/N.json back to the date, data/jobs with retried_in_job_uuid, and download.txt. I checked each one without a token on macos-colima-vz 8180. I left it out of the script because a month of history would take thousands of requests across the pipelines, so SKILL.md says to ask the user to set up bk before walking more than a few pipelines.
| echo "Skipping Buildkite: the Buildkite CLI \`bk\` is not installed. See https://github.com/buildkite/cli." >&2 | ||
| return 0 | ||
| fi | ||
| if ! bk api "/pipelines?per_page=1" > /dev/null 2>&1; then |
There was a problem hiding this comment.
bk api uses the org from bk's own config, not $org, so with BK_ORG set this message names one org while the script searches another. bk api --org "$org" here and on lines 63 and 76 would keep them the same.
…'s runs With a current `gh`, most GitHub log downloads failed on terminal escape sequences, and the script counted each empty file as "no failure". It now passes `--allow-escape-sequences` when `gh` knows it, as `failed-job.sh` does. A download goes to a temporary file and is kept only when it succeeds, because `gh` writes GitHub's 404 page to stdout too. The script lists every log it couldn't download with its link. GitHub returns 404 for some logs of attempts that a rerun replaced, which are the failures the script is meant to find. A filtered list of GitHub runs stops at 1000, and ddev/ddev has about 2500 a month, so the script now asks for one day at a time. It also reads jobs that timed out. `bk api` now gets `--org`, so `BK_ORG` names the org that the script searches. The error column stops at the end of the failing test's message, so it no longer shows testify's `Test:` line or the ddev log lines after it. SKILL.md says how to read public Buildkite builds without `bk`, and what to do with the logs the script couldn't read. README lists `bk`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Comment by Claude Code, at @rfay's request. On the noisy error column from the review summary: 3c76f1e stops the message at the end of the failing test's indented output. It no longer includes testify's The same commit also fixes something the review didn't cover: a filtered list of GitHub runs stops at 1000, and ddev/ddev has about 2500 runs a month. The script now lists runs one day at a time. |
Short Summary (TL;DR)
/ddev:ci-failuregainstest-history.sh, which lists every CI failure of one test since a date. It also counts failures that a Buildkite retry or a GitHub rerun hid behind a pass, and lists the logs it couldn't download. SKILL.md says when to use it and how to read the results.The Issue
The skill reads one build, and its history can't show how often a test fails:
jobs. Only the replacement job'sretry_source.job_idnames it.Asked which TestCorepackEnable failures happened in a month, an agent found 5 of 8. The other 3 were in builds that passed on retry.
How This PR Solves The Issue
test-history.sh TestName YYYY-MM-DD [OWNER/REPO]bk api --orguntil a page comes back empty. Fetches failed jobs and retried jobs found throughretry_source. Lists GitHub runs one day at a time, because a filtered list stops at 1000 runs, and reads failed or timed-out jobs of every attempt of failed or rerun runs. Prints one line per failure: date, pipeline or workflow, branch, link,file:lineand the test's error message.bk. Group failures by error, not by test name. Name each failure's provider. Check when the test was added before calling failures "increasing". Read open PRs on the same code first.[no tests to run]. When a race doesn't reproduce, read the pinned upstream source and inject the failure under a separateDDEV_XDG_CONFIG_HOME.ghandbksetupgh auth loginorbk auth login --org=ddev --token=<token>.test-history.shthen searches the other CI system only, andfailed-job.shsays to download the GitHub log by hand. SKILL.md and the README list both CLIs.Manual Testing Instructions
Automated Testing Overview
Claude Code ran
shellcheck plugins/*/skills/*/*.shandclaude plugin validate .. Claude Code ran the command above under macOS bash 3.2 with gh 2.103.3 and bk 3.68.0, and it found all 6 failures, listed the 12 unreadable logs, and took 2 minutes. Claude Code also ran both scripts withghandbkmissing, then with stubs that fail as signed-out CLIs do, including withBK_ORGset. Each case printed the matching fix. @stasadev ran an earlier version on Linux. Nobody ran this version on Linux or Git Bash, or tried the changed skill in a fresh session.🤖 Generated with Claude Code