DiffCI

Selection strategy

Test selection vs path filters, Nx and Turborepo

These approaches overlap, but they do not answer exactly the same question. The best baseline is often the simplest one that is safe, maintainable, and measurably cheaper for the repository.

What each approach knows

ApproachPrimary evidenceStrengthMain boundary
Changed-path ruleFiles and directories in the Git diffCheap, explicit, easy to reviewShared and transitive dependencies must be maintained manually
Nx/Turborepo-style affected task graphDeclared projects, packages and task dependenciesFits repositories already organized around that graphPrecision stops at the configured project or task boundary
Source dependency test selectionResolved imports from changed source to testsCan narrow within a package and retain per-test provenanceDynamic behavior, unsupported languages and resolution gaps require fallback
DiffCI observationGit delta, dependency evidence, CI structure and execution comparisonMeasures whether a selection would be safe and worthwhile before CI authority changesAdvisory; it does not replace or accelerate required production CI

Precision is not the same as value

A dependency graph can select fewer tests than a directory rule and still cost more after analysis overhead. A package-level task graph can be less precise but cheaper, easier to explain, and already integrated with build caching. The economic comparison needs actual command execution.

DiffCI's open benchmark found repositories where a simple path rule was already optimal, repositories where dependency analysis found a narrower candidate, and repositories where mandatory fallbacks dominated. That mixture is why DiffCI reports the baseline rather than declaring one method universally better.

Compare the command and maintenance surface

The approaches differ in where their truth is maintained. A path rule is written by hand, a task graph follows declared project relationships, and a source graph derives reachability from code. The commands can look equally small while carrying very different maintenance obligations:

# GitHub Actions path boundary
on:
  pull_request:
    paths: ["packages/billing/**", "packages/shared/**"]

# Nx project/task graph
npx nx affected -t test --base=origin/main --head=HEAD

# Turborepo package/task graph
turbo run test --filter="...[origin/main]"

# DiffCI observation and measured comparison
npx "@diffci.com/diffci@latest" check
QuestionPath filtersNx/TurborepoSource dependency selection
Who maintains dependency truth?Repository authors maintain glob-to-job mappingsProject and task graph configurationResolver plus explicit fallback and always-run policy
Typical selection unitWorkflow or commandProject or taskTest file, package, or full fallback
Analysis overheadVery lowGraph calculation and cache lookupGit, repository, source, and test-graph analysis
Critical failure modeStale or incomplete globMissing task/project dependencyUnsupported or unresolved source edge
Required safety responseBroaden rule or run allRepair graph or run broader taskRecord boundary and run full command

How to choose

  • Use path filters first when repository boundaries are stable, shared dependencies are limited, and the mapping is easy to review.
  • Use the monorepo task graph when Nx, Turborepo, or an equivalent already defines the authoritative project and task relationships.
  • Evaluate source dependency selection when large packages contain many independently reachable tests and coarse project selection still runs too much.
  • Keep full-run triggers regardless. Lockfiles, workflows, root configuration, and incomplete evidence can invalidate every narrow strategy.

Run the comparison without changing CI

npx "@diffci.com/diffci@latest" check

The local check analyzes the change and runs inferred full and selected commands when possible. It retains fallback reasons and measured timings. Use observe --no-send when analysis should not execute tests.

For GitHub Actions prerequisites, see the test impact analysis guide. For a safety checklist, see how to run affected tests safely.