How to test Renovate configuration changes in GitLab CI
You’ve changed renovate.json
, but of course you want to test the change before
merging. There doesn’t seem to be a simple guide to this, so here’s what I’ve
cobbled together.
Prerequisites
- A working Renovate Runner setup, for example my repository. (The steps below assume a GitLab setup, but should work with minor modifications on other platforms.)
- A branch with a
renovate.json
file. For example, my first attempt atregexManagers
.
Journey
Feel free to skip this section if you’re only interested in the actual instructions.
Goals
Aside from testing the renovate.json
change before merging it, there are a few
other things which would be good to achieve:
- Minimal or no temporary changes to the
renovate.json
branch for testing purposes. Any changes introduced to the branch increases risk, for example in the form of accidentally merging the temporary changes, the changes breaking something else, or introducing an error when reverting the temporary changes after testing. - Minimal or no changes (permanent or temporary) to the Renovate Runner setup to enable testing. This improves the chances that the testing doesn’t interfere with normal operation.
- The test run should be as similar as possible to the normal GitLab CI runs as possible.
Challenges
- Renovate Runner by default only runs when triggered from a schedule.
- Running the test locally would be great, but I can’t easily replicate the GitLab CI setup exactly. Because of the risk of differences and the stronger test result of running it in GitLab CI I’ve chosen to only attempt running in GitLab CI.
- The behaviour I’m looking for in Renovate requires it to create a new branch and associated merge request for an already up-to-date dependency.
Steps
- Deactivate any existing Renovate Runner schedules, to avoid interference.
-
Create a new Renovate Runner schedule with the following settings:
- Any schedule.
0 0 1 1 0
, next combination of midnight, Sunday, January 1st, is probably rare enough not to cause any issues even if it’s accidentally activated. - Set the
RENOVATE_REPOSITORIES
variable, the qualified name of the repository you want to test. In case of the branch above this should be “engmark/mypy-exercises”. - Set the
RENOVATE_BASE_BRANCHES
variable to the name of the branch with the Renovate configuration change you want to test. In case of the branch above this should be “feat/enable-updating-readme-link”. - Disable auto-discovery, so that Renovate doesn’t ignore
RENOVATE_REPOSITORIES
, and use dry run mode to avoid actually creating any branches and merge requests. These can be set separately, but to avoid clutter we can set theRENOVATE_EXTRA_FLAGS
variable to “–autodiscover=false –dry-run=full”. - Make sure the schedule is deactivated, since this should only be run manually.
The resulting schedule should look a bit like this:
- Any schedule.
- Manually run the new schedule, and verify the output:
- Renovate ran on only the relevant repository and branch.
- Renovate used the new configuration as expected.
- Re-activate any Renovate Runner schedules deactivated in step 1.
If everything went as expected it should be safe to merge the renovate.json
change.
No webmentions were found.