Skip to content

Fix Maven cache warmer to cache surefire-junit-platform provider#1513

Merged
vikrantpuppala merged 2 commits into
mainfrom
fix/warm-cache-surefire-junit-platform
Jun 29, 2026
Merged

Fix Maven cache warmer to cache surefire-junit-platform provider#1513
vikrantpuppala merged 2 commits into
mainfrom
fix/warm-cache-surefire-junit-platform

Conversation

@vikrantpuppala

Copy link
Copy Markdown
Collaborator

Problem

Forked PRs (e.g. #1507) run Maven in offline mode against the ~/.m2 cache pre-populated by the Warm Maven Dependency Cache workflow. They fail with:

The following artifacts could not be resolved:
org.apache.maven.surefire:surefire-junit-platform:jar:3.1.2 (absent):
Cannot access central (https://repo.maven.apache.org/maven2) in offline mode

This breaks every test job (unit / integration / coverage, all JDK + OS combinations) on fork PRs.

Root cause

The warmer relies on its filtered test steps (4–6) to lazily download the Surefire JUnit Platform provider (surefire-junit-platform). But those steps fail early with No tests matching pattern "..." — there are no compiled test classes for the narrow -Dtest= filters to match, so Surefire prints No tests to run and never loads (or downloads) the provider. The failures are masked by || true, so the warmer reports success while saving a cache that is missing the provider jar.

Verified in the most recent warm run: surefire-junit-platform appears 0 times in the warmer log on both Linux and Windows.

Fix

Add an explicit dependency:get for org.apache.maven.surefire:surefire-junit-platform (version read from the maven-surefire-plugin.version POM property, falling back to 3.1.2) so the provider is cached deterministically, independent of whether any filtered test run executes.

Follow-ups (not in this PR)

  • Steps 4–6 silently fail with "No tests matching pattern" (masked by || true) — the warmer's unit-test steps aren't actually exercising tests and should be fixed to compile + run real tests.
  • A maintainer-applied label to trigger the warmer for a specific PR (auto-removed on new commits) was discussed and deferred.

NO_CHANGELOG=true

This pull request and its description were written by Isaac.

The warm-cache workflow pre-populates ~/.m2 so forked PRs can build in
offline mode. It relied on its filtered test steps (4-6) to lazily pull
the Surefire JUnit Platform provider (surefire-junit-platform), but those
steps fail early with "No tests matching pattern" (no compiled test
classes), masked by `|| true`. Surefire prints "No tests to run" and never
loads the provider, so the jar is never cached.

Forked PR jobs then fail in offline mode with:
  surefire-junit-platform:jar:3.1.2 (absent): Cannot access central ...
  in offline mode

Add an explicit `dependency:get` for the provider so it is cached
deterministically regardless of whether any filtered test run executes.

Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
The warmer saved caches as maven-deps-<timestamp>-<hash>, but consumers
restore with exact key maven-deps-<hash> and fall back to the unscoped
prefix restore-keys: maven-deps-. The timestamp segment means the exact
key never matches, so restore always fell through to the prefix — which
GitHub resolves to the most-recently-created maven-deps-* entry across
ALL poms, frequently a main-branch cache that lacks fork-specific
artifacts (and, before the prior commit, the surefire-junit-platform
provider). Result: fork PRs restored the wrong cache and failed offline.

Fix:
- Warmer key layout -> maven-deps-<hash>-<timestamp> (hash first).
- Consumer restore-keys -> maven-deps-<hash> (hash-scoped prefix), so the
  fallback only matches caches warmed for the same pom and picks the
  newest by timestamp.

Requires a fresh warmer run after merge so caches are saved under the new
key layout; old maven-deps-<timestamp>-<hash> entries no longer match and
expire after 7 days.

Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
@vikrantpuppala vikrantpuppala merged commit ebefc4b into main Jun 29, 2026
15 of 16 checks passed
@vikrantpuppala vikrantpuppala deleted the fix/warm-cache-surefire-junit-platform branch June 29, 2026 10:54
@vikrantpuppala vikrantpuppala restored the fix/warm-cache-surefire-junit-platform branch June 29, 2026 11:00
@vikrantpuppala vikrantpuppala deleted the fix/warm-cache-surefire-junit-platform branch June 29, 2026 11:01
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.

2 participants