Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

ci(affected): update cache-strategy comment to match post-#9 behavior (#2520)

Maximilian Roosd93a65a16b31
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index ac97e53d2..f6eb8c35c 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -250,15 +250,22 @@ jobs:
# .cargo/config.toml), and proc-macro source edits.
#
# Cache strategy:
- # - `collect-affected` (push to main) saves `target/affected/` to
- # actions/cache keyed on the main commit sha.
+ # - `collect-affected` (push to main) saves `target/affected/coverage.db`
+ # to actions/cache keyed on the main commit sha. We cache only the DB,
+ # not the parent dir — cargo-affected drops its profraw staging dir
+ # at the end of every successful collect, but caching the path
+ # explicitly keeps the contract obvious and ~10 GB of profile bundles
+ # from leaking into the cache if that cleanup ever regresses.
# - `affected-tests` (PRs) restores the cache. Primary key is the
# PR/main merge-base — when collect ran on that exact commit, we get a
# tight diff (`PR changes only`) and the smallest possible selection.
# - Restore-keys fall back to the most recent main DB. Its `collect_sha`
- # may be ahead of the merge-base; cargo-affected handles that by running
- # all tests with a notice (no `Diverged` bail), so the fallback always
- # produces a useful run, just with broader selection.
+ # is typically a sibling of the PR's HEAD, not a strict ancestor.
+ # cargo-affected uses any sha still in the repo as a diff anchor, so
+ # the fallback drives normal selection — over-includes tests touched
+ # by main commits between the merge-base and collect_sha (correct
+ # superset), but never widens to "run everything" unless the cache is
+ # missing entirely.
# - Cache keys include `runner.os` (fingerprint embeds `rustc -vV`) and a
# manual `db-v{N}` marker. Bump the marker if cargo-affected ships an
# on-disk schema change; the cache is otherwise version-agnostic.
@@ -327,6 +334,14 @@ jobs:
echo "sha=$sha" >> "$GITHUB_OUTPUT"
echo "merge-base with origin/main: $sha"
+ - uses: ./.github/actions/test-setup
+
+ # Restore AFTER test-setup so we land on top of rust-cache's tar
+ # extraction. rust-cache's restore step calls `cleanTargetDir` on a
+ # partial cache hit (`full match: false`), which deletes file children
+ # of `target/affected/` — including a `coverage.db` we'd just dropped
+ # there. Order: rust-cache populates `target/` first; we then drop the
+ # DB on top, where nothing else touches it.
- name: 💾 Restore coverage DB
uses: actions/cache/restore@v5
with:
@@ -334,13 +349,12 @@ jobs:
# Exact match: collect ran on the PR's merge-base → tight diff.
key: cargo-affected-db-v1-${{ runner.os }}-${{ steps.mb.outputs.sha }}
# Fallback: most recent main DB. cargo-affected runs all tests when
- # collect_sha isn't an ancestor of HEAD; with no DB at all it does
- # the same. Either way the run produces a useful signal.
+ # the cached `collect_sha` is missing from the repo (rebased and
+ # pruned, beyond a shallow clone boundary). Sibling shas — including
+ # PR-vs-main-tip — drive normal selection.
restore-keys: |
cargo-affected-db-v1-${{ runner.os }}-
- - uses: ./.github/actions/test-setup
-
- name: Install cargo-affected
uses: baptiste0928/cargo-install@v3
with: