DEV Community

K@zuki.
K@zuki.

Posted on • Updated on

Debugging Renovate locally

Introduction

If you are using Renovate, it is important to check whether the settings are properly configured.

This article explains how to debug Renovate in a local environment.

Prerequisites

The following prerequisites are required:

  • Generate GitHub's Classic PAT and set it in the environment variable such as GITHUB_TOKEN.
    • If it's only dry-run, read permission to the repository should be sufficient.

Verification Procedure

Just execute the following command:

RENOVATE_CONFIG_FILE=.github/renovate.json5 \
  npx renovate \
    --token=$GITHUB_TOKEN \
    --schedule="" \
    --require-config=ignored \
    --dry-run=full \
    corrupt952/home-apps
Enter fullscreen mode Exit fullscreen mode

You can check whether the target is correct and whether a PR is created by using stats or messages displayed in DRY-RUN.

$ RENOVATE_CONFIG_FILE=.github/renovate.json5 \
    npx renovate \
      --token=$GITHUB_TOKEN \
      --schedule="" \
      --require-config=ignored \
      --dry-run=full \
      corrupt952/home-apps
 INFO: Repository started (repository=corrupt952/home-apps)
       "renovateVersion": "35.71.5"
 INFO: Dependency extraction complete (repository=corrupt952/home-apps, baseBranch=main)
       "stats": {
         "managers": {
           "argocd": {"fileCount": 5, "depCount": 6},
           "kubernetes": {"fileCount": 1, "depCount": 2},
           "regex": {"fileCount": 5, "depCount": 15}
         },
         "total": {"fileCount": 11, "depCount": 23}
       }
 INFO: DRY-RUN: Would ensure Dependency Dashboard (repository=corrupt952/home-apps)
       "title": "Dependency Dashboard"
 INFO: DRY-RUN: Would save repository cache. (repository=corrupt952/home-apps)
 INFO: Repository finished (repository=corrupt952/home-apps)
       "cloned": true,
       "durationMs": 6888
Enter fullscreen mode Exit fullscreen mode

Brief explanation of the command

The following is an explanation of the command mentioned in the verification procedure:

  • RENOVATE_CONFIG_FILE=.github/renovate.json5
    • Specifies the path of the configuration file you want to test the operation of.
    • The configuration file contains the information necessary for Renovate to operate.
    • For details, refer to the official Renovate documentation.
  • npx renovate
    • Since you want to try renovate easily without installing it individually, you are running renovate using npx.
  • token=$GITHUB_TOKEN
    • Specifies the PAT generated in advance.
    • PAT is necessary for Renovate to access the GitHub API.
    • For details, refer to the official Renovate documentation.
  • schedule=""
    • Since it may not be executed if the schedule is defined in the settings, an empty string is specified.
  • require-config=ignored
    • Prevents the remote repository's configuration file from being read.
    • If the remote repository's configuration file is read, it will be merged with the local configuration file, which may result in unnecessary PRs being generated.
    • For details, refer to the official Renovate documentation.
  • dry-run=full
  • corrupt952/home-apps
    • Specifies the repository targeted by Renovate.
    • In this example, corrupt952/home-apps is targeted.

Other cases that are likely to occur when verifying the operation

I want to validate a branch other than the default branch.

Execute by specifying RENOVATE_BASE_BRANCHES.

# In the case of targeting the dev branch
RENOVATE_BASE_BRANCHES=dev \
RENOVATE_CONFIG_FILE=.github/renovate.json5 \
  npx renovate \
    --token=$GITHUB_TOKEN \
    --schedule="" \
    --require-config=ignored \
    --dry-run=full \
    corrupt952/home-apps
Enter fullscreen mode Exit fullscreen mode

I want to create a PR.

Confirm that PAT has write permission to the repository and remove the --dry-run option.

RENOVATE_CONFIG_FILE=.github/renovate.json5 \
  npx renovate \
    --token=$GITHUB_TOKEN \
    --schedule="" \
    --require-config=ignored \
    corrupt952/home-apps
Enter fullscreen mode Exit fullscreen mode

Conclusion

This article explained how to debug Renovate locally.

If you are using Renovate, it is important to check whether the settings are properly configured.

Please execute the procedure explained in this article to use Renovate normally.

Top comments (0)