Tests #359
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: Run tests | |
on: | |
pull_request: | |
branches: | |
- 'master' | |
push: | |
branches: | |
- 'master' | |
paths-ignore: | |
- 'app/build.gradle' | |
- 'metadata/**' | |
- 'app/src/main/res/layout/dialog_whats_new.xml' | |
workflow_dispatch: | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
api-level: [34] | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- 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: Restore/create Gradle cache | |
uses: gradle/actions/setup-gradle@v3 | |
- name: AVD cache | |
uses: actions/cache@v4 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ matrix.api-level }} | |
save-always: true | |
- 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 }} | |
target: google_apis | |
arch: x86_64 | |
force-avd-creation: false | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -metrics-collection | |
disable-animations: true | |
disable-spellchecker: true | |
profile: Nexus 6 | |
script: ./gradlew assemblePremiumDebug --no-watch-fs --build-cache | |
- name: Save AVD to cache | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v4 | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ matrix.api-level }} | |
- name: Add Dropbox API credentials | |
shell: bash | |
run: | | |
echo "dropbox.refresh_token = \"${{ secrets.DROPBOX_REFRESH_TOKEN }}\"" >> app.properties | |
echo "dropbox.app_key = \"${{ secrets.DROPBOX_APP_KEY }}\"" >> app.properties | |
- name: Run tests | |
id: testing | |
uses: reactivecircus/android-emulator-runner@v2 | |
continue-on-error: true | |
with: | |
api-level: ${{ matrix.api-level }} | |
target: google_apis | |
arch: x86_64 | |
force-avd-creation: false | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -metrics-collection | |
disable-animations: true | |
disable-spellchecker: true | |
profile: Nexus 6 | |
# Tests should use the build which includes Dropbox code. | |
script: | | |
adb logcat -c # clear logs | |
touch app/emulator.log # create log file | |
chmod 777 app/emulator.log # allow writing to log file | |
adb logcat >> app/emulator.log & # pipe all logcat messages into log file as a background process | |
./gradlew connectedPremiumDebugAndroidTest --no-watch-fs --build-cache --info | |
- name: Upload Failing Test Report Log | |
if: steps.testing.outcome != 'success' # upload the generated log on failure of the tests job | |
uses: actions/upload-artifact@v2 | |
with: | |
name: logs | |
path: app/emulator.log # path to where the log is | |
- name: Raise error on test fail # set a red tick on the workflow run if the tests failed | |
if: steps.testing.outcome != 'success' | |
run: exit 1 |