A single Renovate PR is merged in no time, but the first run in an existing project brings 21 updates at once, and every merge leaves the remaining PRs behind main. Their green CI then applies to an outdated state, and with a daily cron, Renovate only rebases them up to 24 hours later. Grouping, a rebase whenever a branch falls behind, and a make target that merges and triggers Renovate again bring this down to a few minutes per PR.
The changes are spread across both repositories:
renovate.jsonin the project: grouping and rebase behaviorMakefilein the project: themake renovatetarget.woodpecker/renovate.yamlinrenovate-config: an overridable autodiscover filter
The first run#
In the project from part 2
, the first run created 10 branches but only 5 PRs. Codeberg throttles similarly named PRs per account and answered the rest with HTTP 429; titles like chore(deps): update dependency X to vY count as similar. The Dependency Dashboard lists these updates under “Errored”, and later runs create the missing PRs. Another 11 updates were listed under “Rate-Limited”, as prConcurrentLimit allows 10 open PRs per repository by default.
Grouping#
In the project’s renovate.json, group:allNonMajor bundles all minor and patch updates into one PR, leaving only major versions as separate PRs:
{
"extends": ["local><owner>/renovate-config", "group:allNonMajor"]
}After that, at most 7 PRs were open at the same time: the bundle and 6 major versions. Renovate closes the old individual PRs itself on the next run.
Rebasing behind main#
All npm PRs touch the same yarn.lock, so after each merge the others have a conflict. With rebaseWhen: behind-base-branch in the project’s renovate.json, Renovate rebases every PR that is behind main and regenerates yarn.lock in the process:
{
"rebaseWhen": "behind-base-branch"
}Every change on main then triggers a rebase of all open Renovate PRs, each with its own CI run. Rebasing manually ends Renovate’s maintenance of the branch, as Renovate leaves branches with a foreign committer alone. The rebase checkbox in the PR or in the dashboard triggers a rebase instead.
Running Renovate for one repository#
The rebase happens on the next Renovate run. To keep that run from covering every repository, the autodiscover filter in renovate-config/.woodpecker/renovate.yaml can be overridden:
steps:
- name: renovate
environment:
RENOVATE_AUTODISCOVER_FILTER: ${RENOVATE_AUTODISCOVER_FILTER=<owner>/*}The cron keeps covering all repositories, while a manual run with the variable RENOVATE_AUTODISCOVER_FILTER=<owner>/<repo> covers just one. The Woodpecker API does the same without the web UI:
curl -fsS -X POST https://ci.codeberg.org/api/repos/<repo-id>/pipelines \
-H "Authorization: Bearer $WOODPECKER_TOKEN" -H "Content-Type: application/json" \
-d '{"branch":"main","workflow":"renovate","variables":{"RENOVATE_AUTODISCOVER_FILTER":"<owner>/<repo>"}}'<repo-id> is the Woodpecker ID of renovate-config. The endpoint requires push access to that repository; the token is available in the user settings on ci.codeberg.org. A run for one repository takes about a minute.
Merging locally with make renovate#
Codeberg doesn’t sign merges made through the web UI, so signed merge commits can only be created locally. The next part of the series covers this in detail. Codeberg can’t block a pushed merge, so the CI gate lives in the project’s Makefile. The full implementation of make renovate is in the Makefile of vegane-brezn.de
and can be copied into other projects; what needs adjusting is renovate_api, the Woodpecker ID of renovate-config, the repository name in the filter, and yarn install for the respective lockfile.
make renovate lists open Renovate PRs with their CI status and how far they are behind main. The target reads the status through the Forgejo API for exactly the commit that would be merged:
state=$(curl -fsS "$api/commits/$sha/status" \
| jq -r 'if (.state // "") == "" then "none" else .state end')
behind=$(curl -fsS "$api/compare/$sha...main" | jq -r '.total_commits')make renovate PR=n only merges if the status is success, the branch is not behind main, and it hasn’t moved since the CI run. The status combines all checks on the commit, so a pending renovate/stability-days from the waiting period for new releases
blocks the merge as well. It then pushes main and uses the curl call from above to start a Renovate run for exactly this repository. Codeberg detects the merge and marks the PR as merged, and within a few minutes the remaining PRs are rebased and tested again. Merges stay sequential: merge, Renovate run, green CI, next merge.
A no-commit-to-branch hook in the project’s .pre-commit-config.yaml needs stages: [pre-commit] for this; otherwise it runs as a pre-push hook and blocks the push of the merge to main.
Checking major versions before merging#
For runtime libraries, green CI doesn’t cover everything. For postgres v3 to v4, I compared the breaking changes from the release notes against the code, then ran the migrations and the actual queries against a throwaway database with both versions. The output of 3.4.9 and 4.1.1 was identical, something unit tests without a database would not have shown.
Found this helpful?
Consider supporting via:
