Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Change Detection Examples

Two approaches based on your project's tooling:

Choose Your Pattern

Pattern For Projects With Strategy
with-task-runner/ just, make, xtask, scripts cargo rail plan + your task runner
standalone/ No task runner cargo rail run handles everything

Measured Impact (Last 20 Commits per Repo)

Generated with /Users/mr.wolf/loadingalias/cargo-rail-testing/scripts/measure-impact.sh.

Repository Could Skip Build Could Skip Tests Targeted (Not Full Run)
tokio 10% 0% 95%
meilisearch 35% 35% 60%
helix 30% 30% 40%
helix-db 10% 10% 75%
Aggregate (80 commits) 21% 19% 68%

Interpretation:

  • Task-runner repos (meilisearch, helix) show the largest immediate test/build skip savings.
  • Standalone repos still gain deterministic targeting and explainable plan traces.

With Task Runner (Recommended for Large Projects)

If you already have just, make, xtask, or shell scripts:

# cargo-rail provides change detection
PLAN=$(cargo rail plan --merge-base -f json)
SCOPE=$(echo "$PLAN" | jq -c '.scope')

# Your task runner handles execution
if echo "$PLAN" | jq -e '.surfaces.test.enabled' > /dev/null; then
  if echo "$SCOPE" | jq -e '.mode == "workspace"' > /dev/null; then
    cargo xtask test --workspace
  elif echo "$SCOPE" | jq -e '.mode == "crates"' > /dev/null; then
    mapfile -t CRATES < <(echo "$SCOPE" | jq -r '.crates[]')
    cargo xtask test "${CRATES[@]}"
  else
    echo "planner enabled test surface, but no package-scoped work was selected"
  fi
fi

Use .scope for package selection. Keep the full plan for gates, trace, and debugging. Do not rebuild execution scope from impact.

Why?

  • cargo-rail stays focused on change detection
  • Your existing build logic doesn't change
  • Full control over execution
  • No lock-in

Real examples: helix, meilisearch

Standalone (Simpler, Less Flexible)

If you don't have a task runner:

# cargo-rail handles both detection and execution
cargo rail run --merge-base --surface test
cargo rail run --workflow ci

Why?

  • Single command for plan + execute
  • No scripting required
  • Built-in surfaces: build, test, bench, docs

Real examples: tokio, helix-db

Configuration Reference

Infrastructure Files

Files that trigger full workspace rebuild:

[change-detection]
infrastructure = [
  ".github/**",       # CI changes
  "scripts/**",       # Build scripts
  "justfile",         # Task runner
  "deny.toml",        # License/security
  "rust-toolchain.toml",
  "Cargo.toml",
  "Cargo.lock",
]

Confidence Profiles

Profile Behavior
strict Conservative — runs more, misses less
balanced Default — good tradeoff
fast Aggressive — skips transitive checks
[change-detection]
confidence_profile = "balanced"
bot_pr_confidence_profile = "strict"  # Override for dependabot, etc.

Custom Surfaces

Detect non-Rust asset changes:

[change-detection.custom]
themes = ["runtime/themes/**"]
queries = ["runtime/queries/**"]
workloads = ["workloads/**"]

Plan output includes custom:themes, custom:queries, etc.

Validation

cargo rail config validate --strict
cargo rail plan --merge-base --explain
cargo rail run --merge-base --dry-run --print-cmd

See Also