-
Notifications
You must be signed in to change notification settings - Fork 76
112 lines (95 loc) · 3.68 KB
/
test.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
name: Test
on:
workflow_dispatch:
pull_request:
branches: [master]
jobs:
test:
name: Test on Java ${{ matrix.java-version }}
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# Android Command-line Tools versions depend on Java versions, so we need
# to specify exact versions.
# Learn more: https://stackoverflow.com/a/78890086/7009800
include:
- java-version: 8
android-clt-version: 9123335
- java-version: 11
android-clt-version: 9862592
- java-version: 17
android-clt-version: 11479570
env:
ANDROID_HOME: /home/runner/androidsdk
ANDROID_SDK_ROOT: /home/runner/androidsdk
ANDROID_OS_IMAGE: system-images;android-29;google_apis;x86_64
steps:
- name: Enable KVM group perms
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: Clone repository
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: ${{ matrix.java-version }}
cache: gradle
- name: Set up bartekpacia/scripts (for install_android_sdk script)
run: |
git clone https://github.com/bartekpacia/scripts.git $HOME/scripts
echo "$HOME/scripts/bin" >> $GITHUB_PATH
- name: Set up android-wait-for-emulator script
run: |
curl -fsSl -O https://raw.githubusercontent.com/travis-ci/travis-cookbooks/master/community-cookbooks/android-sdk/files/default/android-wait-for-emulator
chmod +x ./android-wait-for-emulator
mv ./android-wait-for-emulator $HOME/scripts/bin
- name: Set up Android Command-line Tools
run: |
install_android_sdk https://dl.google.com/android/repository/commandlinetools-linux-${{ matrix.android-clt-version }}_latest.zip
echo "$ANDROID_HOME/cmdline-tools/latest/bin:$PATH" >> $GITHUB_PATH
- name: Set up Android SDK components
run: |
yes | sdkmanager --install emulator
echo "$ANDROID_HOME/emulator" >> $GITHUB_PATH
yes | sdkmanager --install "platform-tools"
echo "$ANDROID_HOME/platform-tools" >> $GITHUB_PATH
yes | sdkmanager --install "platforms;android-29"
yes | sdkmanager --install "$ANDROID_OS_IMAGE"
- name: Create AVD
run: |
avdmanager -s create avd \
--package "$ANDROID_OS_IMAGE" \
--name "MyAVD"
cat << EOF >> ~/.android/avd/MyAVD.avd/config.ini
hw.cpu.ncore=2
hw.gpu.enabled=yes
hw.gpu.mode=swiftshader_indirect
hw.ramSize=3072
disk.dataPartition.size=4G
vm.heapSize=576
hw.lcd.density=440
hw.lcd.height=2220
hw.lcd.width=1080
EOF
- name: Run AVD
run: |
emulator @MyAVD \
-verbose -no-snapshot-save -no-window -noaudio -no-boot-anim -accel on -camera-back none -gpu swiftshader_indirect \
>~/emulator_stdout.log \
2>~/emulator_stderr.log &
- name: Wait for AVD to start up
run: |
android-wait-for-emulator
# This is also a prerequiste
while true; do
adb shell service list | grep 'package' && echo 'service "package" is active!' && break
echo 'waiting for service "package" to start'
sleep 1
done
- name: Run tests
run: ./gradlew nativeTest