8

I'm working on a monorepo project that contains a few different subprojects in different languages. Right now I run three different CircleCI "jobs" on each commit. However, each of these packages compile and test themselves independently. Hence I don't actually have to spend time on running all three jobs every time.

Is there some way to condition a CircleCI job on which directory you committed code to?

Dan Cornilescu
  • 6,780
  • 2
  • 21
  • 45
langkilde
  • 345
  • 3
  • 9

3 Answers3

3

This discussion gives a pretty good suggestion on how to accomplish what I want.

https://discuss.circleci.com/t/does-circleci-2-0-work-with-monorepos/10378/11

langkilde
  • 345
  • 3
  • 9
2

We're using CircleCI with Go monorepo.

Here’s how it’s done:

  1. Define a job for each service in circle config yaml.
  2. A git push triggers CircleCI job that finds which services are part of the change.
  3. For each service run a CircleCI job with:
{
  "build_parameters": {
      "CIRCLE_JOB": "my-service"
  }
}

Also, published as an open source: https://github.com/Tufin/circleci-monorepo

0

I came here in addition of previous answer of @effi-bar-shean and @langkilde which give a good overview of the problem. My answer will be focus for JavaScript

How to build on part of monorepo that have changed ?

You can use the 2.0 API of CircleCI which allow you to trigger multiples workflow separately. If you have a JavaScript monorepo you can use a tool like lerna to trigger the workflow of your choice

Example: The output of lerna changed -a gives you all repository that have changed then you have to trigger the workflow of theses packages. You can see a full example here

Here is an example of repository for Javascript monorepo

I hope my answer help you

Julien Kode
  • 101
  • 2