The Version Your Dependency Bot Can't See
My dependency bot is good at its job. Every week it opens tidy, grouped pull requests for my libraries, my CI actions and my base image. So when I asked myself whether it also kept the database server my end-to-end tests run against up to date, I assumed yes. It didn't. I was a minor release behind, and had been for months.
Nothing was broken, which is what made it easy to miss. The tests were green against the version I had pinned. They just weren't testing the version people would actually install.
The problem: some versions aren't in a manifest
Dependency bots work by reading files they understand: a lock file, a list of actions, the FROM line of a Dockerfile. If a version lives somewhere else, the bot never sees it. The version of an external server you test against tends to live in exactly those other places:
- a default inside a Compose variable, like
image: some/server:${SERVER_VERSION:-1.4}, so the stack can also start an older release; - an entry in a CI matrix, which is just a string in YAML;
- a fallback in the test code, for when the environment variable isn't set;
- text in the README and the testing docs, including a "tested with" badge.
Even a bot that understands Compose files won't help here. It can't update a tag written as a variable default. And if it could, it would bump one of those places and leave the other four saying something different. Four places disagreeing is worse than all five being old, because now the docs make claims CI doesn't check.
The usual fix is "remember to check for new releases". That is exactly the step that had already failed.
The idea: give the version an owner
The version needs something that knows every place it lives and can move all of them at once. Then a scheduled job can ask the only question that matters: is there a newer stable release than the one we test?
That splits into two small pieces:
- A bump script that knows every pinned place and rewrites them together. You can run it by hand, and the scheduled job runs exactly the same thing.
- A weekly job that looks up the latest stable release and, if it's newer, runs the script on a branch, starts CI and opens a pull request.
- Scheduleonce a week, or by hand
- Find lateststable release, image published
- Bump every pinone script, fails on drift
- Push and start CIon a predictable branch
- Open a PRyou review and merge
How it works
The script fails when the docs change
The bump script replaces exact strings in known places: the Compose default, the matrix entry, the test fallback, the badge, a couple of sentences in the docs. The important rule is that every replacement must match, or the script exits with an error.
replace() { # file, literal old text, literal new text
grep -qF -- "$2" "$1" || { echo "$1: '$2' not found" >&2; exit 1; }
FROM=$2 TO=$3 perl -pi -e 's/\Q$ENV{FROM}\E/$ENV{TO}/g' "$1"
}
replace docker-compose.yml "SERVER_VERSION:-$old}" "SERVER_VERSION:-$new}"
replace .github/workflows/ci.yml "server: [\"$old\", " "server: [\"$new\", "
replace README.md "against version $old and" "against version $new and"A search-and-replace that quietly skips a reworded sentence is how the docs drift again. Failing loudly turns "someone edited the README" into a red job, which is the only signal anyone notices. It also lets the script be precise. It changes "CI runs 1.4 and 1.2", but not the sentence that says a feature was checked against a live 1.4 node, which is history and should stay as it is.
I made the first bump by hand with this same script, so it was tested on real files before any automation depended on it.
"Latest" needs a definition
"The newest tag" is the wrong answer for most projects. Release candidates get pushed far more often than releases, and they can fill the first page of an image registry's tag list. My definition: the release the project marks as latest on its releases page, in plain major.minor form, and only once its container image actually exists. A release whose image is still building would just give a red CI run for no reason.
Two CI platform gotchas
Both of these are GitHub Actions behaviour, and both cost me a moment.
- Pushes made with the workflow's own token don't trigger other workflows. That's a deliberate guard against infinite loops. So the branch the job pushes would get no CI, and a PR without checks is useless. The exception is a manual dispatch: the job explicitly starts the CI workflow on its branch, and because the check results attach to the commit, they show up on the pull request.
- By default, Actions isn't allowed to open pull requests in a repository. It's a repository setting. I wrote the job to try to open a PR and, if that's refused, open an issue with a one-click link to create it. That way the job works either way.
Don't nag
The job pushes to a predictable branch name derived from the version. If that branch already exists, it does nothing. An open bump isn't opened twice. A version you decided to skip stays skipped while its branch stays around. Delete the branch and the job will offer that version again next week.
Trade-offs
- It only moves the newest tested version. The oldest supported version is a product decision, not a release event, so I still move it by hand.
- The list of pinned places is code you maintain. Add a new mention of the version and you have to teach the script about it. Failing on mismatches helps in one direction only: it catches places that changed, not new places it was never told about.
- A second bot would also work. Tools with regex-based custom matchers can do this without a script. I preferred one small script that I can run locally and read in one screen over a second dependency bot with its own config.
- It's weekly, not instant. For a test matrix that's fine. For a security patch to a server you actually run in production, you want something faster.
Takeaway
A version your dependency bot can't read is a version nobody owns. Give it one script that knows every place it lives and fails when any of them drifts, and a small weekly job that runs that script whenever there's something newer.