Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 90 additions & 10 deletions .github/workflows/dependabot-failure-watcher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,77 @@ name: Dependabot Failure Watcher

# Dependabot version updates run as GitHub Actions workflow runs named
# "Dependabot Updates". This scheduled job looks back over the past week for any
# of those runs that failed and fails itself if it finds one, so a silently-broken
# ecosystem surfaces as a red scheduled run instead of only a red triangle in the
# Dependabot tab that nobody checks.
# version-update run that failed and fails itself if it finds one, so a
# silently-broken ecosystem surfaces as a red scheduled run instead of only a red
# triangle in the Dependabot tab that nobody checks. Security-update runs share
# that workflow name and are deliberately excluded -- see below.
#
# GitHub reuses the "Dependabot Updates" name for three different kinds of run:
#
# 1. A version update's scheduled scan: one run per .github/dependabot.yml
# entry, on the schedule set there. It works out what is out of date and
# opens or updates pull requests. This is the kind this watcher primarily
# exists to catch -- when a scan breaks, the whole ecosystem quietly stops
# being updated and nothing else tells anyone.
# 2. A version update's per-pull-request refresh: one run per already-open
# Dependabot pull request, rebasing or re-checking it. These are not driven
# by the schedule at all -- a push to the base branch, a rebase, or an
# "@dependabot recreate" comment triggers them, so they arrive in bursts
# after merges rather than at the scheduled time. A failure here means one
# open pull request has gone stale, which is worth knowing but is much
# narrower than a broken scan.
# 3. A security update: one ad-hoc job per vulnerable package, triggered by a
# Dependabot alert rather than by dependabot.yml at all.
#
# Kind 3 routinely fails for reasons no pull request can fix: the advisory is
# against a dependency this project does not declare directly, or no patched
# version is reachable. Counting those would keep this workflow permanently red
# and train everyone to ignore it, so they are filtered out below.
#
# Of the fields "gh run list --json" exposes, only the title separates the three
# -- event, headBranch and actor are identical. Titles come in these shapes:
#
# - "<eco> in /." -- kind 1 at the repo root, which
# has no " for " suffix
# - "<eco> in <configured-dir>" -- kind 1 elsewhere, path verbatim
# - "<eco> in / for <deps>" -- kind 2 at the repo root
# - "<eco> in <configured-dir> for <deps>" -- kind 2 elsewhere
# - "<eco> in /. for <one-dep>" -- kind 3 at the repo root
# - "<eco> in <manifest-dir> for <one-dep>" -- kind 3 elsewhere, where
# <manifest-dir> is wherever the vulnerable manifest was discovered
#
# At the root, then, kind 3 is marked by "/." AND a " for " suffix together, and
# BOTH HALVES of " in /. for " are load-bearing -- do not shorten it. Matching on
# " in /." alone would also discard every kind 1 run, which is most of the runs
# here and the shape both failures this watcher was written for actually took.
#
# Outside the root, kinds 2 and 3 cannot be told apart by title, so the filter
# has to name directories instead. e2e/js and e2e/ts (in the Node repos this
# workflow is shared with) are consumer smoke tests carrying committed
# lockfiles, so their transitive dev dependencies attract advisories that no
# pull request can fix, and nothing in them is shipped code.
#
# Be clear about the cost, because it is not zero: both Node repos configure npm
# with directories: ["/", "**/*"], and that glob does match e2e/js and e2e/ts,
# so those directories DO get version updates. Dropping the pattern therefore
# discards their kind 2 failures as well as their kind 3 ones -- there is an
# open version-update pull request under e2e/ts in both repos as this is
# written. The npm ecosystem label does not rescue the distinction either:
# Dependabot writes "npm_and_yarn" for both kinds, so "npm_and_yarn in /e2e/ts
# for js-yaml" could be either a security job or the refresh of a
# version-update pull request.
#
# Accepted deliberately anyway. Kind 1 is what this watcher primarily exists to
# catch and is still reported for those directories, so what is given up is the
# narrower "one open pull request has gone stale" signal, for two directories of
# test scaffolding, in exchange for dropping 16 unactionable failures in each of
# the two Node repos over retained history.
#
# Reading the directories out of dependabot.yml instead looks more general but is
# worse: entries may use globs (directories: ["**/*"]), which never match a title
# literally, so genuine failures would be dropped without a word. Prefer a
# denylist: when it goes stale it re-introduces noise, which is loud, whereas a
# stale allowlist hides failures, which is silent.
#
# Runs entirely within this repo (no external service). A failed scheduled run
# emails the person who last edited the cron below. Note: GitHub auto-disables
Expand All @@ -22,22 +90,34 @@ jobs:
check-dependabot-runs:
runs-on: ubuntu-latest
steps:
- name: Fail if any Dependabot update failed in the last 8 days
- name: Fail if any Dependabot version update failed in the last 8 days
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
run: |
since=$(date -u -d '8 days ago' +%Y-%m-%dT%H:%M:%SZ)
failures=$(gh run list \
# --created filters server-side, so --limit applies to runs already
# narrowed to the window rather than to all of history. Runs come back
# newest-first, so reaching the limit would drop the oldest in-window
# runs and this step would report all-clear without them -- hence a
# limit far above any plausible week's worth of runs.
runs=$(gh run list \
--repo "$REPO" \
--workflow "Dependabot Updates" \
--limit 100 \
--json conclusion,createdAt,displayTitle,url \
--jq "[.[] | select((.conclusion == \"failure\" or .conclusion == \"startup_failure\" or .conclusion == \"timed_out\") and .createdAt >= \"$since\")]")
--created ">=$since" \
--limit 500 \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

: "${REPO:?set REPO=owner/name}"
since=$(date -u -d '8 days ago' +%Y-%m-%dT%H:%M:%SZ)
runs=$(gh run list \
  --repo "$REPO" \
  --workflow "Dependabot Updates" \
  --created ">=$since" \
  --limit 501 \
  --json createdAt)

if [ "$(jq 'length' <<<"$runs")" -ge 501 ]; then
  echo "More than 500 matching runs exist; the watcher may truncate results."
  exit 1
fi

Repository: maxmind/GeoIP2-python

Length of output: 199


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== workflow excerpt =="
if [ -f .github/workflows/dependabot-failure-watcher.yml ]; then
  nl -ba .github/workflows/dependabot-failure-watcher.yml | sed -n '70,115p'
else
  echo "Workflow file not found"
fi

echo
echo "== GitHub CLI availability and run_list help snippet =="
if command -v gh >/dev/null 2>&1; then
  gh --version | head -3
  gh run list --help 2>/tmp/gh-help.log | sed -n '/limit/,50p' || true
else
  echo "gh not installed"
fi

echo
echo "== gh run list call sites =="
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' 'gh run list|--limit 500|Dependabot Updates|run list' .

Repository: maxmind/GeoIP2-python

Length of output: 222


🏁 Script executed:

#!/usr/bin/env bin/bash
set -euo pipefail

REPO="${REPO:-maxmind/GeoIP2-python}"

echo "== workflow excerpt =="
if [ -f .github/workflows/dependabot-failure-watcher.yml ]; then
  awk 'NR>=70 && NR<=115 { printf "%7d  %s\n", NR, $0 }' .github/workflows/dependabot-failure-watcher.yml
else
  echo "Workflow file not found"
fi

echo
echo "== gh run list call sites =="
grep -RInE '(^|[^a-zA-Z0-9_])gh run list|--limit 500|Dependabot Updates|run list' .github . 2>/dev/null | head -200 || true

echo
echo "== gh availability/help =="
if command -v gh >/dev/null 2>&1; then
  gh --version | head -3
  gh run list --help | sed -n '/limit/,+30p' || true
else
  echo "gh not installed"
fi

echo
echo "== repository workflow files =="
find .github/workflows -type f -exec sh -c 'echo "--- {}"; grep -nE "gh run list|limit 500|Dependabot Updates|created" "{}" | head -80 || true' \; || true

Repository: maxmind/GeoIP2-python

Length of output: 6142


🏁 Script executed:

#!/usr/bin/env bin/bash
set -euo pipefail

echo "== gh run list command/source references =="
(
  command -v gh >/dev/null 2>&1 && gh --version | head -3 || true
  command -v gh >/dev/null 2>&1 && gh run list -L 500 --help | sed -n '/flags/p;/limit/p' || true
  command -v gh >/dev/null 2>&1 && gh api -X GET /users/mona/actions/runs?per_page=501\&include_workflow_runs=true >/tmp/maybe_api.json 2>/tmp/maybe_api.err; cat /tmp/maybe_api.err || true
)

echo
echo "== API documentation snippets from local gh docs if present =="
find "$(gh --config-dir 2>/dev/null || echo /tmp)" -path '*gh_run_list*' -type f 2>/dev/null | head -20 | xargs -r grep -n -i 'limit\|per_page\|runs' || true

Repository: maxmind/GeoIP2-python

Length of output: 579


Check for saturation after listing runs.

--limit 500 caps the gh run list result, and with --created newer runs filling that cap, older matching runs are dropped before the failure filter runs. Detect a saturated output page or paginate/split the time range so the watcher fails closed on unseen older failures.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/dependabot-failure-watcher.yml at line 97, Update the gh
run list logic in the Dependabot failure watcher around the --limit 500 option
to detect when the result is saturated and avoid treating the visible page as
complete. Either paginate the run listing or split the --created time range, and
ensure older matching failures remain discoverable so the watcher fails closed
when unseen failures may exist.

Source: MCP tools

--json conclusion,createdAt,displayTitle,url)
failures=$(echo "$runs" | jq '
[.[]
| select((.displayTitle | contains(" in /. for ")) | not)
| select((.displayTitle | test(" in /e2e/(js|ts) for ")) | not)
| select(.conclusion == "failure"
or .conclusion == "startup_failure"
or .conclusion == "timed_out")]')
count=$(echo "$failures" | jq 'length')
if [ "$count" -gt 0 ]; then
echo "::error::$count failed Dependabot update run(s) in the last 8 days:"
echo "::error::$count failed Dependabot version update run(s) in the last 8 days:"
echo "$failures" | jq -r '.[] | "- \(.displayTitle) (\(.createdAt))\n \(.url)"'
exit 1
fi
echo "No failed Dependabot update runs in the last 8 days."
echo "No failed Dependabot version update runs in the last 8 days."
Loading