A Continuous Integration Setup for Monorepo Projects

A Continuous Integration Setup for Monorepo Projects

Monorepo refers to the strategy of having all subprojects located in a single repository. By contrast, with polyrepo, each subproject has its own repository.

Setting Up Monorepo Was Hard… Until 2020

Monorepo refers to the strategy of having all subprojects located in a single repository. By contrast, with polyrepo, each subproject has its own repository.

Monorepo brings many benefits, including better collaboration and shared responsibilities. There are many interesting articles discussing the pros and cons of monorepo. One of my favorites is Monorepo: please do! by Adam Jacob.

Just a few years back, setting up a monorepo project was complicated due to the incompatibility of frameworks. For example, many package managers like NPM weren’t monorepo-friendly and infrastructures like Heroku make assumptions about the project’s root that do not hold true for monorepo projects.

Fortunately, tools and platforms have evolved so much that setting up monorepo projects has become much simpler.

CI for Monorepo Is Still Suboptimal

However, initiating an easy-to-use CI infrastructure for a monorepo project still requires a few tricks.

More specifically, unlike in a polyrepo project where the entire CI runs regardless of what the change is, in a monorepo project, always running the entire CI no matter which subproject is modified is time-consuming and hurts productivity.

For example, a monorepo project may contain a server and multiple clients (e.g. a mobile app, a website, and a CLI), and they all have their CI tasks. To maintain code health, projects often enforce CI checks to pass before merging changes, but it quickly becomes a burden when developers have to wait for all those tests to finish just to fix a typo in the documentation.

Note: It’s possible to approve trivial changes in a per-case manner, but that will require human attention.

It’s Possible to Fix It With a DIY Solution

For the example above, it would be great if we could dynamically define (based on the subprojects that are affected) a collection of CI tasks that are necessary to validate the code change and only run and check them for pull requests.

We can abstract the solution proposed above into two parts: running and checking CI tasks selectively.

Run CI tasks selectively

To selectively trigger CI tasks, we can use GitHub Actions’ path triggering (for more details, see Workflow Syntax for GitHub Actions).

GitHub Actions have a unique feature to let us specify triggering conditions, including file path.

continuous-integration software-development programming github devops

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Offshore Software Development - Best Practices

To make the most out of the benefits of offshore software development, you should understand the crucial factors that affect offshore development.

Hire Dedicated DevOps Developers

Hire our Dedicated DevOps Developers who have in-depth skills and expertise to develop an interactive and secure web application. Get custom DevOps solutions for your project.

Software Developer vs Software Engineer — Differences: Bogus or Real?

In this article, see if there are any differences between software developers and software engineers. What you’re about to read mostly revolves around my personal thoughts, deductions, and offbeat imagination. If you have different sentiments, add them in the comment section, and let’s dispute! So, today’s topic…

5 Core Criteria for Selecting Software Development Company - TopDevelopers.co

Check out these five criteria for the selection of your software vendor, and you will never regret having the wrong quality product made for you.

Hire DevOps Developer

Looking to hire top DevOps developers at affordable prices? **[Hire DevOps Developer](https://hourlydeveloper.io/hire-dedicated-devops-developer/ "Hire DevOps Developer")** from **[HourlyDeveloper.io](https://hourlydeveloper.io/...