Deterministic GitLab Dynamic Child Pipelines for Polyglot Monorepos
rules:changes path filters silently miss transitive dependencies across Python, Rust, TypeScript, Go, and Nix packages. Replacing static YAML with a 15-line GitLab trigger:include:artifact parent pipeline that resolves your real dependency graph cut our self-hosted GitLab CE UI merge request from 2m 59s to 30s (7.1x less runner compute) while keeping the full suite mandatory on default branches and tags.
Why GitLab rules:changes fails in monorepos
Almost every growing monorepo starts with hand-written rules:changes: globs in .gitlab-ci.yml. It works for three services and breaks quietly at ten:
- Transitive dependency blind spots: Editing
libs/proto/schema.pybreaksservices/apiandservices/worker, even though no file underservices/changed. Either engineers maintain fragile duplicated path lists by hand or they give up and run every job on every push. - Coding agents amplify the waste: When Claude Code or Cursor pushes 5 to 10 iterative fix commits per MR, re-running cold Nix, Rust, and integration test stages for a 2-line UI or formatting tweak saturates self-hosted runner fleets.
- Late-stage failure feedback: Putting
lintorformatin the final stage makes developers wait for full build and integration suites just to learn a trailing comma failed formatting at minute 2:49.
How GitLab Dynamic Child Pipelines work
GitLab natively supports generating a child pipeline YAML file at runtime via artifacts:paths and executing it with trigger:include:artifact. Your existing runners, Docker images, caches, and job scripts stay unchanged.
stages: [plan, run]
wake-plan:
stage: plan
image: ghcr.io/strange-metal/wake:latest
script:
- wake plan --ci-file .wake-pipeline.yml --post-comment --out wake-generated-ci.yml
artifacts:
paths:
- wake-generated-ci.yml
wake-child:
stage: run
trigger:
include:
- artifact: wake-generated-ci.yml
job: wake-plan
strategy: depend
In wake-plan, Wake parses your workspace manifests (pyproject.toml, package.json, Cargo.toml, go.mod, flake.nix, callPackage, and optional .wake.yml custom edges), computes the transitive reverse-dependency closure of changed files, promotes fast linters to parallel stage 0, injects explicit needs: DAG edges, and writes wake-generated-ci.yml.
Three self-hosted GitLab Runner pitfalls you must handle
- Never trust
CI_COMMIT_BEFORE_SHAon feature branches: On a branch's first push, GitLab setsCI_COMMIT_BEFORE_SHAto 40 zeroes. On a force-push after rebase, it points to an unreachable commit that breaksgit diff. Always force-fetchorigin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME(orCI_DEFAULT_BRANCH) and diff againstgit merge-base. - Docker executor cached
.gitvolumes go stale: Self-hosted runners with persistent build caches often hold outdatedrefs/remotes/origin/develop. Explicitly rungit fetch --no-tags --depth=50 origin +refs/heads/$TARGET:refs/remotes/origin/$TARGETinside the planner job. - Always keep a deterministic full-suite safety net: Any edit to root lockfiles, shared CI templates, or pushes to
develop/mainand release tags must automatically bypass pruning and run 100% of jobs.
Measured results on self-hosted GitLab CE
| Scenario | Jobs run | Wall-clock | Compute | Result |
|---|---|---|---|---|
| Static YAML (cold cache) | 9 / 9 | 2m 59s | 4m 32s | Failed at 2:49 on formatting |
| Static YAML (warm cache) | 9 / 9 | 1m 23s | 2m 40s | UI edit rebuilt backend + Nix |
| Wake stage-0 fast-fail | 1 / 9 | 21s | 21s | 4.0x faster feedback |
| Wake dynamic child pipeline (UI MR) | 3 / 9 | 30s | 38.3s | 7.1x less compute |
Profile your own GitLab pipeline with zero code egress
Inspect our live monorepo X-Ray flamegraph or run Wake's offline container inside your own GitLab Runner network to see exactly how many minutes dynamic child pipelines can cut.
Request a 15-minute X-Ray audit