Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}
Expand Down
6 changes: 6 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion scripts/analysis/lint-results.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 14 warnings</span>
<span class="mdl-layout-title">Lint Report: 17 warnings</span>
Loading