Renovate Bot - Handling multiple projects and their dependencies

 



Continuing with the use of Renovate, now I will tell you how to configure Renovate Bot to use it with several projects when there are dependencies between them.

This tool has a very simple solution for us when you have many projects and dependencies between them.

Example:

Project1 depends on Project2 and this in turn depends on Project3. P3 is your domain model, a change there can impact Project1 and Project2. And you want to generate the PRs and automatically merge to Project2 and Project1 respectively so you don't have to do it manually.

Of course, the automatic merge is only for minor or patch versions; for major versions, it should be manual.

Quadim

In Quadim we are using Renovate to manage our dependencies between microservices.



We can enable Renovate as we learned in the first article, but this will only inform us of changes in public libraries and for private libraries only generate a PR (Pull Request) but you will have to do the merge manually.


The problem

The issue is that we constantly generate minor or patch versions and approving the PR that Renovate generates manually is very operational. So then I bring you the recipe to no longer have that pain.

The solution

We can create a repository to centralize Renovate configuration and from which other projects can inherit.



And this in turn could inherit from another Renovate configuration repository. Just as we inherit from classes, here we inherit configurations from other projects.

Step 1: Create your central configuration

You only need to create a default.json in your Quadim-Renovate-Config for example:

{
"extends": [
"local>cantara/Cantara-Renovate-Config"
],
"labels": [
"renovate"
],
"packageRules": [
{
"updateTypes": ["minor", "patch", "digest"],
"matchPackagePatterns": [
"^ai.quadim.api:quadim",
"^github.com/aws/aws-sdk-go",
"^com.fasterxml.jackson.dataformat:jackson*",
"^com.fasterxml.jackson.datatype:jackson*",
"^com.fasterxml.jackson.module:jackson",
"^com.fasterxml.jackson.core:jackson-*",
"^org.projectlombok:lombok*",
"^com.slack.api:slack-api-client*",
"^net.whydah.sso:Whydah-*",
"^ch.qos.logback:logback-classic*",
"^com.amazonaws:aws-*"
],
"automerge": true,
"ignoreTests": true
}
]
}

The explanation is very simple:

1. We extend another Renovate Config of another GitHub account. More details are in Appendix A.

2. We label it as Renovate (used in the Pull Request)

3. Package Rules - Here are configure that packages should be considered for auto-merge = true. The recommendation is only for "minor", "patch" and "digest". Major versions should be merged manually.


In our case, the private libraries are in the:

^ai.quadim.api:quadim, ^net.whydah.sso:Whydah-*

Thanks to these lines, our projects that have dependencies will auto-merge automatically. Cool.


             

Step 2: Each project must extend of "Renovate central config " 


This part is the most simple, you only need to aggregate in your renovate.json of each project its configuration and the magic will be available. 



We are extending of Quadim-Renovate-Config:

{
"extends": [
"local>quadimai/Quadim-Renovate-Config"
]
}


The same for the other projects.

Step 3: Wait some minutes and receive one PR 

Wait a few minutes and you will receive your PR, but this time it will be auto-merged automatically.

Super Cool!!.






Appendix A

In the lines above, we were using https://github.com/Cantara/Cantara-Renovate-Config/ to create a network of renovate config between different accounts. 

It is your configuration:

{
"extends": [
"config:base"
],
"labels": [
"renovate"
],
"packageRules": [
{
"updateTypes": ["minor", "patch", "digest"],
"matchPackagePatterns": [
"^org.apache.maven.plugins:maven*",
"io.swagger.core.v3:swagger*",
"io.rest-assured:rest*",
"^github.com/aws/aws-sdk-go",
"^github.com/cantara/bragi*",
"^github.com/cantara/gober*",
"^org.slf4j:slf4j*",
"^org.slf4j:jcl*",
"^org.slf4j:jul*",
"^com.google.cloud:google-cloud*",
"^com.google.code.gson:gson*",
"^com.amazonaws:aws-*",
"^software.amazon.awssdk:ses",
"^software.amazon.awssdk:bom",
"^com.amazonaws:aws-java-sdk-dynamodb",
"^com.fasterxml.jackson.dataformat:jackson*",
"^com.fasterxml.jackson.datatype:jackson*",
"^com.fasterxml.jackson.module:jackson",
"^com.fasterxml.jackson.core:jackson-*",
"^com.fasterxml.jackson:jackson*",
"^com.google.protobuf:protobuf*",
"^org.postgresql:postgresql*",
"^org.flywaydb:flyway*",
"^com.slack.api:slack-api-client*",
"^net.whydah.sso:Whydah-*",
"^no.cantara.jau:configservice*",
"^org.valuereporter:valuereporter*",
"^no.cantara.config:property-config",
"^github.com/cantara/nerthus*",
"^no.cantara.messi:messi-*",
"^no.cantara.base:Hystrix-*",
"^no.cantara.base:Resilience4j-*",
"^no.cantara.stingray:stingray*",
"^org.mockito:mockito*",
"^org.assertj:assertj*",
"^org.junit.jupiter:junit*",
"^com.exoreaction.xorcery:xorcery*"
],
"automerge": true,
"ignoreTests": true
}
]
}


That's all. Enjoy!

Congratulations to the guys of Renovate. Amazing tool.

Joe


Share: