Run only what's affected

--affected runs changed packages plus everything that depends on them.

From turborepo, filtering/RULE.md and ci/RULE.md.

Changed is not enough

Pick what the PR changed, then run CI.

Changed onlyBad
0 tested0 dependents skipped
turbo run test --filter=[main]
AffectedGood
0 tested0 dependents skipped
turbo run test --affected

No merge base, no savings

The PR touched api. Check out, then run --affected.

Shallow cloneBad
actions/checkout@v4 (depth 1)
History fetchedGood
with: { fetch-depth: 0 }
# .github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 2        # minimum; 0 when the merge base is far back
- run: turbo run build test lint --affected

# base branch isn't main or master?
TURBO_SCM_BASE=origin/develop turbo run build --affected

Why it matters, pros and cons

Why it matters

A change to ui can break web without touching it. --affected diffs against the base branch and walks up to every dependent.

Pros

  • PRs test what they can break, nothing more.
  • Same as --filter=...[main], shorter.
  • Reads the PR base on GitHub Actions.

Cons

  • Needs the merge base in the clone.
  • Uses main/master, not your default branch.
  • Run everything on main after merge.