-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
executable file
·72 lines (59 loc) · 1.21 KB
/
entrypoint.sh
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
#!/bin/bash
export PATH=$ANDROID_HOME/platform-tools:$PATH
start_emulator() {
emulator -avd test -no-audio -no-window -memory 2048 -netfast -cpu-delay 0&# -no-boot-anim -gpu off &
}
wait_for_emulator() {
echo "Waiting for emulator to start..."
bootanim=""
failcounter=0
until [[ "$bootanim" =~ "stopped" ]]; do
bootanim=`adb -e shell getprop init.svc.bootanim 2>&1`
if [[ "$bootanim" =~ "not found" ]]; then
let "failcounter += 1"
if [[ $failcounter -gt 3 ]]; then
echo " Failed to start emulator"
exit 1
fi
fi
sleep 1
done
echo "emulator started"
}
press_menu_key() {
adb shell input keyevent 82 &
}
start_xvfb() {
Xvfb :99 -ac -screen 0 1024x768x8 &
}
prepare_node() {
source ~/.nvm/nvm.sh
nvm install 7
nvm use 7
npm i macaca-android -g
}
npm_install() {
npm install
}
show_info() {
java -version
android list targets
}
download_and_extract() {
if [ -n "$CI_BUILD_REPO" ]; then
git clone $CI_BUILD_REPO /src
else
curl -o /tmp/src.tar.gz $SOURCE_CODE_URL
tar -C /src -xvf /tmp/src.tar.gz
fi
}
main() {
download_and_extract
show_info
start_xvfb
start_emulator
wait_for_emulator
press_menu_key
}
main
exec "$@"