-
Notifications
You must be signed in to change notification settings - Fork 79
192 lines (168 loc) · 6.46 KB
/
emulator.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: Test nix-on-droid in an emulator
on:
pull_request:
push:
schedule:
- cron: 0 0 * * 1
jobs:
prepare-droidctl:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
path: ${{ steps.droidctl-build.outputs.path }}
steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Configure Nix magic cache
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build droidctl
id: droidctl-build
run: |
nix build 'github:t184256/droidctl' --out-link /tmp/droidctl
echo "path=$(realpath /tmp/droidctl)" >> "$GITHUB_OUTPUT"
prepare-n-o-d:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Setup cachix
uses: cachix/cachix-action@v14
with:
name: nix-on-droid
- name: Configure Nix magic cache
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Checkout repository
uses: actions/checkout@v4
- name: Build zipball and channel tarball to inject (n-o-d)
id: injection-build
run: |
rm -rf n-o-d
mkdir -p n-o-d
git -C . archive --format=tar.gz --prefix n-o-d/ HEAD > n-o-d/archive.tar.gz
ARCHES=x86_64 nix run '.#deploy' -- file:///data/local/tmp/n-o-d/archive.tar.gz n-o-d/
tar cf n-o-d.tar n-o-d
- name: Store zipball and channel tarball to inject (n-o-d)
uses: actions/upload-artifact@v4
with:
name: n-o-d.tar
path: n-o-d.tar
retention-days: 2
prepare-avd:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: false
matrix:
api-level: [29] # keep in sync
steps:
- name: Configure AVD cache
id: avd-cache
uses: actions/cache@v4
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-test-${{ matrix.api-level }}
- name: Enable KVM
if: matrix.api-level == 29 && steps.avd-cache.outputs.cache-hit != 'true'
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: Create AVD and generate snapshot for caching
if: matrix.api-level == 29 && steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
# ! Keep in sync with the other one,
# ! but w/o -no-snapshot-save and with disable-animations: false
target: default
arch: x86_64
api-level: ${{ matrix.api-level }}
disk-size: 8G
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
emulate:
needs:
- prepare-droidctl
- prepare-n-o-d
- prepare-avd
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
api-level: [29] # keep in sync
# below 28: bootstrap didn't start, IDK why
# 34: sometimes work, but doesn't seem stable, even w/o caching images
script:
- android_integration
- bootstrap_flakes
- bootstrap_channels
- poke_around
- test_channels_uiautomator
- test_channels_shell
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Retrieve zipball and channel tarball to inject (n-o-d)
uses: actions/download-artifact@v4
with:
name: n-o-d.tar
- name: Unpack zipball and channel tarball to inject (n-o-d)
run: tar xf n-o-d.tar
- name: Install Nix / enable KVM
uses: DeterminateSystems/nix-installer-action@main
- name: Configure Nix magic cache
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Fetch droidctl (using previous eval)
id: droidctl-fetch
env:
DROIDCTL: ${{needs.prepare-droidctl.outputs.path}}
run: nix build "$DROIDCTL" --out-link /tmp/droidctl
continue-on-error: true # GitHub Actions can throttle magic-nix-cache
- name: Build droidctl (anew, fallback)
if: always() && (steps.droidctl-fetch.outcome == 'failure')
run: nix build 'github:t184256/droidctl' --out-link /tmp/droidctl
- name: Restore AVD cache
id: avd-cache
if: matrix.api-level == 29 # tested, robust with kill workaround
uses: actions/cache/restore@v4
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-test-${{ matrix.api-level }}
- name: Test script=${{ matrix.script }} api-level=${{ matrix.api-level }}
uses: reactivecircus/android-emulator-runner@v2
with:
target: default
arch: x86_64
api-level: ${{ matrix.api-level }}
disk-size: 8G
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
# https://github.com/ReactiveCircus/android-emulator-runner/issues/385
script: >
trap 'pkill --exact --echo --signal SIGKILL crashpad_handle || true' EXIT &&
adb shell 'rm -rf /data/local/tmp/n-o-d' &&
adb push n-o-d /data/local/tmp/ &&
echo 'pushed' &&
adb shell 'cd /data/local/tmp/n-o-d && tar xzof archive.tar.gz && mv n-o-d unpacked' &&
echo 'unpacked' &&
cd tests/emulator &&
adb shell settings put secure enabled_accessibility_services com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService &&
echo 'ready' &&
/tmp/droidctl/bin/droidctl run ${{ matrix.script }}.py
# TODO: push to cachix from within the emulator?
# would be of use on aarch64, not x86_64
- name: Upload screenshots
if: always()
uses: actions/upload-artifact@v4
with:
name: screenshots-${{ matrix.script }}-${{ matrix.api-level }}
path: tests/emulator/screenshots
if-no-files-found: warn # 'error' or 'ignore' are also available