Skip to content

Commit 0301a05

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 embeds hashFiles('**/pom.xml') — so any pom-touching PR missed outright. - GitHub isolates caches per PR scope: the eight open PRs each held a byte-identical 704 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. - master DOES have a cache producer — snapshot.yml saves ~/.m2/repository as Linux-maven-publish-* on every push — but verify's restore prefix (Linux-maven-0-) could never match that family. snapshot.yml's own restore-keys already reach down into Linux-maven-0-; the sharing was one-directional by accident. - The redundant per-PR saves pushed the repo over its 10 GB cache budget (10.35 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), add restore-keys with prefix fallback, and include Linux-maven-publish- so every PR warm-starts from the snapshot build's superset cache, refreshed on each merge to master. The maven-0 epoch remains the manual bust lever. Mechanism verified in a fork experiment (joaodinissf#26): a pom-touching second run logged 'Cache restored from key: Linux-maven-0-…' and round- tripped the cached content. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 011a589 commit 0301a05

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/verify.yml

Lines changed: 9 additions & 2 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-*), which every PR can prefix-restore.
53+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
5054
with:
5155
path: /home/runner/.m2/repository
5256
key: ${{ runner.os }}-maven-0-${{ hashFiles('**/pom.xml') }}
57+
restore-keys: |
58+
${{ runner.os }}-maven-0-
59+
${{ 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)