Skip to content

ci(affected): extract shared setup into composite action - #2483

Merged
max-sixty merged 5 commits into
mainfrom
affected-design
Apr 30, 2026
Merged

max-sixty merged 5 commits into
mainfrom
affected-design

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Summary

Both collect-affected and affected-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.yaml so each job replaces the block with one uses: line.

Pinned tool versions now live in one place. No behavior change — same steps, same order.

Test plan

  • pre-commit run passes on changed files
  • collect-affected and affected-tests jobs still install the same toolchain in CI

🤖 Generated with Claude Code

max-sixty and others added 5 commits April 29, 2026 14:20
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
@max-sixty
max-sixty merged commit 2372212 into main Apr 30, 2026
27 checks passed
@max-sixty
max-sixty deleted the affected-design branch April 30, 2026 01:48
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants