On the 15th and 16th of April CITCON Europe took place in Cluj-Napoca (Transylvania). CITCON is an open spaces conference. The agenda is made up by the people attending the conference. Because of this there are always a couple of nice takeaways. This year Ivan Moore (@ivanrmoore) made a claim that you can not do CI without using monorepos. A monorepo is simply one repository where all source code ends up. This is contrary to a setup with (for example) Git source control where you have a single repository per module. The idea of having a single (big) repository with all code seems strange. After some thorough discussion the merits of monorepos were clear to me.
Consider a scenario with 2 services which depend on a module with some common/shared code. Each service has to manage the version of the common module itself – hence the latest changes made to the common module are not integrated with the services. Now you bump the version of the common module.

- Develop some generic functionality in service 1
- Once it works for service 1, move the code to the common repo
- Build release the repo
- Update the version of the common module in service 1
- Eventually, update the version of the common module in service 2
- The repository can become quite large. This only slows down the initial checkout [1]. It would probably take more time to check out a bunch of repo’s, though.
- Will the repository get slow? Well, the Linux kernel is maintained in one repo. By the time your code base is that many lines of code (currently about 17M), you can decide if it’s useful to split up the code base or invest in tooling.
- Everybody can change all code. Of course! That’s why you have source control to start with. The important thing is that you can track the code changes and see who made them.
- Everybody is pushing all the code to one repo, hence you’ll have to update/pull/rebase all the time. In practice this does not prove to be a real problem: if you’re using pull requests, the number of commits on the master branch are not that big. If you’re doing trunk based development ( ) you’re integrating everything all the time. There is no overlap between code committed for service 1 and service 2, i.e. no merge conflicts.
- You’ll have to set up your CI builds in a smart way, so that not everything is built on every commit. Modern build tools can deal with that. If not, you’ll have to write a script to perform that task, which is not a problem, since it will be committed in the same repository and therefore is always up to date with the rest of the code.

Arjan Molenaar
Contact