forked from plusonelabs/calendar-widget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
122 lines (112 loc) · 4.36 KB
/
.travis.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
# This build file is based on https://github.com/andstatus/andstatus/blob/master/.travis.yml
language: android
jdk: oraclejdk8
sudo: required
env:
global:
- COMPILE_API_LEVEL=25
- ANDROID_BUILD_TOOLS_VERSION=25.0.3
# Using Emulator for an older Android version, because there is no newer emulator, which works in travis-ci
- EMULATOR_API_LEVEL=24
- EMULATOR_ABI=armeabi-v7a
- EMULATOR_TAG=google_apis
- ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default)
android:
components:
- tools
- platform-tools
- tools
- build-tools-$ANDROID_BUILD_TOOLS_VERSION
- android-$COMPILE_API_LEVEL
- android-$EMULATOR_API_LEVEL
- extra-google-m2repository
- extra-android-m2repository
# Specify at least one system image
- sys-img-$EMULATOR_ABI-google_apis-$EMULATOR_API_LEVEL
before_install:
# http://stackoverflow.com/questions/33820638/travis-yml-gradlew-permission-denied
- chmod +x app/calendar-widget/gradlew
before_script:
- uname -a
- android list targets
- ls -la $HOME/.android/**/*
- ls -la $HOME/**/*
# Create and start emulator
- echo no | android create avd --force -n test -t "android-"$EMULATOR_API_LEVEL --abi $EMULATOR_ABI --tag $EMULATOR_TAG
- ls -la $HOME/.android/**/*
- ls -la $HOME/**/*
- cat $HOME/.android/avd/test.avd/config.ini
- cp assets/avd_config.ini $HOME/.android/avd/test.avd/config.ini
- cat $HOME/.android/avd/test.avd/config.ini
- emulator -avd test -no-window &
- travis_wait 30 android-wait-for-emulator
# Previous command seems to end too early, so wait a bit more
# On multilined commands: https://gitlab.com/gitlab-org/gitlab-ci/issues/258 and http://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines
- |
while ! adb shell getprop init.svc.bootanim; do
echo Waiting for boot animation to end
sleep 10
done
# Another method. Should print SDK version number to console
# See http://stackoverflow.com/questions/28195080/unknown-api-level-error-when-trying-to-run-instrumentation-test
- |
while ! adb shell getprop ro.build.version.sdk; do
echo Waiting for ro.build.version.sdk value from device
sleep 10
done
- adb devices
- adb shell input keyevent 82 &
script:
- cd app/calendar-widget
- |
./gradlew build assembleAndroidTest
retval=$?
if [ $retval -ne 0 ]; then
echo "error on assembling, exit code: "$retval
exit $retval
fi
# See http://stackoverflow.com/questions/21294945/error-unable-to-find-instrumentation-info-for-componentinfo
# Instead of this (which doesn't give any output during tests execution):
# - ./gradlew connectedCheck -PdisablePreDex --continue --stacktrace --debug
# run:
- |
./gradlew :installDebugAndroidTest :installDebug
retval=$?
if [ $retval -ne 0 ]; then
echo "error on install, exit code: "$retval
exit $retval
fi
#
# The below line causes Process crash due to absense of video device
#- adb shell am instrument -w -r -e debug false org.andstatus.app.tests/android.test.InstrumentationTestRunner
#
# Run only tests, marked with a special annotation:
# See https://developer.android.com/reference/android/test/InstrumentationTestRunner.html
# For testing one method only:
# - adb shell am instrument -w -r -e debug false -e class org.andstatus.app.msg.ActAsUserTest#testActAsUser org.andstatus.app.tests/android.test.InstrumentationTestRunner
- |
adb shell am instrument -w -r -e debug false com.plusonelabs.calendar.tests/android.test.InstrumentationTestRunner |& tee build/adb-test.log
retval=$?
if [ $retval -ne 0 ]; then
echo "error in adb, exit code: "$retval
exit $retval
fi
# adb doesn't propagate exit code from tests, see https://code.google.com/p/android/issues/detail?id=3254
# So we need to parse saved terminal log
- |
cat build/adb-test.log | grep -A2 "INSTRUMENTATION_STATUS: stack="
if [ $? -eq 0 ]; then
echo "Test failure found"
exit 1
else
cat build/adb-test.log | grep "Test results for InstrumentationTestRunner"
fi
# See https://docs.travis-ci.com/user/languages/java/#Projects-Using-Gradle
before_cache:
- ls -la $HOME/.gradle/**/*
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/