Merge pull request #546 from weblate/weblate-no-nonsense-notes-androi… #261
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: Android tests | |
on: | |
push: | |
branches: [ "master" ] | |
# runs when you commit to the master branch and when merging pull requests. | |
# Not on receiving pull requests, as it would be a waste. | |
paths-ignore: | |
- '**.md' | |
- '.github/**' | |
- '!.github/workflows/build.yml' | |
jobs: | |
# this job runs all the tests | |
job_tests: | |
if: github.repository == 'spacecowboy/NotePad' # no need to run it on forks | |
timeout-minutes: 45 # test jobs take ~11 minutes each. We give time to download the AVD images | |
continue-on-error: true # run tests for ALL configurations, don't stop at the 1° failure | |
strategy: | |
matrix: | |
# test on emulators with these Android API versions. They all have ATD images. | |
api-level: [ 30, 31, 32, 33, 34 ] | |
# use stripped-down, test-friendly Android OS images without, or with, google apps | |
target: [ aosp_atd, google_atd ] | |
# profile: [ 5.1in WVGA, 10.1in WXGA ] # TODO you can also test with phones and tablets! | |
runs-on: ubuntu-latest # List of installed software: | |
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md | |
permissions: | |
contents: read | |
steps: | |
- name: perform the checkout | |
uses: actions/checkout@v4 | |
- name: perform the set up for the JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: temurin | |
- name: perform the validation | |
continue-on-error: true | |
uses: gradle/actions/wrapper-validation@v3 | |
- name: perform Gradle setup & caching | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Check for hardware acceleration availability | |
continue-on-error: true | |
# Read the console logs for the result. The android emulator can't use | |
# acceleration, according to the logs. No you can't install HAXM. | |
run: $ANDROID_HOME/emulator/emulator -accel-check | |
- name: Enable KVM group perms as required by reactivecircus/android-emulator-runner | |
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: perform AVD caching | |
uses: actions/cache@v4 | |
id: avd-cache | |
# they appear in | |
# https://github.com/spacecowboy/NotePad/actions/caches?query=sort%3Asize-desc | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ matrix.api-level }}-${{ matrix.target }} | |
- name: create AVD and generate snapshot for caching | |
# here it automatically installs the needed android SDK components | |
# see https://github.com/ReactiveCircus/android-emulator-runner/blob/main/README.md | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
target: ${{ matrix.target }} | |
profile: 5.1in WVGA # low resolution: faster. This has no software buttons | |
arch: x86_64 | |
disk-size: 2G # needed for saving org and json files. We need 2 GB for API 34 | |
force-avd-creation: false | |
# The emulator is picky on these parameters. For... | |
# tests with "-accel on": see github run #84 | |
# tests with "-gpu host": the emulators never boot! | |
# tests with "-gpu off": see github run #87, faster & more stable | |
emulator-options: -no-boot-anim -no-window -gpu off | |
disable-animations: true | |
disable-spellchecker: true | |
# starts the emulator, runs this script, then closes the emulator | |
script: echo "Generated AVD snapshot for caching." | |
- name: perform the Gradle build | |
run: ./gradlew build | |
- name: run custom tasks for additional checks | |
run: ./gradlew checkLanguages checkFastlane | |
- name: make the emulator script executable | |
run: chmod +x github_on_emu_started.sh | |
- name: run the tests | |
# note that by now the app is already built | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
target: ${{ matrix.target }} | |
arch: x86_64 | |
profile: 5.4in FWVGA | |
disk-size: 500M | |
force-avd-creation: false | |
disable-animations: true | |
disable-spellchecker: true | |
emulator-options: -no-snapshot-save -verbose -no-boot-anim -no-window -gpu off | |
script: bash ./github_on_emu_started.sh | |
- name: upload the generated files | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: files-api${{ matrix.api-level }}-${{ matrix.target }} | |
path: | | |
logcat-dump.txt | |
app/build/reports/androidTests/** |