-
Notifications
You must be signed in to change notification settings - Fork 56
/
circle.yml
85 lines (67 loc) · 2.84 KB
/
circle.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
machine:
java:
# latest wiremock version needs java 8
version: oraclejdk8
environment:
# auth for the coveralls report
COVERALLS_REPO_TOKEN: mHJjy4h8zt9RIIBKg8sBosF5JkKsFk139
# chooce network device for tests with wiremock support and emulator
TEST_MOCK_IFACE: eth0
test:
pre:
# emulator startup need some minutes that's why start it before first build/test steps for build speed up
- emulator -avd circleci-android22 -no-audio -no-window:
background: true
parallel: true
override:
# Build the code
- ./gradlew app:assembleDebug
# Execute Unit Tests
- ./gradlew app:test
# start wiremock to support tests with network communication
- tools/src/main/resources/start-wiremock.sh:
# start at background to use wiremock in next build steps
background: true
# Execute Component Tests
- ./gradlew appCt:test
# Check lint hints
- ./gradlew app:lint
# Build instrumented test code
# fix apk not build https://code.google.com/p/android/issues/detail?id=180689
- ./gradlew appIt:assembleDebug
# ensure that the emulator is ready to use
- circle-android wait-for-boot
# the necessary sleep duration may change with time and depends on the pre tasks length.
# When all pre tasks are run long enough then waiting will not be necessary anymore.
# This sleep should avoid the com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException
- sleep 60
# at least remove the look screen
- adb shell input keyevent 82
# later we collect the logs from test run
- adb logcat -d
# execute tests on emulator
- ./gradlew appIt:connectedCheck
# Create coverage report
- ./gradlew jacocoTestReport
# copy test results
- mv app/build/reports/tests/debug $CIRCLE_TEST_REPORTS/AppUnitTests
- mv appCt/build/test-report $CIRCLE_TEST_REPORTS/ComponentTests
- mv appIt/build/reports/androidTests/connected $CIRCLE_TEST_REPORTS/AndroidTests
- mv build/reports/jacoco/test/html $CIRCLE_TEST_REPORTS/CodeCoverageReport
# copy lint report
- mkdir $CIRCLE_TEST_REPORTS/Lint
- mv app/build/outputs/lint-results_files $CIRCLE_TEST_REPORTS/Lint
- mv app/build/outputs/lint-results.html $CIRCLE_TEST_REPORTS/Lint/lint-app-results.html
# circleCi proper test value feature
- mkdir $CIRCLE_TEST_REPORTS/junit
- find */build/test-results -name "*.xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
- find */build/outputs/androidTest-results/ -name "*.xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
# collect logs from emulator
- adb logcat -d > $CIRCLE_ARTIFACTS/logcat_emulator.txt
# Only executed if all tasks are successful
deployment:
# report coverage to coveralls
coverage:
branch: [master, rewrite]
commands:
- ./gradlew coveralls