I am trying to setup a monorepo with GitLab CI/CD. I want to define the jobs for each sub project under that project and not on the root gitlab-ci.yml
file. So right now I have:
cache:
key: $CI_COMMIT_REF_SLUG
paths:
- infrastructure/node_modules/
- infrastructure/dist/
- frontend/node_modules/
- frontend/dist/
include:
- local: '/infrastructure/infrastructure.gitlab-ci.yml'
rules:
- changes:
- 'infrastructure/*'
- local: '/frontend/frontend.gitlab-ci.yml'
rules:
- changes:
- 'frontend/*'
Originally the cache was also moved to each folder, but I was also trying with moving just the cache to the root gitlab-ci.yml.
The problem that I'm facing right now is that if only 1 sub-pipeline runs, everything works properly, but if both running together, because I have changes in both folders, only the frontend pipelines are running properly, however the infrastructure caching is not working.
When only infra pipeline is running, it works fine, so I have the node_modules shared between the jobs.