Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Android instrumentation tests on GitHub Actions #6083

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/android-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Gradle Android tests

on:
push:
branches:
- "master"
- "actions-instrumentation-tests"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be removed before merging:

Suggested change
- "actions-instrumentation-tests"

workflow_dispatch:

jobs:
android-test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- api-level: 34
jdk-version: 21
arch: x86_64
steps:
- uses: actions/checkout@v4

- name: Set up JDK ${{ matrix.jdk-version }}
uses: actions/setup-java@v4
with:
java-version: '${{ matrix.jdk-version }}'
distribution: 'temurin'

- uses: gradle/actions/setup-gradle@v3

- 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: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.jdk-version }}-${{ matrix.api-level }}

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: ${{ matrix.arch }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: Run Android instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: ${{ matrix.arch }}
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 :app:connectedDebugAndroidTest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test with Gradle
name: Gradle unit tests

on:
push:
Expand All @@ -7,7 +7,7 @@ on:
workflow_dispatch:

jobs:
test:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -20,5 +20,5 @@ jobs:

- uses: gradle/actions/setup-gradle@v3

- name: Test with Gradle
- name: Run unit tests with Gradle
run: ./gradlew test
Loading