Skip to content

Commit 7310d32

Browse files
committed
ci(dylint): invalidate stale target/dylint after cache restore
The `Dylint` workflow's cache `restore-keys` list ends with a key that matches any prior cache for the same `rust-toolchain`, ignoring the `dylint.toml` hash. When `dylint.toml` changes the cached `target/dylint/libraries/libperfectionist.so` is the lib built from the previous `dylint.toml`. `cargo dylint` does not always detect a changed `git`/`rev` and reuses the cached `.so` instead of rebuilding. With `RUSTFLAGS="-D warnings"` enforced, the stale lib re-flags sites that the current `dylint.toml` revision is supposed to skip, failing the job. Add a step between the cache restore and the dylint run that deletes `target/dylint`. The `~/.cargo` registry cache stays intact, so dependency downloads remain fast, while the perfectionist library is always rebuilt from the `dylint.toml` currently in tree. Reproducible locally by switching `dylint.toml` between the `0.0.0-rc.6` tag and the `KSXGitHub/perfectionist#25` rev without clearing `target/dylint` between runs.
1 parent eb17f9d commit 7310d32

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

.github/workflows/dylint.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ jobs:
3939
shell: bash
4040
run: cargo install --locked cargo-dylint dylint-link
4141

42+
# The third entry in `restore-keys` above falls back to any cache for the
43+
# same `rust-toolchain`, including caches built against an older
44+
# `dylint.toml`. `cargo dylint` does not always detect a changed `git`
45+
# `rev`/`tag` and may reuse the cached `libperfectionist.so` from the
46+
# prior `dylint.toml`. Removing the dylint cache directory forces a
47+
# fresh library build for the current `dylint.toml`. The `~/.cargo`
48+
# registry cache is preserved, so dependency downloads stay fast.
49+
- name: Invalidate stale dylint build artifacts
50+
shell: bash
51+
run: rm -rf target/dylint
52+
4253
- name: Run dylint
4354
shell: bash
4455
env:

0 commit comments

Comments
 (0)