build: fetch Robolectric's Android SDK jar from the mirror

Robolectric resolves android-all-instrumented itself at test time with
MavenArtifactFetcher, whose default repository is repo1.maven.org. The
Gradle mirror in settings.gradle.kts never applied to that fetch, so the
CI egress IP still got HTTP 429 there.

That fetcher also stores the jar in ~/.m2/repository, outside the
~/.gradle/caches directory CI restores, so every ephemeral runner
downloaded it again. Point robolectric.dependency.repo.url at the same
mirror for every Test task and cache the Robolectric Maven repository in
both workflows, keyed by the Robolectric version and the configured SDK.
This commit is contained in:
austinried
2026-11-04 10:21:49 +00:00
parent b2a1716be2
commit d6ff3ee086
4 changed files with 12 additions and 2 deletions
+5
View File
@@ -40,6 +40,11 @@ runs:
path: ~/.gradle/caches path: ~/.gradle/caches
key: gradle-v2-${{ hashFiles('**/*.gradle*', '**/gradle.properties', 'gradle/libs.versions.toml', 'gradle/wrapper/gradle-wrapper.properties') }} key: gradle-v2-${{ hashFiles('**/*.gradle*', '**/gradle.properties', 'gradle/libs.versions.toml', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: gradle-v2- restore-keys: gradle-v2-
- uses: actions/cache@v6
with:
path: ~/.m2/repository/org/robolectric
key: robolectric-m2-v1-${{ hashFiles('gradle/libs.versions.toml', 'app/src/test/resources/robolectric.properties') }}
restore-keys: robolectric-m2-v1-
- id: signing - id: signing
if: inputs.sign == 'true' if: inputs.sign == 'true'
shell: bash shell: bash
+2
View File
@@ -181,6 +181,8 @@ val demoScreenshotClass = "com.subtracks.ui.DemoScreenshotTest"
val queryTimingClass = "com.subtracks.data.db.QueryTimingMeasurementTest" val queryTimingClass = "com.subtracks.data.db.QueryTimingMeasurementTest"
tasks.withType<Test>().configureEach { tasks.withType<Test>().configureEach {
// Robolectric fetches its Android SDK jar itself, outside Gradle's repositories.
systemProperty("robolectric.dependency.repo.url", providers.gradleProperty("mavenCentralMirrorUrl").get())
if (name.endsWith("UnitTest")) { if (name.endsWith("UnitTest")) {
filter { filter {
(integrationTestClasses + demoScreenshotClass + queryTimingClass).forEach { excludeTestsMatching(it) } (integrationTestClasses + demoScreenshotClass + queryTimingClass).forEach { excludeTestsMatching(it) }
+2
View File
@@ -9,3 +9,5 @@ android.useAndroidX=true
android.nonTransitiveRClass=true android.nonTransitiveRClass=true
kotlin.code.style=official kotlin.code.style=official
mavenCentralMirrorUrl=https://maven-central.storage-download.googleapis.com/maven2/
+3 -2
View File
@@ -1,4 +1,5 @@
pluginManagement { pluginManagement {
val mavenCentralMirrorUrl = providers.gradleProperty("mavenCentralMirrorUrl").get()
repositories { repositories {
google { google {
content { content {
@@ -7,7 +8,7 @@ pluginManagement {
includeGroupByRegex("androidx.*") includeGroupByRegex("androidx.*")
} }
} }
maven("https://maven-central.storage-download.googleapis.com/maven2/") { maven(mavenCentralMirrorUrl) {
name = "MavenCentralMirror" name = "MavenCentralMirror"
} }
mavenCentral() mavenCentral()
@@ -19,7 +20,7 @@ dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories { repositories {
google() google()
maven("https://maven-central.storage-download.googleapis.com/maven2/") { maven(providers.gradleProperty("mavenCentralMirrorUrl").get()) {
name = "MavenCentralMirror" name = "MavenCentralMirror"
} }
mavenCentral() mavenCentral()