Skip to content

Update example app version #2596

Update example app version

Update example app version #2596

name: Android
on:
workflow_dispatch:
workflow_call:
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL: 60
permissions:
contents: read
jobs:
emulator:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
api-level:
- 29
working-directory: ['.', 'examples/ExampleApp']
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Setup Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: 'adopt'
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
# Cache the emulator
- name: AVD cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: create AVD and generate snapshot for caching
if: ${{ steps.avd-cache.outputs.cache-hit != 'true' }}
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2.37.0
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
disable-animations: false
script: echo 'Generated AVD snapshot for caching.'
- name: Run tests on android emulator
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2.37.0
if: matrix.working-directory == 'examples/ExampleApp'
with:
working-directory: ${{ matrix.working-directory }}
api-level: ${{ matrix.api-level }}
# Grab the failures from the device so we can include them in results. Exit with non-zero so GH checks still fail.
script: ./gradlew connectedCheck -x :app:benchmark:connectedBenchmarkAndroidTest
- name: Run tests on android emulator
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2.37.0
if: matrix.working-directory != 'examples/ExampleApp'
with:
working-directory: ${{ matrix.working-directory }}
api-level: ${{ matrix.api-level }}
# Grab the failures from the device so we can include them in results. Exit with non-zero so GH checks still fail.
script: ./gradlew connectedCheck -x :embrace-microbenchmark:connectedCheck --stacktrace || (adb logcat '[Embrace]:d' '*:S' -t 100000 > emulator_logcat.log && adb pull /storage/emulated/0/Android/data/io.embrace.android.embracesdk.test/cache/test_failure/ && exit 127)
- name: Archive Test Results
if: ${{ always() && matrix.working-directory == '.' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: android-emulator-${{ matrix.working-directory }}-test-results
path: |
embrace-android-sdk/build/reports/androidTests/connected
test_failure
emulator_logcat.log