Repository navigation
ci(affected): extract shared setup into composite action - #2483
Merged
Merged
Conversation
Adds two jobs: - `collect-affected` runs on push to main and refreshes `target/affected/coverage.db` via `cargo affected collect`. Caches it to actions/cache keyed on `runner.os` + the cargo-affected git rev (resolved at runtime — schema bumps invalidate stale DBs) + the main commit sha. - `affected-tests` runs on PRs as a `continue-on-error` advisory job. Restores the DB with the PR's merge-base as the primary key (tight diff when collect ran on that exact commit) and a prefix restore-keys fallback to the most recent main DB. cargo-affected's "fall back to all tests when selection can't be precise" behavior (max-sixty/cargo-affected@9afb870) means the fallback path always produces a useful run rather than bailing. Comments document the storage rationale and a TODO to gate the full test matrix on merges + labeled PRs once selection accuracy is calibrated. Co-Authored-By: Claude <[email protected]>
`baptiste0928/cargo-install` with no `rev:`/`branch:`/`tag:` already resolves to the default branch's HEAD via `git ls-remote` and exposes the resolved sha as an output — the explicit resolve step was redundant. Drop the resolve step, omit `rev:` from the install (auto-tracks main), and replace the rev component of the DB cache key with a manual `db-v1-` marker. The marker is the hand-bumpable lever for handling on-disk schema changes in cargo-affected; routine upstream commits no longer invalidate the cache. Co-Authored-By: Claude <[email protected]>
cargo-affected now falls back to running all tests when it can't compute a precise selection (no DB, env-fingerprint mismatch, or collect_sha not reachable from HEAD). The skip-on-cache-miss step and the per-step `cache-matched-key != ''` gates were preventing exactly the fallback behavior we want — the cached DB is now an optimization, not a precondition. Removing the gates means an empty/divergent cache produces a useful "run all tests" advisory run instead of a silent skip. The cache restore stays so exact-match merge-base hits still get a tight diff. Co-Authored-By: Claude <[email protected]>
Both collect-affected and affected-tests installed the same 7 setup steps (cargo-insta, cargo-nextest, cargo-affected, llvm-tools, rust-cache, apt shells, nushell). Lift them into .github/actions/affected-setup so each job references the action instead of duplicating the block. Pinned tool versions now live in one place. Co-Authored-By: Claude <[email protected]>
# Conflicts: # .github/workflows/ci.yaml
worktrunk-bot
approved these changes
Apr 30, 2026
1 of 4 tasks
max-sixty
added a commit
that referenced
this pull request
Apr 30, 2026
## Summary Follow-up to #2483. The composite action installed `cargo-affected` and `llvm-tools`, which the regular `test (linux/macos/windows)` matrix doesn't need. Lift only the always-shared subset (cargo-insta, cargo-nextest, rust-cache, OS-conditional shells, nushell) into `test-setup`, and have the affected-* jobs add `cargo-affected` + `llvm-tools` inline. The test matrix now uses the action too: ~50 lines of inline setup collapse to one `uses:` line. Pinned tool versions (cargo-insta, cargo-nextest, nushell) serve all four callers from one place. OS branching that was already inline in test-matrix moves into the action — same `runner.os` conditionals, just relocated. Drops the Windows-only informational `echo "Using Git Bash for Windows tests"` step (was a no-op). ## Test plan - [x] `pre-commit run` passes on changed files - [ ] `test (linux/macos/windows)` still install the same toolchain - [ ] `affected tests (linux, advisory)` still installs cargo-affected + llvm-tools - [ ] `collect affected coverage` (gated to push-to-main) still works 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Both
collect-affectedandaffected-tests(added in #2475) installed the same 7 setup steps — cargo-insta, cargo-nextest, cargo-affected, llvm-tools, rust-cache, apt shells, nushell. Lift them into.github/actions/affected-setup/action.yamlso each job replaces the block with oneuses:line.Pinned tool versions now live in one place. No behavior change — same steps, same order.
Test plan
pre-commit runpasses on changed filescollect-affectedandaffected-testsjobs still install the same toolchain in CI🤖 Generated with Claude Code