fix(ci): Robolectric's jar cache restores on every runner (#3134)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-24 02:49:49 -05:00
1 parent 7905e2f8ba
commit 627344ea30
1 file changed
+18 -2
+18 -2
View File
@@ -697,11 +697,27 @@ jobs:
run: |
echo "version=$(grep -o "org.robolectric:robolectric:[0-9.]*" app/build.gradle | cut -d: -f3)" >> "$GITHUB_OUTPUT"
# Robolectric downloads these from Maven Central on first use without retrying, and 429s fail whole test classes.
# The cache path sits beside the workspace because runner homes are at different depths from it, and
# actions/cache stores paths relative to the workspace. Runners that keep their own ~/.m2 skip the cache.
- name: Place Robolectric's Android jars beside the workspace
id: robolectric-jars
run: |
set -euo pipefail
jars="$GITHUB_WORKSPACE/../robolectric-jars"
m2="$HOME/.m2/repository/org/robolectric/android-all-instrumented"
if [ -d "$m2" ] && [ ! -L "$m2" ]; then
echo "cache=false" >> "$GITHUB_OUTPUT"
else
mkdir -p "$jars" "$(dirname "$m2")"
ln -sfn "$(cd "$jars" && pwd)" "$m2"
echo "cache=true" >> "$GITHUB_OUTPUT"
fi
- name: Cache Robolectric's Android jars
if: steps.robolectric-jars.outputs.cache == 'true'
uses: actions/cache@v4
with:
path: ~/.m2/repository/org/robolectric/android-all-instrumented
key: robolectric-android-all-${{ steps.robolectric.outputs.version }}
path: ../robolectric-jars
key: robolectric-android-all-v2-${{ steps.robolectric.outputs.version }}
- name: Unit tests
id: unit-tests
env: