DEV Community

Cover image for Dependency Automation with Renovate: Grouping and Auto-Merge Strategy
Mustafa ERBAY
Mustafa ERBAY

Posted on • Originally published at mustafaerbay.com.tr

Dependency Automation with Renovate: Grouping and Auto-Merge Strategy

In software projects, failing to keep third‑party libraries up to date leads to accumulating security vulnerabilities over time and to unmanageable breaking changes during version jumps. Renovate is an open‑source dependency‑automation tool that, unlike the default update bots provided by package managers, automatically manages dependencies in code repositories according to semantic versioning rules, custom scheduling windows, and flexible grouping rules.

Dependency‑update bots that run with the default configuration open a separate Pull Request (PR) for each new package version, causing PR fatigue in development teams. A Monday morning with 40 pending update requests can lead teams to close or ignore the notifications without reviewing them. Renovate eliminates this noise by grouping packages by function, auto‑merging patches that pass tests without manual code intervention, and using scheduling strategies.

In this guide we will walk through, step by step, how to set up a robust Renovate architecture that works with Node.js, Python, Docker, and Go projects and integrates fully with CI/CD pipelines.

The Dependency Update Problem and Renovate's Approach

Traditional dependency‑management tools typically scan manifest files (package.json, requirements.txt, go.mod, Dockerfile) individually and open a branch for each updatable package they find. In modern projects, dozens of sub‑libraries belonging to a framework are updated simultaneously. For example, in the React or Vue ecosystems, updating the core library at a different time than the router or state‑management tool can lead to version incompatibilities.

Renovate analyzes the project's dependency tree as a whole. It monitors not only direct dependencies but also the locked sub‑versions in lockfiles (package-lock.json, poetry.lock, pnpm-lock.yaml). Thanks to flexible AST (Abstract Syntax Tree) parsers and package‑matching rules, the notification‑creation step can be fully customized.

Diagram

Renovate's core operation relies on a configuration file in the code repository, either .github/renovate.json or renovate.json5. The bot periodically visits the repository, reads the configuration rules, and executes the necessary Git operations to reach the desired state.

ℹ️ Multi-Language Support

Renovate supports by default more than 90 package managers and notification types, including NPM, PyPI, Go Modules, Cargo, Composer, Dockerfile, Helm, Terraform, and GitHub Actions.

Basic Renovate Configuration: The renovate.json Basics

An effective Renovate setup starts with a renovate.json file placed in the project's root directory. The configuration architecture is based on inheriting ready‑made rule sets (extends) and defining project‑specific rules (packageRules) on top of them.

Ready‑made templates bring community‑accepted best practices into the project. However, the default config:recommended setting alone does not suppress PR noise. A schedule that aligns with the team's working hours and a semantic versioning strategy should be added.

{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "extends": [
    "config:recommended",
    ":preserveSemverRanges",
    ":rebaseStalePrs"
  ],
  "timezone": "Europe/Istanbul",
  "schedule": ["before 6am on Monday"],
  "prConcurrentLimit": 10,
  "prHourlyLimit": 2,
  "minimumReleaseAge": "3 days",
  "packageRules": [
    {
      "matchPackagePrefixes": ["@types/"],
      "automerge": true,
      "automergeType": "branch"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

In this configuration the critical parameters serve the following purposes:

  • timezone and schedule: Set the timing of update scans and PR creation to the team's off‑hours. A scan scheduled to run before 6 am on Monday provides ready PRs at the start of the week.
  • prConcurrentLimit: Limits the maximum number of PRs that can be open simultaneously. When this limit is exceeded, Renovate stops opening new PRs and waits for existing ones to close. The default is 10.
  • prHourlyLimit: Sets an hourly ceiling on PR creation to avoid hitting GitHub or GitLab API rate limits and to prevent overloading CI/CD runners. The default is 2.
  • minimumReleaseAge: Prevents a newly published package from being pulled into the project immediately. A three‑day wait provides a safety margin for the package maintainer to address a faulty release or for zero‑day security vulnerabilities to be discovered.

Reducing PR Noise: Package Grouping Strategies

The most effective way to reduce PR noise is to consolidate packages that are directly related or belong to the same risk category under a single PR. Without grouping, an ESLint or Babel ecosystem update can result in 15 separate PRs.

Renovate merges these packages into logical groups using the groupName property within the packageRules array. If any package in a group introduces a breaking change or fails tests, the CI status for the entire group appears as failed, preventing the faulty update from reaching the main branch.

{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "packageRules": [
    {
      "description": "Yama (patch) ve minör güncellemeleri tek bir grupta topla",
      "matchUpdateTypes": ["patch", "minor"],
      "groupName": "Tüm Minör ve Yama Güncellemeleri",
      "groupSlug": "minor-patch-all"
    },
    {
      "description": "React ekosistemini birleştir",
      "matchPackagePatterns": ["^react", "^@types/react"],
      "groupName": "React Ekosistemi"
    },
    {
      "description": "FastAPI ve Pydantic bağımlılıklarını birleştir",
      "matchPackageNames": ["fastapi", "pydantic", "pydantic-settings"],
      "groupName": "FastAPI Core"
    },
    {
      "description": "Docker imaj etiketlerini haftalık grupla",
      "matchManagers": ["dockerfile"],
      "groupName": "Docker Imaj Güncellemeleri"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Key considerations when grouping packages are:

  1. Ecosystem Integrity: Sub‑components of the same library (e.g., Vue, Vue Router, Pinia) must be placed under the same grouping rule.
  2. Update Type Separation: Patch updates should not be merged with Major updates. Major updates may contain API changes and should be reviewed as separate PRs.
  3. Pattern Matching: When using regex in matchPackagePatterns, keep the expressions narrow to avoid unintentionally including unrelated packages.

Secure Auto-Merge Architecture

In projects with comprehensive unit and integration test suites, having patch‑level updates go through human approval wastes time. Auto‑merge is the process where PRs that meet the defined criteria and pass CI tests are automatically merged into the main branch by the bot.

There are two main approaches to implementing auto‑merge: PR‑based auto‑merge and branch‑based auto‑merge. In branch‑based merging, Renovate creates a temporary branch without opening a PR, runs CI tests, and if they succeed, merges the branch directly into main. This keeps the Git history and PR list clean.

{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "packageRules": [
    {
      "description": "Geliştirme bağımlılıklarının (devDependencies) patch güncellemelerini otomatik birleştir",
      "matchDepTypes": ["devDependencies"],
      "matchUpdateTypes": ["patch"],
      "automerge": true,
      "automergeType": "branch",
      "requiredStatusChecks": ["build", "test"]
    },
    {
      "description": "Güvenlik yamalarını derhal auto-merge et",
      "matchIsVulnerabilityAlert": true,
      "automerge": true,
      "schedule": ["at any time"]
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Auto‑merge can be safely operated only when three core conditions are met:

Security Layer Requirement Description
CI Requirement requiredStatusChecks Merge will not occur unless the specified CI pipeline steps (e.g., unit-test, lint) are green.
Delay Period minimumReleaseAge Leaving at least 24–72 hours between package publication and merge allows faulty packages to be filtered out.
Scope Limit matchUpdateTypes Auto‑merge should be limited to patch updates or, in certain cases, minor versions.

⚠️ Security Warning

In projects with low test coverage, enabling automerge: true raises the risk of breaking changes or runtime exceptions reaching production. Ensure that critical flows are protected by tests before activating auto‑merge.

CI Pipeline Integration and Test Security

Renovate's reliable operation depends directly on the feedback provided by CI/CD pipelines. Automatic merging and PR approval mechanisms work in conjunction with the repository's branch protection rules and status checks.

In a GitHub Actions environment, Renovate can be run as a self‑hosted runner or as a GitHub Action workflow. Optional scheduled triggers (cron) can be used to let Renovate execute its own cycle.

name: Renovate Dependency Automation

on:
  schedule:
    - cron: '0 3 * * 1' # Her Pazartesi gece 03:00 UTC
  workflow_dispatch:

jobs:
  renovate:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v4

      - name: Run Renovate
        uses: renovatebot/github-action@v40.0.0
        with:
          configurationFile: .github/renovate.json
          token: ${{ secrets.RENOVATE_TOKEN }}
        env:
          LOG_LEVEL: info
Enter fullscreen mode Exit fullscreen mode

The critical aspect to watch in this CI integration is authorization. The secret defined as RENOVATE_TOKEN must have permissions on the repositories to open PRs, delete branches, and read status checks (via a fine‑grained Personal Access Token or a GitHub App).

When Renovate opens a PR, the main pipeline is triggered. If the main pipeline fails, Renovate adds a note to the PR description indicating that the tests have broken and cancels the auto‑merge.

# Example: Version verification and test run inside CI pipeline
import sys
import pkg_resources

def check_critical_dependencies():
    """Simple health check that validates compatibility of critical dependencies"""
    required_packages = ["fastapi", "pydantic", "sqlalchemy"]

    for package in required_packages:
        try:
            dist = pkg_resources.get_distribution(package)
            print(f"[OK] {dist.project_name} - Version: {dist.version}")
        except pkg_resources.DistributionNotFound:
            print(f"[ERROR] Critical package not found: {package}")
            sys.exit(1)

if __name__ == "__main__":
    check_critical_dependencies()
Enter fullscreen mode Exit fullscreen mode

Monorepo and Private Registry (Private NPM/PyPI) Management

With the rise of local package bundlers and monorepo architectures, dependencies are no longer fetched only from public package registries. Packages hosted on internal private NPM, PyPI, or Nexus/JFrog Artifactory servers also need to be scanned.

Renovate provides a hostRules structure for accessing private package registries. Authentication credentials should not be written directly in the JSON file; instead they should be supplied via environment variables or secret managers in the CI/CD environment.

{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "extends": ["config:recommended"],
  "hostRules": [
    {
      "matchHost": "https://npm.sirketiniz.com/",
      "hostType": "npm",
      "token": "{{ stringTemplate `${env.PRIVATE_NPM_TOKEN}` }}"
    },
    {
      "matchHost": "https://nexus.sirketiniz.com/repository/pypi-group/",
      "hostType": "pypi",
      "username": "renovate-bot",
      "password": "{{ stringTemplate `${env.NEXUS_PASSWORD}` }}"
    }
  ],
  "packageRules": [
    {
      "matchPackagePrefixes": ["@sirket-ici/"],
      "registryUrls": ["https://npm.sirketiniz.com/"]
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

In monorepo setups (e.g., projects using Nx, Turborepo, or Lerna) hundreds of packages and applications reside in the same repository. Renovate automatically detects lockfiles within the monorepo and updates both root‑level dependencies and those in sub‑packages simultaneously, preventing version drift inside the monorepo.

Edge Cases and Important Tips in Practice

The most common issues encountered after Renovate goes live are lockfile merge conflicts, API rate‑limit boundaries, and breaking changes in Major version upgrades.

Preventing Lockfile Conflicts

When multiple branches are open and a new PR lands on the main branch, lockfiles can become outdated. To have Renovate automatically resolve conflicts, configure the rebaseWhen parameter:

{
  "rebaseWhen": "behind-base-branch"
}
Enter fullscreen mode Exit fullscreen mode

The behind-base-branch setting causes Renovate to automatically rebase its PR whenever the target branch (main) is updated, and rerun tests against the updated code.

Major Version Upgrade Strategy

Major version updates can involve architectural changes. Rather than fully automating them, add checklists to the PR content and require manual review:

{
  "packageRules": [
    {
      "matchUpdateTypes": ["major"],
      "automerge": false,
      "labels": ["type: breaking-change", "needs-review"],
      "commitMessagePrefix": "chore(deps)!:"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

This rule ensures compliance with semantic commit conventions (chore(deps)!:) and notifies the team with breaking‑change labels when the PR is opened.

💡 Question Answer: Dependabot or Renovate?

Dependabot is simpler to set up, but it falls short when it comes to complex grouping, regex‑based package matching, and advanced auto‑merge rules. For teams that need flexibility and want to address PR noise at the architectural level, Renovate is the more capable option.

Conclusion

Dependency automation is a vital operational process that enhances a project's sustainability. However, uncontrolled automation tools can cause more PR noise and developer time loss than the benefits they provide.

When used with proper package grouping rules, time‑distributed scanning schedules, and auto‑merge strategies backed by a solid CI pipeline, Renovate turns dependency management into a reliable mechanism that works silently in the background.

It is recommended to roll out Renovate in your projects gradually:

  1. In the first phase, enable grouping and monitoring rules for patch versions and development libraries (devDependencies).
  2. After gaining confidence in your CI test coverage, activate the auto‑merge mechanism with a minimumReleaseAge safety margin.
  3. In the final phase, integrate private registries and monorepo setups to standardize all dependency management.

Official Resources

Top comments (0)