-
Notifications
You must be signed in to change notification settings - Fork 1
/
circle.yml
160 lines (147 loc) · 5.1 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
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
version: 2
references:
## Cache
cache_key: &cache_key
key: cache-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "build.gradle.kts" }}-{{ checksum "app/build.gradle.kts" }}
restore_cache: &restore_cache
restore_cache:
<<: *cache_key
save_cache: &save_cache
save_cache:
<<: *cache_key
paths:
- ~/.gradle
- ~/.m2
- ~/.android
## Workspace
workspace: &workspace
~/workspace
attach_debug_workspace: &attach_debug_workspace
attach_workspace:
at: *workspace
persist_debug_workspace: &persist_debug_workspace
persist_to_workspace:
root: *workspace
paths:
- app/build/outputs/androidTest-results
- app/build/outputs/apk
- app/build/outputs/code-coverage
- app/build/test-results
attach_firebase_workspace: &attach_firebase_workspace
attach_workspace:
at: *workspace
persist_firebase_workspace: &persist_firebase_workspace
persist_to_workspace:
root: *workspace
paths:
- firebase
## Docker image configurations
android_config: &android_config
working_directory: *workspace
docker:
- image: circleci/android:api-28
environment:
TERM: dumb
_JAVA_OPTIONS: "-Xmx2048m -XX:+UnlockExperimentalVMOptions"
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m"'
gcloud_config: &gcloud_config
working_directory: *workspace
docker:
- image: google/cloud-sdk@sha256:e5e691e48b47a9976c2183edae53531b642ca59f93706c9ef1ff28ecb7e04022
environment:
TERM: dumb
# Google Services
export_gservices_key: &export_gservices_key
run:
name: Export Google Services key environment variable
command: echo 'export $GOOGLE_SERVICES="$GOOGLE_SERVICES"' >> $BASH_ENV
decode_gservices_key: &decode_gservices_key
run:
name: Decode Google Services key
command: echo $GOOGLE_SERVICES | base64 -di > app/google-services.json
# Google Cloud Service
export_gcloud_key: &export_gcloud_key
run:
name: Export Google Cloud Service key environment variable
command: echo 'export GCLOUD_SERVICE_KEY="$GCLOUD_SERVICE_KEY"' >> $BASH_ENV
decode_gcloud_key: &decode_gcloud_key
run:
name: Decode Google Cloud credentials
command: echo $GCLOUD_SERVICE_KEY | base64 -di > ${HOME}/client-secret.json
jobs:
## Build debug APK and instrumented test APK
build_debug:
<<: *android_config
steps:
- checkout
- *restore_cache
- run:
name: Download dependencies
command: chmod a+x gradlew; ./gradlew androidDependencies
- *save_cache
- *export_gservices_key
- *decode_gservices_key
- run:
name: Gradle build (debug)
command: ./gradlew -PdisablePreDex :app:assembleDebug :app:assembleAndroidTest
- *persist_debug_workspace
- store_artifacts:
path: app/build/outputs/apk/
destination: /apk/
## Run unit tests
test_unit:
<<: *android_config
steps:
- checkout
- *restore_cache
- run:
name: Download dependencies
command: chmod a+x gradlew;./gradlew androidDependencies
- *save_cache
- *export_gservices_key
- *decode_gservices_key
- run:
name: Run unit tests
command: ./gradlew -PdisablePreDex :app:testDebugUnitTest
- *persist_debug_workspace
- store_artifacts:
path: app/build/reports/
destination: /reports/
- store_test_results:
path: app/build/test-results/
destination: /test-results/
## Run instrumented tests
test_instrumented:
<<: *gcloud_config
steps:
- *attach_debug_workspace
- *export_gcloud_key
- *decode_gcloud_key
- run:
name: Set Google Cloud target project
command: gcloud config set project comicsdbclient-a3fa8
- run:
name: Authenticate with Google Cloud
command: gcloud auth activate-service-account firebase-adminsdk-0x8cx@comicsdbclient-a3fa8.iam.gserviceaccount.com --key-file ${HOME}/client-secret.json
- run:
name: Run instrumented test on Firebase Test Lab
command: gcloud firebase test android run --type instrumentation --app app/build/outputs/apk/debug/app-debug.apk --test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk --device model=Nexus5X,version=26,locale=en_US,orientation=portrait --environment-variables coverage=true,coverageFile=/sdcard/tmp/code-coverage/connected/coverage.ec --directories-to-pull=/sdcard/tmp --timeout 20m
- run:
name: Create directory to store test results
command: mkdir firebase
- run:
name: Download instrumented test results from Firebase Test Lab
command: gsutil -m cp -r -U "`gsutil ls gs://test-lab-pdswcvjnp16f2-y37xzrtumnd6x | tail -1`*" /root/workspace/firebase/
- *persist_firebase_workspace
- store_artifacts:
path: firebase/
destination: /firebase/
workflows:
version: 2
workflow:
jobs:
- build_debug
#- test_unit
- test_instrumented:
requires:
- build_debug