Codecov Coverage Report Cache Invalidation Policy
0 reputation · 16 May 2021, 15:45 UTC
0 reputation · 16 May 2021, 15:45 UTC
The goal is to guarantee that a Codecov coverage badge or dashboard always reflects the latest coverage file uploaded for a given commit. In practice, the cache key is derived from the repository, branch, and commit hash, but the exact trigger for cache invalidation is not documented. This creates uncertainty for CI pipelines that rely on up‑to‑date coverage metrics.
When a commit is force‑pushed or a pull request is rebased, the commit hash may remain unchanged while the coverage report itself changes. Users have observed that the UI may still display the old badge, suggesting the cache is retained. Additionally, there is no documented time‑based expiration for cached reports, and the “Last updated” timestamp on the UI does not clarify whether it indicates a cache refresh or a new upload.
Given these gaps, the following specific questions remain unanswered:
Does Codecov invalidate a cached report when the coverage file changes but the commit hash stays the same?
Confirmed: Codecov identifies a report by repository owner/name, provider commit SHA, and optionally PR number and flags. Badge and dashboard URLs are parameterized by those identifiers. The key is commit-based, not time-based.
Likely: Re-uploading coverage for an existing commit SHA updates the stored report timestamp and the coverage shown for that SHA, effectively replacing the previous payload for that key. Exact overwrite versus merge behavior can depend on uploader configuration and flags. A force-push that truly keeps the same SHA cannot change file content without changing the SHA, so the scenario of "same SHA, different coverage" is not a normal Git workflow.
Is there a documented time-based expiration policy for cached reports?
Confirmed: No documented time-based expiration policy for stored coverage reports is published. Reports are retained per commit/PR key.
Likely: Badge and dashboard responses are served via CDN. Apparent staleness is typically CDN propagation latency, not a policy TTL. Short lag after a successful upload is expected.
How is cache handled when a PR is merged or rebased onto a new commit?
Confirmed: A new commit SHA creates a new report entry. Merging or rebasing a PR normally produces new SHAs on base and head, so a fresh report is required for the new SHA. The old SHA report remains unchanged.
Likely: If the CI uploads only for the old SHA after a rebase, the UI will continue to show the old report for that SHA. The new SHA will appear empty until a coverage upload is made for it.
One diagnostic detail that changes the recommendation: which flags and uploader configuration are used in the upload. Upload deduplication and flags can cause reports to be merged rather than replaced for the same SHA, leading to unexpected values.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.