An example monorepo pipeline in CircleCI with Go services.
- The
gatekeeper
workflow consists of a singlegatekeeper
job that runs by default on all commits and other triggers.- Inside the
gatekeeper
, we are scanning for which folders have changed and then making an API call using our v2 API to trigger the pipeline. - When making the API trigger, we must specify parameters to set
gatekeeper
tofalse
so that it doesn't retrigger the same workflow in a loop, and only trigger the desired service workflow(s).
- Inside the
- The API call triggers another workflow,
service
, which will have jobs that run specifically for said service(s). The name of the service is passed as a parameter in the API call.
- This only works if each service in the monorepo follows the same steps / process (e.g. whatever is in
service
job). If different services require different tasks and steps, then you'd need to define different jobs and corresponding workflows for them. - This project assumes the project names match the folder names. If not, then you'll need to account for that in your config.
- We're using built-in pipeline parameters to compare current commit to previous commit. Ideal is to compare against last commit built on CircleCI, not just the last commit in the log (since multiple commits can be pushed, and only latest one is built).
- Script in
gatekeeper
job does not cover the scenario where a branch does not have a previous commit. I believe that will break. - Need to implement comparing tags