CI/CD for developers · mid
Making a slow pipeline fast
Measure first: queue time, run time and the critical path. Then fix caching, split tests in parallel, reuse a prepared database and bake dependencies into a base image.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Measure: duration per job, queue time versus run time, and the critical path, from the CI tool's pipeline graph and analytics.
- Cache: GitLab caches only paths inside the project directory, so ~/.cache/pip is never saved. Set PIP_CACHE_DIR to a folder under $CI_PROJECT_DIR. Key the cache on the lock file, not the commit SHA.
- Autoscaled runners do not share disks, so use a shared cache (object storage). Or bake dependencies into a CI image rebuilt when the lock file changes.
- Run tests in parallel (pytest-xdist, or the CI tool's parallel keyword with tests split by past timings). Run independent jobs at the same time.
- Reuse a migrated test database or a template database instead of applying every migration for every test run.
- Only run what changed in a monorepo, and use a Docker layer cache or registry cache for image builds.
- Fail fast: lint and unit tests first. Run slow end-to-end tests after, or on main and nightly.
- Flaky tests destroy trust. Track and quarantine them, and fix them.
The red pen
Common traps: mistake → fix
Mistake: A faster runner fixes a slow pipeline
Fix: Waiting, missing caches and serial jobs are often the real cost.
Mistake: A cache key on the commit SHA is correct
Fix: It never hits. Key on the lock file.
Mistake: Retries hide flaky tests safely
Fix: They hide the problem and cost time. Fix or quarantine.
Easy to hard
Questions interviewers ask, easy to hard
- How do you start when a pipeline takes 40 minutes?
- Why is the pip cache never used on GitLab, and how do you fix it?
- How do you split tests across parallel jobs?
- How do you speed up Docker builds in CI?
- What do you do about flaky tests?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.