How to Decide Which Tests to Run for Changed Features in a CI/CD Pipeline?

December 11, 2025 4 answers
Asked by if memory serves
I'm working on a CI/CD setup and I've hit a bit of a wall. My repo has numerous features, and when someone enhances just one of them and creates a pull request (PR), I'm unsure if I should run tests for all features or just for the ones that were modified. For instance, I have two scripts, 'script/register_model_a' and 'script/register_model_b', which log metrics and create new model versions in MLFlow. What's the best practice here? Should I set up a folder structure based on each module to detect file changes and decide which feature needs testing, or is it safer to run all tests every time? Thanks for any advice!

Answers

foxtrot
The easiest route is just to run all tests. If features are truly isolated, you could invest the time to only trigger tests based on what has changed, but that usually pays off only when it becomes cumbersome.

forgotten password clue: I agree! Plus, since theyโ€™re working on features within the same repo, it might be risky to rely entirely on individual tests. Running everything gives a comprehensive safety net.

Reply to this answer
Saffron Saturday
You're on the right track! Most teams encounter this issue as their codebase grows. A good solution is to use folder-level ownership and diff-based triggers. Segment each feature into its own module, then check what paths changed in the PR to run the appropriate scripts. Most CI tools can handle this well. However, I suggest doing full runs for main/release branches and only selective runs for PRs to balance speed and safetyโ€”this helps avoid lengthy run times, especially with heavy ML tasks.
Reply to this answer
tcp.window64
TL;DR: Run everything every time! Your CI pipeline should have jobs that ideally finish in about 20 minutes for merges or PRs. For example, run as many code scanners as possible in parallel after building. Your integration and system tests should also be parallelized; avoid making tests depend on each other, as this can slow things down. I once optimized a test pack from 30 hours down to just 40 minutes after a lot of tweaks!
Reply to this answer
+darning needle~
For MLFlow, donโ€™t register a new model version on every PR commit. Instead, you can log the metrics on the PR and skip registration. Only do that on merge to the main branch. Organize your repo efficiently and track changes that way. Here are some helpful links: 1. GitLab rules for CI. 2. GitHub actions path filters. 3. Jenkins changeset management.

berthC_18: Good insight! We do the same in my teamโ€”only the main branch gets model registrations.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions