Config Validation¶
You can check your Renovate configuration with a standalone program called renovate-config-validator.
All renovate distributions include this program.
Default behavior¶
When you run renovate-config-validator with no arguments it will check:
- all default locations (if files exist)
- the
RENOVATE_CONFIG_FILEenvironment variable
For example:
$ npx --yes --package renovate -- renovate-config-validator
INFO: Validating renovate.json
INFO: Config validated successfully
If you want to run renovate-config-validator while using a custom filename for your renovate config file, you will need to pass the filename as cli argument.
Strict mode¶
By default, the validator program fails with a non-zero exit code if there are any validation warnings or errors.
You can pass the --strict flag to make it fail if a scanned config needs migration:
$ npx --yes --package renovate -- renovate-config-validator --strict
INFO: Validating renovate.json
WARN: Config migration necessary
"oldConfig": {
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [ "config:base" ]
},
"newConfig": {
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [ "config:recommended" ]
},
Pass file to check as CLI arguments¶
You can pass the file you want to check to the renovate-config-validator program with a CLI argument.
This can be handy to check a config file with a non-default name, like when you're using preset repositories.
For example:
$ npx --yes --package renovate -- renovate-config-validator first_config.json
INFO: Validating first_config_.json
INFO: Config validated successfully
Note
If you specify the filename, renovate-config-validator treats the file(s) as global self-hosted configuration instead of repo-level configuration.
If this isn't intentional - for instance if you're validating a shared config preset or a non-standard filename - make sure you specify --no-global, i.e. renovate-config-validator --no-global go-presets.json.
Providing global configuration¶
If renovate-config-validator detects a config.js, or any global self-hosed environment variables, they will be set as global configuration.
For instance, if you had a config.js:
module.exports = {
// to mirror the Mend-hosted Renovate
globalExtends: ['global:safeEnv'],
};
And a renovate.json:
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"env": {
"GONOSUMDB": "off"
}
}
The renovate-config-validator would allow this to pass.
Validate your config automatically¶
You can create a pre-commit hook to validate your configuration automatically.
Go to the renovatebot/pre-commit-hooks repository for more information.
Validation of Renovate config change PRs¶
Renovate can validate configuration changes in Pull Requests when you use a special branch name.
Follow these steps to validate your configuration:
- Create a new Git branch that matches the
{{branchPrefix}}reconfigurepattern. For example, if you're using the default prefixrenovate/, your branch name must berenovate/reconfigure. - Commit your updated Renovate config file to this branch, and push it to your Git hosting platform.
The next time Renovate runs on that repo it will:
- Search for a branch that matches the special reconfigure pattern.
- Check for a config file in the reconfigure branch. Renovate can even find a renamed configuration file (compared to the config file in the default branch).
- Add a passing or failing status to the branch, depending on the outcome of the config validation run.
- If there's an open pull request with validation errors from the reconfigure branch then Renovate comments in the PR with details.
- Validate each commit the next time Renovate runs on the repository, until the PR is merged.
Note
The reconfigure branch must be pushed to the source repository that Renovate runs against, not a fork.