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?

  • We ultimately solved this by building all of our subprojects (across 3+ languages) via a single build tool - in our case it was Gradle. At that point, we were able to leverage the Gradle build cache (ultimately caching that in CircleCI's build cache!) to skip unnecessary subproject builds. Happy to write this up as an answer if it would be useful. – Oliver Charlesworth Nov 19 '17 at 10:30
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

| improve this answer | |
  • 2
    It would be nice to include at a short summary of the approaches discussed - link only answers are always at risk of losing all their value if the link breaks for whatever reason. – Dan Cornilescu Nov 16 '17 at 1:14
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

| improve this answer | |
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 😊

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.