0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-11-05 00:27:05 +00:00
renovatebot_renovate/docs/usage/config-validation.md
Róbert Papp eadca27384
docs(validator): Recommend npx to run validator (#26628)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-02-18 15:56:24 +00:00

3.1 KiB

title description
Config Validation How to validate Renovate's configuration.

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_FILE environment variable

For example:

$ npx --yes --package renovate -- renovate-config-validator
 INFO: Validating renovate.json
 INFO: Config validated successfully

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

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:

  1. Create a new Git branch that matches the {{branchPrefix}}reconfigure pattern. For example, if you're using the default prefix renovate/, your branch name must be renovate/reconfigure.
  2. 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:

  1. Search for a branch that matches the special reconfigure pattern.
  2. 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).
  3. Add a passing or failing status to the branch, depending on the outcome of the config validation run.
  4. If there's an open pull request with validation errors from the reconfigure branch then Renovate comments in the PR with details.
  5. Validate each commit the next time Renovate runs on the repository, until the PR is merged.