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