Files
anki/tools/coverage
Fernando Lins 4aa9c08369 fix(ci): prevent silent skip of PR coverage-regression check on evicted baseline (#5480)
## Linked issue

Fixes #5418

## Summary / motivation

Every push to `main` creates a new `coverage-baseline-linux-<sha>` cache
entry. Without a pruning step, these entries accumulate until GitHub's
LRU eviction removes old ones. When the baseline a PR needs has been
evicted, `check-coverage-regression.py` silently skips the check instead
of failing, which could mask genuine coverage regressions.

Two changes together close the gap:

1. **`prune-coverage-cache.yml`**: a new workflow triggered by
`workflow_run` on every successful CI run on `main`. It keeps exactly
one `coverage-baseline-linux-*` cache (the one just created) and deletes
all older entries via the GitHub Actions API. With a single,
always-fresh entry, eviction becomes practically impossible.

2. **`check-coverage-regression.py`**: turns the silent "no baseline —
skipping" path into an explicit failure (`exit 2`). If somehow a
baseline is still absent, the check now surfaces the problem visibly
instead of passing silently.

## Steps to reproduce

1. Allow several pushes to `main` to accumulate
`coverage-baseline-linux-*` cache entries until GitHub evicts the most
recent one.
2. Open a PR: `check-coverage-regression.py` prints `no baseline —
skipping` and exits 0, even if coverage dropped.

## How to test

### Details

- After merging, verify via **Actions → Prune coverage baseline caches**
that the job runs after a `CI` completion on `main` and leaves exactly
one `coverage-baseline-linux-*` entry (`gh cache list -R ankitects/anki
--key coverage-baseline-linux-`).
- Confirm that a PR with a missing baseline now receives exit code 2
(visible failure) instead of exit code 0.

## Before / after behavior

**Before:** evicted baseline → `check-coverage-regression.py` skips
silently, coverage regressions go undetected.

**After:** only one baseline exists at a time (no eviction risk); if it
is somehow absent, the script exits with code 2 and the CI step fails
visibly.
2026-08-30 21:07:18 -03:00
..