How to correctly compose Gitlab CI with turborepo? #13719
Replies: 2 comments 1 reply
|
Your second instinct is the right one: dependency graph lives in Roughly: variables:
GIT_DEPTH: 0 # important, see below
build:
script:
- pnpm install --frozen-lockfile
- pnpm turbo run lint build test --affected
GitLab shallow-clones with depth 20 by default, so without On the "no dependsOn because we use JIT" point: still declare The one thing that genuinely needs separate jobs is per-app env files or per-app deploy credentials. Do that with a normal job per app and deploy:web:
script: pnpm turbo run deploy --filter=web
environment: production-webHandful of static jobs, no pipeline generator to maintain. |
|
On your direct question — no, you can't get benefit #2 without a dynamic child pipeline, and that's a GitLab constraint rather than anything to do with turbo. A pipeline's job list is fixed when the pipeline is created, and What's worth changing is the division of labour, not the pipeline shape. The generator should only decide which apps, never what runs. Why the static
The generator input is that same JSON: generate:
stage: prepare
variables:
GIT_DEPTH: 0
TURBO_SCM_BASE: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
script:
- pnpm install --frozen-lockfile
- pnpm turbo ls --affected --output=json > affected.json
- node scripts/generate-pipeline.mjs affected.json > child.yml
artifacts:
paths: [child.yml]
run-apps:
stage: build
trigger:
include:
- artifact: child.yml
job: generate
strategy: depend
The thing that will actually cost you, given that you don't use the cache. One child pipeline per app means each child independently builds every shared package in its You don't need Vercel Remote Cache for this. Turbo's local filesystem cache carried through GitLab's own variables:
TURBO_CACHE_DIR: $CI_PROJECT_DIR/.turbo/cache
default:
cache:
key: turbo-$CI_COMMIT_REF_SLUG
fallback_keys:
- turbo-$CI_DEFAULT_BRANCH
paths:
- .turbo/cache
This is also the point where the Verified against turbo 2.10.11. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
Hi! I'm interesting with compose Gitlab CI with Turborepo, I don't understand how to do it correctly. We don't use Turborepo cache, so in my mind there is a conflict of what Turborepo must do and what need to do in CI/CD process. Currently there are some thoughts:
dependsOnoptions, because we use Just In Time compilation for dependenciesa) every app has own .gitlab-ci.yml
b) pipeline generator read
npx turbo ls --affectedoutput and generate pipeline for every app, that changedin this flow what is responsibility of Turborepo? okay, there is a
lintcommand in every app which one launcheslintprocess in app and it's dependencies, but what about other commands?in my mind it must works the next way:
but this behavior is unreachable, because gitlab-ci.yml can't create dynamic jobs with own settings like .env files and so on, so I can't see all picture, please, help me, give me some examples of turborepo integration with Gitlab
I must keep all deps inside turbo.json and keep gitlab-ci.yml simple where I just run turborepo tasks, or I should keep turbo.json simple and describe all commands inside gitlab-ci.yml?
Additional information
No response
Example
No response
All reactions