Skip to content

ci: [Robolectric CI 2] Cache Robolectric android-all jars in the build job - #6545

Closed
romtsn wants to merge 4 commits into
romtsn/robolectric-ci-1-sdk-levelsfrom
romtsn/robolectric-ci-2-jar-cache
Closed

romtsn wants to merge 4 commits into
romtsn/robolectric-ci-1-sdk-levelsfrom
romtsn/robolectric-ci-2-jar-cache

Conversation

@romtsn

@romtsn romtsn commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

PR Stack (Robolectric CI)


📜 Description

Caches ~/.m2/repository/org/robolectric in the Build job:

  • Every run restores the cache (actions/cache/restore) before make preMerge.
  • Only main saves it (actions/cache/save), and only when there was no exact hit. PRs read the entry that main saved, like setup-gradle does for the Gradle caches. Otherwise each PR would save its own ~700 MB entry that only that PR can use.

The cache key is a hash of the Robolectric version line in libs.versions.toml and every sdk = [...] / sdk= in the test sources. So the key changes only when the Robolectric version or the set of SDK levels changes, not on each dependency bump. restore-keys allows a partial hit, so a new SDK level downloads only its own jar.

💡 Motivation and Context

Robolectric downloads the android-all-instrumented jars at test runtime into ~/.m2/repository. setup-gradle caches only ~/.gradle, so each CI run that executes Robolectric tests downloads 100-200 MB per SDK level. With the levels from #6544, that is ~713 MB for core and replay.

💚 How did you test it?

A temporary benchmark workflow (not part of this PR) ran only the core and replay Robolectric tests. Each job ran cold runs (jars deleted first) and warm runs in turns on the same runner, so the runner hardware does not affect the comparison. Mean of 3 rounds per job:

Job Jars core cold → warm replay cold → warm
with #6544, Intel Xeon 6973P 713 MB 117.0s → 112.3s (+4.7s) 71.0s → 67.3s (+3.7s)
with #6544, AMD EPYC 7763 713 MB 161.8s → 157.5s (+4.3s) 94.7s → 92.3s (+2.4s)
without #6544, AMD EPYC 9V74 1244 MB 163.0s → 152.2s (+10.8s) 91.1s → 83.1s (+8.0s)
without #6544, AMD EPYC 9V74 1244 MB 169.0s → 162.9s (+6.1s) 92.9s → 89.6s (+3.3s)

So the cache saves about 4-5s per run with #6544, and up to ~11s without it. Runners download from Maven Central at about 150-370 MB/s, so the download is short. curl of the same 6 jars takes about 3.5s.

Note: a first comparison of two Build runs of this PR (cache miss vs. hit) showed 2.5 min less, but most of that was runner variance. All test tasks in that run were 20-30% faster, including the Spring tests, which do not use Robolectric.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

The entry is ~750 MB of the repo's 50 GB Actions cache. If cache pressure becomes a problem, remove restore-keys so that old jars do not stay in the entry after a Robolectric upgrade.

🤖 Generated with Claude Code

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

#skip-changelog

Robolectric downloads the android-all-instrumented jars at test runtime into ~/.m2, which setup-gradle does not cache, so each CI run downloads 100-200 MB per SDK level. Cache that directory, keyed on the Robolectric version and the SDK levels the tests use.

Locally, an empty jar cache makes the core and replay test run take 158-207s instead of 76-88s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sentry

sentry Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.63.0 (1) release

⚙️ sentry-android Build Distribution Settings

romtsn and others added 3 commits November 10, 2026 17:36
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each PR used to save its own ~700 MB entry, which only that PR can use. Now PRs only restore the entry that main saves, like setup-gradle does for the Gradle caches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@romtsn

romtsn commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

closing in favour #6553

@romtsn romtsn closed this Nov 11, 2026
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