-
Notifications
You must be signed in to change notification settings - Fork 2
156 lines (137 loc) · 5.28 KB
/
blank.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
# This is a basic workflow to help you get started with Actions
name: CI
on: [push, workflow_dispatch]
jobs:
build:
runs-on: macos-latest
strategy:
matrix:
api: [1-28, 2-29, 3-30, 4-30, 5-30]
steps:
- uses: actions/checkout@v2
# - name: build
# run: |
# ./gradlew :app:assembleDebug :app:assembleDebugAndroidTest
- name: create AVD
run: |
export API=`echo ${{matrix.api}}|cut -f 2 -d'-'`
if [ $API == 28 ]
then
export PACKAGE="system-images;android-${API};google_apis;x86"
export ABI="google_apis/x86"
else
export PACKAGE="system-images;android-${API};google_apis;x86_64"
export ABI="google_apis/x86_64"
fi
export EMULATOR_NAME="${EMULATOR}_API${API}"
echo y | $ANDROID_HOME/tools/bin/sdkmanager --install $PACKAGE
echo no | "$ANDROID_HOME/tools/bin/avdmanager" create avd -n TestAvd -d pixel_xl --abi $ABI --package $PACKAGE --force
echo "AVD created:"
"$ANDROID_HOME/emulator/emulator" -list-avds
- name: accel check
run: |
"$ANDROID_HOME/emulator/emulator" -accel-check
- name: modify config.ini
run: |
echo 'config.ini'
cat ~/.android/avd/TestAvd.avd/config.ini
echo 'hw.ramSize=2048MB' >> ~/.android/avd/TestAvd.avd/config.ini
echo '== config.ini modified'
cat ~/.android/avd/TestAvd.avd/config.ini
- name: run emulator
continue-on-error: true
run: |
set +e
nohup "$ANDROID_HOME/emulator/emulator" -avd TestAvd -no-snapshot -no-window -no-audio -no-boot-anim -accel on -wipe-data 2>&1 &
echo "Waiting for device..."
$ANDROID_HOME/platform-tools/adb wait-for-device shell true
echo "Android is booting..."
EMU_BOOTED=0
n=0
first_launcher=1
echo 1 > /tmp/failed
while [[ $EMU_BOOTED = 0 ]];do
echo "Test for current focus"
# $ANDROID_HOME/platform-tools/adb shell dumpsys window
CURRENT_FOCUS=`$ANDROID_HOME/platform-tools/adb shell dumpsys window 2>/dev/null | grep -i mCurrentFocus`
echo "Current focus: ${CURRENT_FOCUS}"
case $CURRENT_FOCUS in
*"Launcher"*)
if [[ $first_launcher == 1 ]]; then
echo "Launcher seems to be ready, wait 10 sec for another popup..."
sleep 10
first_launcher=0
else
echo "Launcher is ready, Android boot completed"
EMU_BOOTED=1
rm /tmp/failed
fi
;;
*"Not Responding: com.android.systemui"*)
echo "Dismiss System UI isn't responding alert"
adb shell input keyevent KEYCODE_ENTER
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_ENTER
first_launcher=1
;;
*"Not Responding: com.google.android.gms"*)
echo "Dismiss GMS isn't responding alert"
adb shell input keyevent KEYCODE_ENTER
first_launcher=1
;;
*"Not Responding: system"*)
echo "Dismiss Process system isn't responding alert"
adb shell input keyevent KEYCODE_ENTER
first_launcher=1
;;
*"ConversationListActivity"*)
echo "Close Messaging app"
adb shell input keyevent KEYCODE_ENTER
first_launcher=1
;;
*)
n=$((n + 1))
echo "Waiting Android to boot 10 sec ($n)..."
sleep 10
if [ $n -gt 60 ]; then
echo "Android Emulator does not start in 10 minutes"
exit 2
fi
;;
esac
done
echo "Android Emulator started."
- name: access emulator with adb
run: |
if test -s /tmp/failed; then
echo "Skip"
else
"$ANDROID_HOME/platform-tools/adb" shell ls || true
fi
- name: show emulator log
run: |
test -f nohup.out && cat nohup.out || echo 'no nohup.out'
# - name: install apk
# run: |
# $ANDROID_HOME/platform-tools/adb install app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
# $ANDROID_HOME/platform-tools/adb install app/build/outputs/apk/debug/app-debug.apk
- name: run test
continue-on-error: true
run: |
if test -s /tmp/failed; then
echo "Skip"
else
CURRENT_FOCUS=`$ANDROID_HOME/platform-tools/adb shell dumpsys window 2>/dev/null | grep -i mCurrentFocus`
if [[ CURRENT_FOCUS != *"Launcher"* ]]; then
adb shell input keyevent KEYCODE_ENTER
fi
./gradlew connectedAndroidTest
fi
#$ANDROID_HOME/platform-tools/adb shell am instrument -w -m -e debug false -e class 'vsedoli.espressodemo.ExampleInstrumentedTest' vsedoli.espressodemo.test/androidx.test.runner.AndroidJUnitRunner
- name: grab screen
run: |
$ANDROID_HOME/platform-tools/adb exec-out screencap -p > screen.png
- uses: actions/upload-artifact@v2
with:
name: screen-${{matrix.api}}.png
path: screen.png