-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
19 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: "Run Android emulator tests" | ||
description: "Setups android emulator caching and running" | ||
inputs: | ||
api-level: | ||
description: Android API level for testing | ||
required: true | ||
cache-disabled: | ||
description: When 'true', all caching is disabled. No entries will be written to or read from the cache. | ||
required: false | ||
default: false | ||
cache-read-only: | ||
description: | | ||
When 'true', existing entries will be read from the cache but no entries will be written. | ||
By default this value is 'false' for workflows on the `dev` branch and 'true' for workflows on other branches. | ||
required: false | ||
default: ${{ github.ref_name != 'dev' }} | ||
additional-arguments: | ||
description: Additional arguments for running connectedCheck | ||
required: false | ||
default: '' | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Build tests | ||
uses: gradle/gradle-build-action@v2 | ||
with: | ||
arguments: packageDebugAndroidTest --continue --configuration-cache | ||
cache-disabled: ${{ inputs.cache-disabled }} | ||
cache-read-only: ${{ inputs.cache-read-only }} | ||
|
||
#TODO: make AVD cache respect disabled and read-only (https://github.com/actions/cache/blob/main/save/README.md) | ||
- name: AVD cache | ||
uses: actions/cache@v3 | ||
id: avd-cache | ||
with: | ||
path: | | ||
~/.android/avd/* | ||
~/.android/adb* | ||
key: avd-${{ inputs.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: | ||
force-avd-creation: false | ||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | ||
arch: x86_64 | ||
api-level: ${{ inputs.api-level }} | ||
script: echo "Generated AVD snapshot for caching." | ||
|
||
- name: Run tests | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
force-avd-creation: false | ||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save | ||
arch: x86_64 | ||
api-level: ${{ inputs.api-level }} | ||
script: ./gradlew connectedCheck --continue --configuration-cache ${{ inputs.additional-arguments }} | ||
|
||
# Android test failures are not available in gradle build scans | ||
- name: Upload test reports | ||
if: success() || failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: test-reports-${{ inputs.api-level }} | ||
path: '**/build/reports/androidTests' |
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