Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/setup-diffbio/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ runs:
- name: Install uv
uses: astral-sh/setup-uv@v10.2.0
with:
prune-cache: true
version: "0.12.21"
enable-cache: true
cache-suffix: ${{ inputs.cache-suffix }}
Expand Down
28 changes: 28 additions & 0 deletions tests/test_ci_concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,31 @@ def test_every_workflow_a_push_triggers_cancels_the_run_it_supersedes() -> None:
assert isinstance(concurrency, dict), f"{name} declares no concurrency group"
assert "github.ref" in str(concurrency.get("group")), f"{name}'s group ignores the ref"
assert concurrency.get("cancel-in-progress") is True, f"{name} keeps superseded runs"


def test_every_uv_cache_is_pruned_before_it_is_saved() -> None:
"""A saved uv cache holds only what uv built, not every wheel it downloaded.

setup-uv prunes only when asked (``prune-cache`` defaults to false from v9); unpruned, the
caches of the heavy extras grow to gigabytes each and evict the repository's other caches.
"""
github = WORKFLOWS.parents[1] / ".github"
documents = [
*sorted(github.glob("workflows/*.yml")),
*sorted(github.glob("actions/*/action.yml")),
]
checked = 0
unpruned: list[str] = []
for path in documents:
document = yaml.safe_load(path.read_text(encoding="utf-8"))
owners = {**document.get("jobs", {}), "runs": document.get("runs") or {}}
for owner, body in owners.items():
for step in body.get("steps", []):
if not str(step.get("uses", "")).startswith("astral-sh/setup-uv@"):
continue
checked += 1
if (step.get("with") or {}).get("prune-cache") is not True:
unpruned.append(f"{path.relative_to(WORKFLOWS.parents[1])}:{owner}")

assert checked, "no setup-uv step found; the contract is reading the wrong files"
assert unpruned == [], f"setup-uv steps saving an unpruned cache: {unpruned}"
Loading