diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 9036833a51e..dc293bb238c 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -36,27 +36,44 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1 - - name: Read the Robolectric version + # The cache holds one jar per SDK level the tests run on (@Config(sdk = [..])). Its key names the levels, so + # a test on a new level gets a new cache instead of downloading that jar on every run. + - name: Read the Robolectric version and SDK levels id: robolectric - run: echo "version=$(grep -oP 'org\.robolectric:robolectric:\K[0-9.]+' app/build.gradle.kts)" >> "$GITHUB_OUTPUT" + run: | + { + echo "version=$(grep -oP 'org\.robolectric:robolectric:\K[0-9.]+' app/build.gradle.kts)" + echo "sdks=$(grep -rhoP 'sdk\s*=\s*\[\K[0-9, ]+' app/src/test | tr -d ' ' | tr ',' '\n' | sort -un | paste -sd- -)" + } >> "$GITHUB_OUTPUT" - name: Restore the Robolectric Android SDK jars id: robolectric-cache uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.m2/repository/org/robolectric - key: robolectric-sdks-${{ runner.os }}-${{ steps.robolectric.outputs.version }} + key: robolectric-sdks-${{ runner.os }}-${{ steps.robolectric.outputs.version }}-${{ steps.robolectric.outputs.sdks }} - name: Run unit tests with coverage run: ./gradlew --no-daemon testGplayDebugUnit + # A cache is never replaced once its key exists, so only one with a jar for every SDK level is saved. + - name: Check the Robolectric Android SDK jars + id: robolectric-jars + if: ${{ always() && steps.robolectric-cache.outputs.cache-hit != 'true' }} + env: + SDKS: ${{ steps.robolectric.outputs.sdks }} + run: | + jars=$(find ~/.m2/repository/org/robolectric/android-all-instrumented -name '*.jar' 2>/dev/null | wc -l) + levels=$(echo "$SDKS" | tr '-' '\n' | wc -l) + echo "complete=$([ "$jars" -ge "$levels" ] && echo true || echo false)" >> "$GITHUB_OUTPUT" + # Saved even when the suite fails, so a red run still leaves the jars behind. - name: Save the Robolectric Android SDK jars - if: ${{ always() && steps.robolectric-cache.outputs.cache-hit != 'true' }} + if: ${{ always() && steps.robolectric-jars.outputs.complete == 'true' }} uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.m2/repository/org/robolectric - key: robolectric-sdks-${{ runner.os }}-${{ steps.robolectric.outputs.version }} + key: robolectric-sdks-${{ runner.os }}-${{ steps.robolectric.outputs.version }}-${{ steps.robolectric.outputs.sdks }} - name: Upload test artifacts if: ${{ failure() }} diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2d16654afaf..da64a8770b7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -108,6 +108,12 @@ android { // Gradle's 512m default is too small for the Robolectric suites it.maxHeapSize = "2g" it.testLogging.events("started", "failed", "skipped") + // Robolectric downloads its Android SDK jars itself, from Maven Central unless told otherwise. Take + // them from the mirror the build uses too, see build.gradle; Robolectric checks their SHA-512. + it.systemProperty( + "robolectric.dependency.repo.url", + "https://maven-central.storage-download.googleapis.com/maven2/" + ) } unitTests.isReturnDefaultValues = true } diff --git a/build.gradle b/build.gradle index 4f2927f46fe..41083640dfb 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,9 @@ buildscript { repositories { google() gradlePluginPortal() + // Google's mirror of Maven Central, first: Maven Central rate-limits the CI runners (HTTP 429). The dependency + // verification in gradle/verification-metadata.xml checks each artifact, whichever repository serves it. + maven { url = 'https://maven-central.storage-download.googleapis.com/maven2/' } mavenCentral() } @@ -42,6 +45,9 @@ configurations.configureEach { allprojects { repositories { google() + // Google's mirror of Maven Central, first: Maven Central rate-limits the CI runners (HTTP 429). The dependency + // verification in gradle/verification-metadata.xml checks each artifact, whichever repository serves it. + maven { url = 'https://maven-central.storage-download.googleapis.com/maven2/' } mavenCentral() maven { url = 'https://jitpack.io' diff --git a/scripts/analysis/lint-results.txt b/scripts/analysis/lint-results.txt index b1a91c63f74..8f8c5f61165 100644 --- a/scripts/analysis/lint-results.txt +++ b/scripts/analysis/lint-results.txt @@ -1,2 +1,2 @@ DO NOT TOUCH; GENERATED BY DRONE - Lint Report: 14 warnings + Lint Report: 17 warnings