This repository has been archived by the owner on May 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
config.yml
317 lines (285 loc) · 9.36 KB
/
config.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
version: 2
references:
## Cache
cache_key: &cache_key
key: cache-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "build.gradle" }}-{{ checksum "mobile/build.gradle" }}
restore_cache: &restore_cache
restore_cache:
<<: *cache_key
save_cache: &save_cache
save_cache:
<<: *cache_key
paths:
- ~/.gradle
- ~/.m2
## Workspace
workspace: &workspace
~/workspace
attach_debug_workspace: &attach_debug_workspace
attach_workspace:
at: *workspace
attach_release_workspace: &attach_release_workspace
attach_workspace:
at: *workspace
persist_debug_workspace: &persist_debug_workspace
persist_to_workspace:
root: *workspace
paths:
- mobile/build/intermediates
- mobile/build/outputs/androidTest-results
- mobile/build/outputs/apk
- mobile/build/outputs/code-coverage
- mobile/build/test-results
persist_release_workspace: &persist_release_workspace
persist_to_workspace:
root: *workspace
paths:
- mobile/build
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-27-alpha
environment:
TERM: dumb
_JAVA_OPTIONS: "-Xmx2048m -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m"'
gcloud_config: &gcloud_config
working_directory: *workspace
docker:
- image: google/cloud-sdk:latest
environment:
TERM: dumb
## Keys
# Android Key Store
export_android_key: &export_android_key
run:
name: Export Android key store environment variable
command: echo 'export ANDROID_KEY_STORE="$ANDROID_KEY_STORE"' >> $BASH_ENV
decode_android_key: &decode_android_key
run:
name: Decode Android key store
command: echo $ANDROID_KEY_STORE | base64 -di > key-store.jks
# Google Services
export_gservices_key: &export_gservices_key
run:
name: Export Google Services key environment variable
command: echo 'export GOOGLE_SERVICES_KEY="$GOOGLE_SERVICES_KEY"' >> $BASH_ENV
decode_gservices_key: &decode_gservices_key
run:
name: Decode Google Services key
command: echo $GOOGLE_SERVICES_KEY | base64 -di > mobile/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
# Fabric
export_fabric_key: &export_fabric_key
run:
name: Export Fabric key
command: echo 'export FABRIC_KEY="$FABRIC_KEY"' >> $BASH_ENV
decode_fabric_key: &decode_fabric_key
run:
name: Decode Fabric key
command: echo $FABRIC_KEY | base64 -di > mobile/fabric.properties
jobs:
## Build debug APK and instrumented test APK
build_debug:
<<: *android_config
steps:
- checkout
- *restore_cache
- run:
name: Download dependencies
command: ./gradlew androidDependencies
- *save_cache
- *export_gservices_key
- *decode_gservices_key
- run:
name: Gradle build (debug)
command: ./gradlew -PciBuild=true :mobile:assembleDebug :mobile:assembleAndroidTest
- *persist_debug_workspace
- store_artifacts:
path: mobile/build/outputs/apk/
destination: /apk/
## Build release APK
build_release:
<<: *android_config
steps:
- checkout
- *restore_cache
- run:
name: Download dependencies
command: ./gradlew androidDependencies
- *save_cache
- *export_android_key
- *decode_android_key
- *export_gservices_key
- *decode_gservices_key
- *export_fabric_key
- *decode_fabric_key
- run:
name: Gradle build (release)
command: ./gradlew -PciBuild=true :mobile:assembleRelease
- *persist_release_workspace
- store_artifacts:
path: mobile/build/outputs/apk/
destination: /apk/
- store_artifacts:
path: mobile/build/outputs/mapping/
destination: /mapping/
## Check code quality
check_quality:
<<: *android_config
steps:
- checkout
- *restore_cache
- run:
name: Download dependencies
command: ./gradlew androidDependencies
- *save_cache
- *export_gservices_key
- *decode_gservices_key
- run:
name: Run Checkstyle
command: ./gradlew -PciBuild=true :mobile:customCheckstyle
- run:
name: Run FindBugs
command: ./gradlew -PciBuild=true :mobile:customFindBugs
- *persist_debug_workspace
- store_artifacts:
path: mobile/build/reports/
destination: /reports/
## Run unit tests
test_unit:
<<: *android_config
steps:
- checkout
- *restore_cache
- run:
name: Download dependencies
command: ./gradlew androidDependencies
- *save_cache
- *export_gservices_key
- *decode_gservices_key
- run:
name: Run unit tests
command: ./gradlew -PciBuild=true :mobile:testDebugUnitTest
- *persist_debug_workspace
- store_artifacts:
path: mobile/build/reports/
destination: /reports/
- store_test_results:
path: mobile/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 newspaper-84169
- run:
name: Authenticate with Google Cloud
command: gcloud auth activate-service-account firebase-adminsdk-p9qvk@newspaper-84169.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 mobile/build/outputs/apk/debug/mobile-debug.apk --test mobile/build/outputs/apk/androidTest/debug/mobile-debug-androidTest.apk --device model=sailfish,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-3udbiqpdyp0d0-miwcp7d69v80m | tail -1`*" /root/workspace/firebase/
- *persist_firebase_workspace
- store_artifacts:
path: firebase/
destination: /firebase/
## Submit JaCoCo coverage report
report_coverage:
<<: *android_config
steps:
- checkout
- *restore_cache
- run:
name: Download dependencies
command: ./gradlew androidDependencies
- *attach_debug_workspace
- *attach_firebase_workspace
- run:
name: Move Firebase coverage report
command: mkdir -p mobile/build/outputs/code-coverage/connected && cp firebase/sailfish-26-en_US-portrait/artifacts/coverage.ec mobile/build/outputs/code-coverage/connected/coverage.ec
- *export_gservices_key
- *decode_gservices_key
- run:
name: Generate JaCoCo report
command: ./gradlew -PciBuild=true :mobile:jacocoTestReport
- run:
name: Upload coverage report to Codacy
command: ./gradlew -PciBuild=true uploadCoverageToCodacy
- run:
name: Upload coverage report to CodeCov
command: bash <(curl -s https://codecov.io/bash)
- store_artifacts:
path: mobile/build/reports/
destination: /reports/
## Deploy release APK to Fabric Beta
deploy:
<<: *android_config
steps:
- checkout
- *attach_release_workspace
- *restore_cache
- run:
name: Download dependencies
command: ./gradlew androidDependencies
- *export_fabric_key
- *decode_fabric_key
- run:
name: Deploy to Fabric Beta
command: ./gradlew -PciBuild=true :mobile:crashlyticsUploadDistributionRelease
workflows:
version: 2
workflow:
jobs:
- build_debug
- build_release
- check_quality:
requires:
- build_debug
- test_unit:
requires:
- build_debug
- test_instrumented:
requires:
- build_debug
- report_coverage:
requires:
- test_unit
- test_instrumented
- deploy:
filters:
branches:
only:
- master
requires:
- build_release
- check_quality
- test_unit
- test_instrumented