diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 2151c5caa39..1cac07a1474 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -36,9 +36,28 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0 + - name: Read the Robolectric version + id: robolectric + run: echo "version=$(grep -oP 'org\.robolectric:robolectric:\K[0-9.]+' app/build.gradle.kts)" >> "$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 }} + - name: Run unit tests with coverage run: ./gradlew --no-daemon testGplayDebugUnit + # 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' }} + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ~/.m2/repository/org/robolectric + key: robolectric-sdks-${{ runner.os }}-${{ steps.robolectric.outputs.version }} + - name: Upload test artifacts if: ${{ failure() }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2