Updated: #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
push: | |
branches: [ workflow-github, master ] | |
paths-ignore: | |
- '*.md' | |
pull_request: | |
branches: [ master ] | |
paths-ignore: | |
- '*.md' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
cache-version: v1 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
api-level: [ 29 ] | |
shard: [ 1 ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4.1.7 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
cache: gradle | |
- name: Gradle cache | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Determine emulator target | |
id: determine-target | |
run: | | |
if [ ${{ matrix.api-level }} -ge 29 ]; then | |
echo "TARGET=default" >> $GITHUB_OUTPUT | |
else | |
echo "TARGET=google_apis" >> $GITHUB_OUTPUT | |
fi | |
- name: Output target | |
run: echo "The TARGET is ${{ steps.determine-target.outputs.TARGET }}" | |
- name: Wait for emulator to boot | |
run: adb wait-for-device | |
- name: AVD cache | |
uses: actions/cache@v4 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-ubuntu-${{ matrix.api-level }}-${{ env.cache-version }} | |
- name: Create AVD and generate snapshot for caching | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@v2.33.0 | |
with: | |
api-level: ${{ matrix.api-level }} | |
target: ${{ steps.determine-target.outputs.TARGET }} | |
arch: x86_64 | |
force-avd-creation: false | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: echo "Generated AVD snapshot for caching." | |
- name: Instrumentation tests | |
timeout-minutes: 60 | |
uses: reactivecircus/android-emulator-runner@v2.33.0 | |
with: | |
api-level: ${{ matrix.api-level }} | |
force-avd-creation: false | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: ./gradlew connectedCheck --stacktrace | |
- name: Run device tests | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
target: ${{ steps.determine-target.outputs.TARGET }} | |
arch: x86_64 | |
force-avd-creation: false | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
profile: Nexus One | |
script: | | |
adb shell wm density 240 | |
SKIP_ERRORPRONE=true SKIP_JAVADOC=true ./gradlew cAT --stacktrace -Dorg.gradle.workers.max=2 | |
- name: Upload test results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-results-${{ matrix.api-level }}-${{ steps.determine-target.outputs.TARGET }}-${{ matrix.shard }} | |
path: | | |
**/build/reports/* | |
**/build/outputs/*/connected/* | |
- name: Unit Tests | |
run: | | |
SKIP_ERRORPRONE=true SKIP_JAVADOC=true ./gradlew testDebugUnitTest \ | |
--stacktrace --continue \ | |
-Dorg.gradle.workers.max=2 | |