22# we run as the primary example for this project.
33name : Pull Request Validation
44on : [pull_request]
5+ concurrency :
6+ group : ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
7+ cancel-in-progress : true
58
69jobs :
7- # Run Lint and Unit Tests
8- test :
9- runs-on : ubuntu-latest
10- steps :
11- - uses : actions/checkout@v6
12- - uses : gradle/actions/wrapper-validation@v5
13-
14- - name : set up JDK
15- uses : actions/setup-java@v5
16- with :
17- distribution : ' zulu'
18- java-version : ' 21'
19- cache : ' gradle'
20-
21- - name : Lint
22- run : ./gradlew clean lint
23-
24- - name : Unit Test
25- run : ./gradlew clean test
26-
27- # Run instrumented test cases
28- android :
10+ verify :
2911 runs-on : ubuntu-latest
3012
3113 strategy :
@@ -41,17 +23,51 @@ jobs:
4123 with :
4224 distribution : ' zulu'
4325 java-version : ' 21'
44- cache : ' gradle'
4526
46- - name : Enable KVM group perms (needed for reactivecircus/android-emulator-runner below)
27+ - uses : gradle/actions/setup-gradle@v5
28+
29+ - name : Unit Testing and Linting
30+ run : ./gradlew lintDebug testDebugUnitTest --parallel --continue --build-cache --configuration-cache-problems=warn
31+
32+ - name : Enable KVM group perms
4733 run : |
4834 echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
4935 sudo udevadm control --reload-rules
5036 sudo udevadm trigger --name-match=kvm
5137
38+ - name : AVD Cache
39+ uses : actions/cache@v5
40+ id : avd-cache
41+ with :
42+ path : |
43+ ~/.android/avd/*
44+ ~/.android/adb*
45+ key : avd-${{ matrix.api-level }}
46+
47+ - name : Create and Cache AVD
48+ if : steps.avd-cache.outputs.cache-hit != 'true'
49+ uses : reactivecircus/android-emulator-runner@v2
50+ with :
51+ api-level : ${{ matrix.api-level }}
52+ arch : x86_64
53+ force-avd-creation : false
54+ emulator-options : -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
55+ disable-animations : false
56+ script : echo "Generated AVD snapshot for caching."
57+
5258 - name : Run Instrumented Tests
5359 uses : reactivecircus/android-emulator-runner@v2
5460 with :
5561 api-level : ${{ matrix.api-level }}
5662 arch : x86_64
57- script : ./gradlew connectedCheck
63+ force-avd-creation : false
64+ disable-animations : true
65+ emulator-options : -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
66+ script : ./gradlew connectedCheck --build-cache --configuration-cache-problems=warn
67+
68+ - name : Upload Artifacts on Failure
69+ uses : actions/upload-artifact@v6
70+ if : failure()
71+ with :
72+ name : build-${{ matrix.api-level }}
73+ path : app/build/
0 commit comments