Skip to content

Tell the owner when a run started by a bot fails - #86

Merged
ryansmith4 merged 3 commits into
mainfrom
ci/report-bot-run-failures
Nov 22, 2026
Merged

ryansmith4 merged 3 commits into
mainfrom
ci/report-bot-run-failures

Conversation

@ryansmith4

@ryansmith4 ryansmith4 commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

What this fixes

GitHub emails a failed workflow run only to whoever started it. Two kinds of run are started by nobody who reads email:

When one of these fails, nothing tells the repository owner. A Dependabot pull request with auto-merge enabled then sits open, or main stays broken. This is not hypothetical: a download from a package site failed three times on 2026-11-21 and 22, once on main after the app merged #83.

Changes

  1. A notice when CI fails in a run the owner did not start (ci.yml, new report-failure job). It runs when the build, dependency-submission or dependency-review job fails, and opens a ci-failure issue assigned to the repository owner. The issue shows each job's result and gives the command to run the failed jobs again.
    • One open issue collects the failures. If a ci-failure issue is already open, the job comments on it instead of opening another, so an outage at a package site does not produce one issue per run. The issue has a fixed title, and each failure names itself in the first line of the issue or comment. Failures that land in the same few seconds can still open one each. The owner closes the issue once dealt with.
    • The advice depends on what failed. If only dependency-review failed on a pull request, the notice says the pull request has probably merged anyway, because that job is not a required check, and to read its log. If the build failed on main but the dependency baseline was recorded, it says so. A cancelled job gets a sentence saying what that means.
    • Not reported: the owner's own runs, which GitHub already emails; pull requests from forks, whose token cannot open an issue; and a pull request run cancelled by a newer push. Outside pull requests a cancelled job is reported, because there it means a job ran past its time limit.
  2. A comment when the auto-merge job itself fails (dependabot-auto-merge.yml, new last step). It comments on the pull request and mentions the owner. It uses the built-in token, never the app's, and needs no new permission.
  3. CLAUDE.md: describes both, and adds one rule for publishing: approve the maven-central environment only for a run you started.

What was tested

The two scripts were run as they appear in the workflow files, with a stand-in for the gh command:

  • The notice, 21 cases: each kind of run and each combination of failed or cancelled jobs that changes the advice; titles containing shell syntax, which arrive literally and on one line; a 300-character title; an issue that is already open, for a pull request and for main; a lookup or a comment that fails; a label that cannot be created; an assignee that cannot be set; and nothing being creatable, where the step fails.
  • The comment, 2 cases: posted with the mention first, and the step failing when it cannot be posted.
  • Structure, 7 checks: the new job can only write issues, runs no action and names no secret but the built-in token; the auto-merge job still runs exactly its two pinned actions; its new step is last, runs only on failure and never holds the app's token.
  • The lookup of an open notice, run for real and read-only against this repository: it returns the open issue for a label that has one, nothing for a label that does not exist, and leaves pull requests out.
  • The tests themselves: 25 deliberate breakages of the two workflow files, each of which makes a named check fail, after a control run showing the tests pass on an unchanged copy.

GitHub's own records confirm who the "starter" is in each case: the three merges on 2026-11-22 show northpost-automerge[bot] for the app's merges and the owner's login for the owner's.

Not testable before it happens: the job's condition as GitHub evaluates it, and that the issue and the comment produce an email. This pull request's own run is started by the owner, so the new job is skipped on it. No workflow has opened an issue in this repository yet, so the first real failure is also the first real test of that.

Known limits

  • On a pull request, a job that runs past its time limit is cancelled, not failed, so it is not reported.
  • A pull request run that had already failed before a newer push replaced it is still reported.
  • Nothing closes the issue when a re-run passes.
  • A failure in the new job itself is silent.

🤖 Generated with Claude Code

https://claude.ai/code/session_018ffDfV5858ERd3MkYFRJUN

GitHub emails a failed run only to whoever started it. A run started
by Dependabot, or by the app that merges its pull requests, therefore
reaches nobody: a pull request with auto-merge enabled sits open, or
main stays broken, without a word. Downloads from the package sites
failed three times in two days, so this will happen.

- ci.yml: a report-failure job opens a ci-failure issue assigned to
  the repository owner when the build, dependency-submission or
  dependency-review job fails in a run the owner did not start. The
  issue gives the command to run the failed jobs again. Pull requests
  from forks and cancelled jobs are not reported.
- dependabot-auto-merge.yml: if the auto-merge job fails, a last step
  comments on the pull request and mentions the owner. It uses the
  built-in token, never the app's.
- CLAUDE.md: describe both, and say to approve a publish only for a
  run the owner started.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ffDfV5858ERd3MkYFRJUN
@ryansmith4 ryansmith4 added the ci Build, CI and release automation label Nov 22, 2026
ryansmith4 and others added 2 commits November 22, 2026 10:11
Review of the previous commit found the notice correct but its text
wrong in two cases, and one issue per failed run more than is useful.

- One open ci-failure issue collects the failures. A later failure
  becomes a comment on it, so an outage at a package site does not
  open an issue per run. If the search or the comment fails, an issue
  is opened anyway.
- The advice now depends on what failed. A pull request whose only
  failure is dependency-review can still merge, because only the Java
  jobs are required checks, and the notice says so. A failed build on
  main no longer claims the dependency baseline is missing when
  dependency-submission passed.
- Outside pull requests a cancelled job is reported too. Nothing
  cancels those runs on purpose, so it means a job ran past its time
  limit.
- The issue title is cut to 200 characters, under GitHub's limit.
- dependabot-auto-merge.yml: the guard comment names the new last
  step as its one exception. CLAUDE.md follows.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ffDfV5858ERd3MkYFRJUN
Review of the previous commit found it correct, with one thing that
would mislead: the collecting issue kept the title of its first
failure, so a broken main could arrive as a comment under an old pull
request's name.

- The issue title is now the same for every failure, "CI failed in a
  run nobody was emailed about". Each failure still names itself in
  the first line of the issue or comment. The title no longer needs
  cutting to length.
- The lookup of an open notice lists issues directly instead of
  searching. A search lags behind an issue opened moments ago, which
  is exactly when several failures arrive together.
- Advice text: a failed build on main with the baseline recorded no
  longer says it is unknown whether main builds; a failed
  dependency-review says the pull request has probably merged and to
  read the log; a cancelled job gets a sentence saying what that
  means.
- The comment above the job says that a pull request job running past
  its time limit is not reported.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ffDfV5858ERd3MkYFRJUN
@ryansmith4
ryansmith4 merged commit ccbcd3b into main Nov 22, 2026
10 checks passed
@ryansmith4
ryansmith4 deleted the ci/report-bot-run-failures branch November 22, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Build, CI and release automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant