Skip to content

Instantly share code, notes, and snippets.

@HarHarLinks
Created June 16, 2025 09:20
Show Gist options
  • Save HarHarLinks/cdf24e0b74fa6274e8ead7c48ce0b04c to your computer and use it in GitHub Desktop.
Save HarHarLinks/cdf24e0b74fa6274e8ead7c48ce0b04c to your computer and use it in GitHub Desktop.
How to preview and debug renovate grouping
  1. install renovate cli https://docs.renovatebot.com/getting-started/running/#npm-package-cli
  2. run LOG_LEVEL=debug renovate --platform=local --dry-run=lookup --repository-cache=reset | tee renovate.txt (or similar)
  3. within renovate.txt, locate the detected updates
  4. extract the json object within the "config" key and save it as renovate.txt.json. e.g.
    `DEBUG: packageFiles with updates (repository=local)`
        "config": {
          "dockerfile": [
            {
              "deps": [
                {
    
    becomes
        {
          "dockerfile": [
            {
              "deps": [
                {
    
  5. run ./renovate.py (source below)
  6. the script has 2 ouputs
    1. a reduced but still rather verbose representation of the input json, formatted as yaml. this is ordered by a hierarchy of dependency type (e.g. npm) -> packageFile (e.g. package.json) -> depName (e.g. react) -> updates (e.g. major)
    2. an inverse hierarchy, formatted as yaml. It is ordered by branchName (e.g. renovate/major-react-dependencies, see how it encodes relevant info at https://docs.renovatebot.com/configuration-options/#branchtopic and https://docs.renovatebot.com/configuration-options/#groupslug) -> the depnames and updateTypes updated on this branch (e.g. react: major)

Limitations

Renovate might skip some packages when run locally. This will be shown in the first of the outputs by including skipReasons, including internal package and github-token-required, which I have not tried to figure out.

#!/usr/bin/env python
import json, yaml
by_branch = {}
def add_branch(branch, dep):
if branch not in by_branch:
by_branch[branch] = [dep]
else:
by_branch[branch].append(dep)
with open('renovate_test.txt.json', 'r') as file:
data = json.load(file)
output = {}
for depType, depTypeV in data.items():
# dockerfile
per_depType = []
for depTypeVL in depTypeV:
# dockerfile[]
deps = []
for dep in depTypeVL["deps"]:
# nginx
updates = []
for update in dep["updates"]:
u = {'updateType': update["updateType"], 'branchName': update["branchName"]}
updates.append(u)
add_branch(update["branchName"], f"{dep["depName"]}: {update["updateType"]}")
d = {'depName': dep["depName"]}
if len(updates) > 0:
d["updates"] = updates
if "skipReason" in dep:
d["skipReason"] = dep["skipReason"]
deps.append(d)
per_depType.append({'packageFile': depTypeVL["packageFile"], 'deps': deps})
output[depType] = per_depType
print(yaml.dump(output))
print(yaml.dump(by_branch))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment