Skip to content

Android Emulator Tests #15

Android Emulator Tests

Android Emulator Tests #15

name: Android Emulator Tests
on:
workflow_run:
workflows: ["Android CI"]
types:
- completed
branches:
- main
workflow_dispatch: {}
jobs:
test:
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
api-level: [35]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/common-setup
- name: Enable KVM
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: Gradle cache
uses: gradle/actions/setup-gradle@v4
- name: AVD cache
uses: actions/cache@v4
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: ./.github/actions/emulator-step
with:
api-level: ${{ matrix.api-level }}
script: echo "Generated AVD snapshot for caching."
- name: Build app and test APKs
run: ./gradlew assembleDebug assembleDebugAndroidTest
- name: Run instrumented tests
uses: ./.github/actions/emulator-step
with:
api-level: ${{ matrix.api-level }}
script: ./gradlew connectedDebugAndroidTest -x assembleDebug -x assembleDebugAndroidTest
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.api-level }}
path: app/build/reports/androidTests
- name: Publish test results
uses: mikepenz/action-junit-report@v5
if: always()
with:
report_paths: 'app/build/outputs/androidTest-results/connected/**/*.xml'