DEV Community

Cover image for Fast CI/CD for Monorepos
Sibelius Seraphini for Woovi

Posted on

Fast CI/CD for Monorepos

Monorepo brings a lot of benefits such as code sharing, simple dependency managing and easy to apply changes to many services at once.
However, it can also make your CI/CD slow if you always test and build every package and service.

Conditional build

Conditional build is the technique where you check what files changed to determine what jobs and workflows you should or should not run on your CI/CD.

CircleCI provides an orb, like a package, that tells if a given path changed from the last workflow. You can define it in a config.yml file

version: 2.1
setup: true
orbs:
  path-filtering: circleci/path-filtering@0.0.2

workflows:
  setup:
    jobs:
      - path-filtering/filter:
          base-revision: main
          mapping: |
            packages/account/.* account-modified true
            packages/ledger/.*  ledger-modified true
            packages/card/.*    card-modified true
Enter fullscreen mode Exit fullscreen mode

Then, you can use this variables in the main workflow, like this:

deploy_staging_ledger:
    steps:
      - when: << pipeline.parameters.ledger-modified >>          
Enter fullscreen mode Exit fullscreen mode

deploy_staging_ledger will only run when ledger package was modified.

In Conclusion

As you scale, you need to find a more optimized way to make your process more efficient.
Testing and building only packages and services affected by code changes reduces the cost and time to production.


What optimizations are you doing in your Startup?


References

Reducing testing and building time in Monorepos
Woovi CI/CD Talk


Woovi
Woovi is a Startup that enables shoppers to pay as they like. To make this possible, Woovi provides instant payment solutions for merchants to accept orders.

If you want to work with us, we are hiring!

Top comments (0)