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 \
--json conclusion,createdAt,displayTitle,url)
Comment on lines +104 to +109

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 | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== workflow file excerpt =="
sed -n '1,140p' .github/workflows/dependabot-failure-watcher.yml 2>/dev/null || true

echo
echo "== gh cli availability and version =="
if command -v gh >/dev/null 2>&1; then
  gh --version | head -n 3
else
  echo "gh not found"
fi

echo
echo "== search for dependabot failure watcher references =="
rg -n "dependabot-failure-watcher|Dependabot Updates|gh run list|--limit 500|created \)>=|since" .github workflow 2>/dev/null || rg -n "dependabot-failure-watcher|Dependabot Updates|gh run list|--limit 500|created \)>=|since" . 2>/dev/null || true

Repository: maxmind/libmaxminddb

Length of output: 7630


🌐 Web query:

GitHub CLI gh run list --limit default created date Actions API response per_page 100

💡 Result:

The GitHub CLI command gh run list provides a --limit flag (alias -L) to control the number of workflow runs to fetch [1][2][3]. While the specific default value for the --limit flag may vary across versions of the GitHub CLI (commonly cited as 20 or 30) [1][2][4][3], the underlying GitHub Actions REST API uses a per_page parameter to handle pagination [5][6][7]. Key points regarding these parameters include: 1. GitHub CLI --limit: This flag specifies the maximum number of runs to retrieve [1][8]. If not specified, it defaults to a built-in value (often 20 in recent versions) [1][2][3]. 2. GitHub Actions API per_page: This API parameter controls the number of results returned per request [5][6]. It has a default value of 30 and a maximum allowed value of 100 [5][6][9]. 3. Interaction: When you use gh run list --limit, the GitHub CLI manages the API calls for you, performing internal pagination if the requested limit exceeds the API's per_page maximum (100) or to aggregate results to reach your specified limit [4]. If you need to retrieve a large number of runs, the GitHub CLI will handle the necessary API pagination to fulfill your --limit request [4]. If you are working directly with the GitHub REST API, you must explicitly set per_page (up to 100) and iterate through pages using the page parameter to retrieve more than 100 results [5][6][7].

Citations:


🌐 Web query:

site:docs.github.com REST API actions workflow runs list workflow runs filtered by created

💡 Result:

To filter workflow runs by their creation date using the GitHub REST API, you use the created parameter [1][2]. This parameter is available for the endpoints that list workflow runs for a repository and for a specific workflow [1][3]. The created parameter accepts a string that defines a date-time range [1][4]. The syntax for this string follows the standard GitHub search syntax, which allows for various operators such as ranges [1][5]. For example, you can specify dates in YYYY-MM-DD format or ISO 8601 date-time formats [1][4]. Applicable API Endpoints: 1. List workflow runs for a repository: GET /repos/{owner}/{repo}/actions/runs [1][3] 2. List workflow runs for a workflow: GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs [1][3] When using the created parameter, the API endpoint will return up to 1,000 results for the query [1][2]. For detailed information on the specific operators supported for date ranges (e.g., >, <,..), refer to the official GitHub documentation on search syntax [1][4].

Citations:


Fail closed when the run query reaches its cap.

--limit 500 stops this query after the 500 newest in-window runs, even though the API can return up to 1,000 matching created results. If more than 500 versions runs exist in the 8-day window, older failures are dropped before filtering and the workflow can report all-clear. Fetch a sentinel row and fail closed when it is present, or establish a guaranteed lower bound for this repository’s weekly Dependabot run count.

🤖 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 around lines 93 - 98,
Update the run query in the workflow’s gh run list block to detect truncation by
requesting one sentinel row beyond the intended 500 results, then fail closed
when that sentinel is present before filtering or reporting success. Preserve
the existing in-window query and ensure the sentinel cannot be mistaken for a
real run result.

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