Skip to content

Commit a3330b5

Browse files
joaodinissfclaude
andcommitted
ci: restore Maven cache from master-produced caches in maven-verify
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>
1 parent 011a589 commit a3330b5

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

.github/workflows/verify.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,18 @@ jobs:
4545
run: mvn --version
4646
- name: Set up Workspace Environment Variable
4747
run: echo "WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV
48-
- name: Cache Maven dependencies
49-
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
48+
- name: Restore Maven dependency cache
49+
# Restore-only: PR scopes cannot share caches with each other, so per-PR
50+
# saves are dead weight that evicts the useful master-scoped caches
51+
# (10 GB repo budget). The producer is snapshot.yml on master pushes
52+
# (Linux-maven-publish-*). Path and key must mirror snapshot.yml exactly:
53+
# the literal path spec is hashed into the cache *version*, so any
54+
# variation (~/.m2 vs /home/runner/.m2) makes its caches unmatchable.
55+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
5056
with:
51-
path: /home/runner/.m2/repository
52-
key: ${{ runner.os }}-maven-0-${{ hashFiles('**/pom.xml') }}
57+
path: ~/.m2/repository
58+
key: ${{ runner.os }}-maven-publish-${{ hashFiles('**/pom.xml', '**/*.target') }}
59+
restore-keys: ${{ runner.os }}-maven-publish-
5360
- name: Build with Maven within a virtual X Server Environment
5461
# Run pmd:pmd and pmd:cpd first to generate reports for all modules, then run pmd:check and pmd:cpd-check
5562
# This ensures all violations are collected and reported before the build fails

0 commit comments

Comments
 (0)