-
-
Notifications
You must be signed in to change notification settings - Fork 158
122 lines (109 loc) · 4.83 KB
/
android_tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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/**