fix(ci): replace setup-java's broken maven cache with actions/cache (#2503)

* fix(ci): replace setup-java's broken maven cache with actions/cache

setup-java@v5.6.0's built-in cache: maven has never worked on this
repo: every run restores nothing ("maven cache is not found") and then
fails to save ("Path Validation Error: Path(s) specified in the action
for caching do(es) not exist"), so every single CI run resolves the
full dependency tree cold. Confirmed across 3 independent runs, no
custom localRepository override anywhere that would explain it -
looks like a bug in this pinned action version.

Uses actions/cache directly instead, keyed on pom.xml's hash - the
same underlying mechanism setup-java's option wraps, just debuggable
and not broken. Free (GitHub Actions cache storage is free up to
10GB/repo), same runner, no test/build logic touched.

* fix(ci): scope the maven cache key to the root pom.xml only

hashFiles('**/pom.xml') also picked up
compatibility-tests/sdk-test-java/pom.xml, a separate project this
workflow never builds - its own paths: trigger only watches the root
pom.xml. An unrelated change there would bust the cache key and cost
this fix its whole point on the next run.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-08-23 22:37:07 -05:00
1 parent 59c6f772cb
commit a68bfc4e68
1 file changed
+12 -1
+12 -1
View File
@@ -33,7 +33,18 @@ jobs:
with:
java-version: '25'
distribution: 'temurin'
cache: maven
# setup-java's built-in `cache: maven` never actually saves a cache on this action
# version - every run restores nothing ("maven cache is not found") and then fails to
# save with "Path Validation Error: Path(s) specified in the action for caching do(es)
# not exist", so every run has been resolving all dependencies cold. Using actions/cache
# directly instead, which is the same mechanism setup-java's option wraps.
- uses: actions/cache@v6.1.0
with:
path: ~/.m2/repository
key: maven-${{ runner.os }}-${{ hashFiles('pom.xml') }}
restore-keys: |
maven-${{ runner.os }}-
- name: Run tests
run: mvn test -B