From 15b83680ac29655b720f345b4c9ce2c17b496d1d Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 10 Nov 2026 13:12:34 +0100 Subject: [PATCH 1/4] ci: Cache Robolectric android-all jars in the build job 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 --- .github/workflows/build.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 351dd6c3da..d9ef834086 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,6 +30,24 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1 + # Robolectric downloads one android-all-instrumented jar (100-200 MB) per SDK level at test + # runtime into ~/.m2, which setup-gradle does not cache. The key changes only when the + # Robolectric version or the set of SDK levels used by tests changes. + - name: Compute Robolectric cache key + id: robolectric-key + run: | + key=$( (grep '^roboelectric' gradle/libs.versions.toml; git grep -hoE 'sdk *= *\[[^]]*\]|^sdk=.*' -- '*/src/test/*') | sort -u | sha256sum | cut -c1-16) + echo "key=$key" >> "$GITHUB_OUTPUT" + + - name: Cache Robolectric android-all jars + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ~/.m2/repository/org/robolectric + key: robolectric-${{ steps.robolectric-key.outputs.key }} + # ponytail: a partial hit keeps old jars around, so the entry grows a bit across + # Robolectric upgrades. Drop restore-keys if the cache size matters. + restore-keys: robolectric- + - name: Run Tests and Lint run: make preMerge From 617fc70a5c566878d35da58b6d80c1d5cad61e12 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 10 Nov 2026 17:36:46 +0100 Subject: [PATCH 2/4] ci: Remove note comment from Robolectric cache step Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d9ef834086..97300e29dd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,8 +44,6 @@ jobs: with: path: ~/.m2/repository/org/robolectric key: robolectric-${{ steps.robolectric-key.outputs.key }} - # ponytail: a partial hit keeps old jars around, so the entry grows a bit across - # Robolectric upgrades. Drop restore-keys if the cache size matters. restore-keys: robolectric- - name: Run Tests and Lint From 8220904f8bcd06b7875580dfbdd4eb028a23896e Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 10 Nov 2026 17:38:07 +0100 Subject: [PATCH 3/4] ci: Restore cache size note on Robolectric cache step Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 97300e29dd..65047451c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,6 +44,8 @@ jobs: with: path: ~/.m2/repository/org/robolectric key: robolectric-${{ steps.robolectric-key.outputs.key }} + # A partial hit keeps old jars around, so the entry grows a bit across Robolectric + # upgrades. Drop restore-keys if the cache size matters. restore-keys: robolectric- - name: Run Tests and Lint From 4cf3c9ca257b9b50197ca5429c5db327164e3e59 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Wed, 11 Nov 2026 09:39:50 +0100 Subject: [PATCH 4/4] ci: Save the Robolectric jar cache only on main 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 --- .github/workflows/build.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65047451c7..17fe0534b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,8 +39,9 @@ jobs: key=$( (grep '^roboelectric' gradle/libs.versions.toml; git grep -hoE 'sdk *= *\[[^]]*\]|^sdk=.*' -- '*/src/test/*') | sort -u | sha256sum | cut -c1-16) echo "key=$key" >> "$GITHUB_OUTPUT" - - name: Cache Robolectric android-all jars - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + - name: Restore Robolectric android-all jars + id: robolectric-cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.m2/repository/org/robolectric key: robolectric-${{ steps.robolectric-key.outputs.key }} @@ -51,6 +52,14 @@ jobs: - name: Run Tests and Lint run: make preMerge + # Only main saves, so PRs share one entry instead of each storing ~700 MB. + - name: Save Robolectric android-all jars + if: github.ref == 'refs/heads/main' && steps.robolectric-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ~/.m2/repository/org/robolectric + key: robolectric-${{ steps.robolectric-key.outputs.key }} + - name: Install Sentry CLI uses: getsentry/action-setup-cli@70d7e587b84c2e78cf4d37cd33d7b74fb3729c1b # v1