-
Notifications
You must be signed in to change notification settings - Fork 29
175 lines (138 loc) · 6.28 KB
/
ci_emulator_run.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
name: Emulator Run CI
on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
concurrency:
group: emulator-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
macos-latest-run-v-examples:
runs-on: macOS-latest
timeout-minutes: 45
env:
VAB_FLAGS: -cg -f '-d no_load_styles' -v 3 --api 30 --build-tools 29.0.0 --device auto --log-clear --archs x86_64
steps:
- uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 8
- name: Install V
uses: vlang/setup-v@v1
with:
check-latest: true
- name: Checkout vab
uses: actions/checkout@v2
with:
path: vab
- name: Simulate "v install vab"
run: mv vab ~/.vmodules
- name: Run tests
run: v test ~/.vmodules/vab
- name: Build vab with -prod
run: v -prod ~/.vmodules/vab
- name: Build vab
run: v -g ~/.vmodules/vab
- name: Symlink vab
run: sudo ln -s ~/.vmodules/vab/vab /usr/local/bin/vab
- name: Run vab --help
run: vab --help
- name: Install AAB dependencies
run: |
vab install bundletool
vab install aapt2
- name: Run vab doctor
run: vab doctor
- name: Cache emulator
id: cache-emulator
uses: actions/cache@v2
with:
path: |
/Users/runner/.android/avd
/Users/runner/Library/Android/sdk/system-images/android-30
key: ${{ runner.os }}-android-emulator-${{ hashFiles('/Users/runner/.android/avd') }}
- name: Prepare emulator
if: steps.cache-emulator.outputs.cache-hit != 'true'
run: |
export ANDROID_SDK_ROOT="$HOME/Library/Android/sdk"
echo yes | $ANDROID_SDK_ROOT/tools/bin/sdkmanager 'system-images;android-30;google_apis;x86_64'
echo no | $ANDROID_SDK_ROOT/tools/bin/avdmanager create avd --force --name test --abi google_apis/x86_64 --package 'system-images;android-30;google_apis;x86_64'
- name: Install and run V + V UI examples as APK and AAB
run: |
export ANDROID_SDK_ROOT="$HOME/Library/Android/sdk"
export ANDROID_NDK_ROOT="$ANDROID_SDK_ROOT/ndk-bundle"
# Don't set Java > 8 here (emulator can't be started otherwise, lol) #export JAVA_HOME=$JAVA_HOME_11_X64
#pgrep emulator >/dev/null 2>&1 ||
$ANDROID_SDK_ROOT/emulator/emulator -avd test -no-snapshot -no-window -no-boot-anim -camera-back emulated -camera-front emulated -gpu swiftshader_indirect &
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
# Remove packages here if cache is run, and emulator failed
# Debugging
#export ADB_TAGS="SOKOL_APP:D"
#export ADB_TAGS="$ADB_TAGS V_ANDROID:D v_test_app:D"
echo "Installing V examples"
git clone --depth 1 https://github.com/vlang/v
# Test deployment of single file *after* build
vab --name "V DEPLOY TEST APK" v/examples/gg/bezier.v && vab v_deploy_test_apk.apk
vab --package aab --name "V DEPLOY TEST AAB" v/examples/gg/bezier.v && vab v_deploy_test_aab.aab
# 'flappylearning' can build but running is currently broken on Android
# Skip fireworks for now
declare -a v_examples=('2048' 'tetris' 'sokol/particles' 'sokol/drawing.v' 'sokol/freetype_raven.v' 'gg/bezier.v' 'gg/bezier_anim.v' 'gg/polygons.v' 'gg/raven_text_rendering.v' 'gg/rectangles.v' 'gg/stars.v' 'gg/worker_thread.v')
echo "Compiling V examples ${v_examples[@]}"
for example in "${v_examples[@]}"; do
#path_safe_name=$( echo "$example" | sed 's%/%-%' | sed 's%\.%-%' )
package_id=$( echo "$example" | sed 's%/%%' | sed 's%\.%%' )
package_id=$( echo "v$package_id" )
# APK
echo "Compiling apk from examples/$example ($package_id)"
vab --package-id "io.v.apk.$package_id" run v/examples/$example
# AAB
echo "Compiling aab from examples/$example ($package_id)"
vab --package aab --package-id "io.v.aab.$package_id" run v/examples/$example
# Remove app in case cache is run
adb uninstall "io.v.apk.$package_id"
adb uninstall "io.v.aab.$package_id"
done
# Output test
echo "Testing if v/examples/tetris can run..."
vab -g --package-id "io.v.ci.vab.apk.examples.tetris" run v/examples/tetris
sleep 5
adb -e logcat -d > /tmp/logcat.dump.txt
echo "Looking for traces of SOKOL_APP ok ..."
cat /tmp/logcat.dump.txt | grep -q 'SOKOL_APP: ... ok'; if [ ! $? -eq 0 ]; then cat /tmp/logcat.dump.txt; fi
# Remove app in case cache is run
echo "Uninstalling v/examples/tetris"
adb uninstall io.v.ci.vab.apk.examples.tetris
# V UI
echo "Installing V UI"
git clone --depth 1 https://github.com/vlang/ui
cd ui ; mkdir -p ~/.vmodules ; ln -s $(pwd) ~/.vmodules/ui ; cd ..
declare -a v_ui_examples=('rectangles.v')
echo "Compiling examples ${v_ui_examples[@]}"
for example in "${v_ui_examples[@]}"; do
package_id=$( echo "$example" | sed 's%/%%' | sed 's%\.%%' )
package_id=$( echo "v$package_id" )
# APK
echo "Compiling apk from ui/examples/$example ($package_id)"
vab --package-id "io.v.apk.ui.$package_id" run ui/examples/$example
# AAB
echo "Compiling aab from ui/examples/$example ($package_id)"
vab --package aab --package-id "io.v.aab.ui.$package_id" run ui/examples/$example
# Remove app in case cache is run
adb uninstall "io.v.apk.ui.$package_id"
adb uninstall "io.v.aab.ui.$package_id"
done
# Output test
echo "Testing if ui/examples/calculator can run..."
vab -g --package-id "io.v.ui.ci.examples.calculator" run ui/examples/calculator.v
sleep 5
adb -e logcat -d > /tmp/logcat.dump.txt
echo "Looking for traces of SOKOL_APP ok ..."
cat /tmp/logcat.dump.txt | grep -q 'SOKOL_APP: ... ok'; if [ ! $? -eq 0 ]; then cat /tmp/logcat.dump.txt; fi
# Remove app in case cache is run
echo "Uninstalling ui/examples/calculator"
adb uninstall io.v.ui.ci.examples.calculator
echo "Killing emulator"
adb -s emulator-5554 emu kill