Skip to content

ci: restore Maven cache from master-produced caches in maven-verify#1399

Open
joaodinissf wants to merge 1 commit into
dsldevkit:masterfrom
joaodinissf:ci/maven-verify-cache-restore-keys
Open

ci: restore Maven cache from master-produced caches in maven-verify#1399
joaodinissf wants to merge 1 commit into
dsldevkit:masterfrom
joaodinissf:ci/maven-verify-cache-restore-keys

Conversation

@joaodinissf

@joaodinissf joaodinissf commented May 31, 2026

Copy link
Copy Markdown
Collaborator

The maven-verify cache never hits in practice. Three compounding causes, verified against the live cache inventory:

  1. Exact-key-only restore: the key embeds hashFiles('**/pom.xml'), so every pom-touching PR (each dependabot bump) missed outright — e.g. run 27416121979: Cache not found for input keys: Linux-maven-0-3ecae… followed by a full cold download.
  2. PR scope isolation: the eight open PRs each held a byte-identical 704 MB cache under their own refs/pull/N/merge scope, invisible to one another. Only master-scoped caches are shareable, and verify.yml (pull_request-only) never saves there. Meanwhile snapshot.yml does produce a master-scoped Linux-maven-publish-* cache on every push.
  3. Eviction churn: the redundant per-PR saves pushed the repo over its 10 GB cache budget (10.35 GB / 14 caches), so LRU eviction also killed same-PR reuse.

The fix stays within the one cache step:

  • actions/cache/restore (restore-only): PRs stop saving — ends the duplicate-cache churn and the eviction pressure (steady state ≈ a few master caches).
  • Mirror the producer exactly: the step adopts snapshot.yml's literal path spec (~/.m2/repository) and key recipe (Linux-maven-publish- + hashFiles('**/pom.xml', '**/*.target')). This is load-bearing: GitHub serves a cache only when key and version match, and the version is a hash of the literal path spec/home/runner/.m2/repository vs ~/.m2/repository alone puts producer and consumer in disjoint version families (visible in the repo's cache inventory as two distinct version hashes for the same directory). A PR that touches no pom/target files exact-hits master's newest cache; any other PR prefix-restores it via restore-keys.
  • Cache-bust lever: rename the maven-publish family in snapshot.yml and here together.

Proven live on this PR — A/B, one commit apart, same three publish caches present on master:

Head maven-verify cache step Duration
pre-fix 0301a0538 (run 28912306532) Cache not found for input keys: Linux-maven-0-813d39e…, Linux-maven-0-, Linux-maven-publish- → cold download 16m16s
fixed a3330b5fe (run 28913047642) Cache restored from key: Linux-maven-publish-a45921afc7… (~1096 MB, exact hit on master's newest cache) 14m23s

Post-run, the cache API shows zero caches under refs/pull/1399/merge — PRs no longer save.

🤖 Generated with Claude Code

@joaodinissf joaodinissf force-pushed the ci/maven-verify-cache-restore-keys branch from 2ffb917 to f145e0c Compare June 12, 2026 20:42
@joaodinissf joaodinissf marked this pull request as ready for review June 12, 2026 20:42
@joaodinissf joaodinissf requested a review from rubenporras June 12, 2026 20:42
@joaodinissf joaodinissf enabled auto-merge (rebase) June 12, 2026 20:42
@joaodinissf joaodinissf force-pushed the ci/maven-verify-cache-restore-keys branch from f145e0c to df9375b Compare June 12, 2026 21:05
@joaodinissf joaodinissf changed the title ci: add restore-keys to the maven-verify Maven cache ci: restore Maven cache from master-produced caches in maven-verify Jun 12, 2026
@joaodinissf joaodinissf marked this pull request as draft June 12, 2026 21:07
auto-merge was automatically disabled June 12, 2026 21:07

Pull request was converted to draft

@joaodinissf joaodinissf removed the request for review from rubenporras June 12, 2026 21:07
@joaodinissf joaodinissf marked this pull request as ready for review June 12, 2026 22:03
@joaodinissf joaodinissf requested a review from rubenporras June 12, 2026 22:03
@joaodinissf joaodinissf enabled auto-merge (rebase) June 12, 2026 22:03
@joaodinissf joaodinissf force-pushed the ci/maven-verify-cache-restore-keys branch 2 times, most recently from 0301a05 to a3330b5 Compare July 8, 2026 02:27
@joaodinissf joaodinissf marked this pull request as draft July 8, 2026 02:43
auto-merge was automatically disabled July 8, 2026 02:43

Pull request was converted to draft

@joaodinissf joaodinissf marked this pull request as ready for review July 8, 2026 02:45
@joaodinissf joaodinissf removed the request for review from rubenporras July 8, 2026 02:46
The maven-verify cache never hit in practice, for three compounding reasons
(verified against the live cache inventory):

- actions/cache only restores on an exact key match, and the key embedded
  hashFiles('**/pom.xml') - so any pom-touching PR missed outright.
- GitHub isolates caches per PR scope: the open PRs each held a byte-identical
  ~700 MB cache under their own refs/pull/N/merge, invisible to one another.
  The only shareable scope is master, and verify.yml (a pull_request-only
  workflow) never saved there.
- The redundant per-PR saves pushed the repo over its 10 GB cache budget
  (10+ GB across 14 caches), so LRU eviction also killed same-PR reuse.

Fix, all in the one cache step: switch to actions/cache/restore (PRs stop
saving - ends the duplicate-cache churn and the eviction pressure) and mirror
the producer exactly. master DOES have a producer - snapshot.yml saves
~/.m2/repository as Linux-maven-publish-* on every push - so maven-verify now
adopts that family's exact path spec and key recipe. The mirroring must be
literal: GitHub hashes the path spec into the cache *version* and only serves
a cache whose key AND version both match, so ~/.m2/repository vs
/home/runner/.m2/repository alone makes the producer's caches silently
unmatchable (the repo's cache inventory showed the two path spellings under
distinct version hashes). A PR that touches no pom/target files exact-hits
master's newest cache; any other PR prefix-restores it via restore-keys.
The cache-bust lever is renaming the maven-publish family in snapshot.yml
and here together.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@joaodinissf joaodinissf force-pushed the ci/maven-verify-cache-restore-keys branch from a3330b5 to 93d4cce Compare July 8, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant