From 62d9defefba8b549e0cbc8901c72ef29ea797c68 Mon Sep 17 00:00:00 2001 From: Neo-Desktop <321592+Neo-Desktop@users.noreply.github.com> Date: Sat, 28 Nov 2026 19:25:36 +0000 Subject: [PATCH] CI: Robolectric's jars through Gradle; the bump on the latest main Android's unit tests fail on main (runs 411, 413, 417, 419, 424): each Robolectric test fails in MavenArtifactFetcher with an IOException. Robolectric downloads its Android framework jars (about 200 MB each) during the tests, and Maven Central refuses some downloads with HTTP 429 (its rate limit). Now Gradle downloads the two jars that the tests use (SDK 28 and SDK 35), with its retries and its cache, and Robolectric runs offline from their directory. -ProbolectricRepoUrl= still makes Robolectric download them itself from that mirror. Gradle tries a refused download again, up to 6 times (gradle.properties). The D-Modem bump checked out the commit that its event names. A run that waited for the run before it therefore built on an old main, and its pull request (#103) conflicted with the one that the earlier run merged (#102). Now it checks out main as it is when the run starts. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B82eRSYSk1rgeTZ9ZWMcZL Signed-off-by: Neo-Desktop <321592+Neo-Desktop@users.noreply.github.com> --- .github/workflows/d-modem-bump.yml | 3 +++ app/build.gradle.kts | 33 +++++++++++++++++++++++++++--- gradle.properties | 4 ++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/.github/workflows/d-modem-bump.yml b/.github/workflows/d-modem-bump.yml index bb02989..a9b43a3 100644 --- a/.github/workflows/d-modem-bump.yml +++ b/.github/workflows/d-modem-bump.yml @@ -51,9 +51,12 @@ jobs: exit 1 fi + # main as it is now, not the commit the event names: a run that waited for the one before it + # (concurrency) builds on the main that the earlier run merged into, and does not conflict with it - uses: actions/checkout@v6 with: token: ${{ secrets.DMODEM_BUMP_TOKEN }} + ref: main fetch-depth: 0 # only the D-Modem submodule (proot stays where it is) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 7aa3d7a..60577c7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -201,10 +201,37 @@ val buildHostSsh = tasks.register("buildHostSsh") { ) } -// Robolectric fetches its Android framework jars itself: -ProbolectricRepoUrl= to fetch them elsewhere +// Robolectric's Android framework jars (android-all-instrumented, about 200 MB each), one for each SDK +// that a test's @Config names (app/src/test). Gradle downloads them, with its retries and its cache +// (CI's setup-gradle keeps the cache). Robolectric then runs offline from their directory. +// Without this, Robolectric downloads them itself during the tests, and Maven Central's rate limit +// (HTTP 429) makes each Robolectric test fail. +// A new SDK in a test's @Config: add its jar here. Robolectric's DefaultSdkProvider gives the version +// for its release (libs.versions.toml): "-robolectric--i". +// -ProbolectricRepoUrl=: Robolectric downloads them itself from that mirror instead. +val robolectricJars = configurations.create("robolectricJars") { + isTransitive = false + isCanBeConsumed = false +} +dependencies { + // SDK 28 (Android 9) and SDK 35 (Android 15), Robolectric 4.17's jars + robolectricJars("org.robolectric:android-all-instrumented:9-robolectric-4913185-2-i7") + robolectricJars("org.robolectric:android-all-instrumented:15-robolectric-13954326-i7") +} +val robolectricJarsDir = layout.buildDirectory.dir("robolectric-jars") +val syncRobolectricJars = tasks.register("syncRobolectricJars") { + description = "Copies Robolectric's Android framework jars to one directory, for its offline mode" + from(robolectricJars) + into(robolectricJarsDir) +} +val robolectricRepoUrl = providers.gradleProperty("robolectricRepoUrl").orNull tasks.withType().configureEach { - providers.gradleProperty("robolectricRepoUrl").orNull?.let { - systemProperty("robolectric.dependency.repo.url", it) + if (robolectricRepoUrl != null) { + systemProperty("robolectric.dependency.repo.url", robolectricRepoUrl) + } else { + dependsOn(syncRobolectricJars) + systemProperty("robolectric.offline", "true") + systemProperty("robolectric.dependency.dir", robolectricJarsDir.get().asFile.path) } // the SSH client's JNI library built for the host (native-ssh), for the SSH tests dependsOn(buildHostSsh) diff --git a/gradle.properties b/gradle.properties index 5299c5f..a63faaa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,3 +3,7 @@ org.gradle.caching=true android.useAndroidX=true android.nonTransitiveRClass=true kotlin.code.style=official +# A download that Maven Central refuses for a short time (HTTP 429, its rate limit): Gradle tries it again, +# up to 6 times, waiting 2 s, then 4 s, and so on (Robolectric's large jars: app/build.gradle.kts) +systemProp.org.gradle.internal.repository.max.retries=6 +systemProp.org.gradle.internal.repository.initial.backoff=2000