user3411562
user3411562

Reputation: 31

what is the best branching model for monorepo inorder to implement CI/CD pipeline till production

I have springboot monorepo with almost 5 libraries & 5 services,

I have used trunkbased model(master & release) for this repo inorder to implement Continous Delivery

The following builds are configured on master branch

CI Build Build the artifact whatever changed - -> QualityCheck > artifact(.jar) -> Deploy to Development Env

Nightly build Build all libraries & services -> QualityCheck -> Deploy all jar's into QA environment

Once we are ready to release, we will create a release branch from master

Again for release branch I am running the release build with the steps same as in Nightly build.

Release build Build all libraries & services -> QualityCheck -> Deploy all jar's into PROD environment

The Concerns that I have is

  1. Is this right branching model for monorepo to achive continious delivery in PRODUCTION ENV?
  2. The Nightly build is taking long time almost two hours to complete deployments of all services into QA ENV, not sure why I am deploying all services into QA even there is no changes?
  3. For relase branch why again I need to run all the build steps same as nightly build since its taking long time, is there anyways to deploy production fastly?

Upvotes: 3

Views: 4420

Answers (1)

Stanislav Bashkyrtsev
Stanislav Bashkyrtsev

Reputation: 15318

First you need to get rid of Nightly builds. You run them because it takes too long to run the whole thing per commit - that's the part that you need to optimize. In order to speed up your build & deploy you need to work only with the affected service(s):

  • Either split the repo into individual projects - a repo per release cycle. Meaning - if 2 services are always deployed & released together - they can be stored in the same repository. Otherwise - split them up into different repos. Some form of integration testing will probably be required - to check e.g. that ServiceA_v20 works fine with ServiceB_v33.
  • Or write custom scripts that determine which part of the project changed. So if ServiceA changed - you need to automatically determine which tests & checks need to be run - then run only that part. This isn't easy because of the dependencies: if ServiceB depends on ServiceA and the latter changes - you need to somehow determine that tests for both ServiceA and ServiceB need to be run. You may want to check videos from Google that talk about monorepos and how they build the graph of dependencies.

But no matter which approach you choose - the best way to keep all the integration in a working state is a) not to change the API too frequently b) to make changes backward compatible for some time.

As for branching.. You don't have to create release branches and build them. If you pushed to master and that binary passed all the checks - that exact binary should be deployed to PRD.

Upvotes: 2

Related Questions