forked from mapbox/mapbox-gl-native-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle.yml
331 lines (327 loc) · 12.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
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
version: 2.1
workflows:
version: 2
mapbox-gl-native-android:
jobs:
- android-arm-template:
name: android-debug-arm-v8
- android-release:
filters:
tags:
only: /android-v.*/
commands:
npm-install:
steps:
- run:
name: npm install
command: npm install --ignore-scripts
npm-install-vendor:
steps:
- run:
name: npm install
command: cd vendor/mapbox-gl-native && npm install --ignore-scripts
prepare-ccache:
steps:
- run:
name: Prepare ccache
command: |
# CircleCI doesn't have any way to embed arbitrary environment variables or command output
# into cache keys, so we're using the workaround of writing the desired content to a file,
# and then using `{{ checksum "filename" }}` in the cache key.
echo "$CIRCLE_BRANCH"
echo "$CIRCLE_BRANCH" > .circle-branch
echo "$CIRCLE_SHA1"
echo "$CIRCLE_SHA1" > .circle-sha1
echo "$CIRCLE_TARGET_BRANCH"
echo "${CIRCLE_TARGET_BRANCH:main}" > .circle-target-branch
echo "$CIRCLE_MERGE_BASE"
echo "${CIRCLE_MERGE_BASE:main}" > .circle-merge-base
ccache --clear
reset-ccache-stats:
steps:
- run:
name: Clear ccache statistics
command: |
ccache --zero-stats
ccache --max-size=2G
ccache --show-stats
show-ccache-stats:
steps:
- run:
name: Show ccache statistics
command: ccache --show-stats
save-node_modules-cache:
steps:
- save_cache:
name: Save node_modules cache
key: 'node_modules/v1/{{ arch }}/{{ checksum "package.json" }}'
paths: [ "node_modules" ]
restore-node_modules-cache:
steps:
- restore_cache:
name: Restore node_modules cache
keys:
- 'node_modules/v1/{{ arch }}/{{ checksum "package.json" }}'
- 'node_modules/v1/{{ arch }}'
save-ccache:
steps:
- save_cache:
name: Save ccache
key: 'ccache/v1/{{ arch }}/{{ .Environment.CIRCLE_JOB }}/{{ checksum ".circle-branch" }}/{{ checksum ".circle-sha1" }}'
paths: [ "~/.ccache" ]
restore-ccache:
steps:
- restore_cache:
name: Restore ccache
keys:
- 'ccache/v1/{{ arch }}/{{ .Environment.CIRCLE_JOB }}/{{ checksum ".circle-branch" }}/{{ checksum ".circle-sha1" }}'
- 'ccache/v1/{{ arch }}/{{ .Environment.CIRCLE_JOB }}/{{ checksum ".circle-branch" }}'
- 'ccache/v1/{{ arch }}/{{ .Environment.CIRCLE_JOB }}/{{ checksum ".circle-target-branch" }}/{{ checksum ".circle-merge-base" }}'
- 'ccache/v1/{{ arch }}/{{ .Environment.CIRCLE_JOB }}/{{ checksum ".circle-target-branch" }}'
- 'ccache/v1/{{ arch }}/{{ .Environment.CIRCLE_JOB }}'
save-gradle-cache:
steps:
- save_cache:
name: Save gradle cache
key: 'gradle/v1/{{ checksum "gradle/dependencies.gradle" }}/{{ checksum "build.gradle" }}/{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}'
paths: [ "/root/.gradle" ]
restore-gradle-cache:
steps:
- restore_cache:
name: Restore gradle cache
keys:
- 'gradle/v1/{{ checksum "gradle/dependencies.gradle" }}/{{ checksum "build.gradle" }}/{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}'
- 'gradle/v1'
prepare-environment:
steps:
- run:
name: Prepare environment
command: touch "$BASH_ENV" && ./vendor/mapbox-gl-native/scripts/environment.js | tee -a "$BASH_ENV"
install-dependencies:
parameters:
node_modules:
type: boolean
default: true
ccache:
type: boolean
default: true
gradle:
type: boolean
default: false
steps:
- checkout
- when:
condition: << parameters.node_modules >>
steps: [ restore-node_modules-cache, npm-install ]
- when:
condition: << parameters.ccache >>
steps: [ prepare-ccache, restore-ccache, reset-ccache-stats ]
- when:
condition: << parameters.gradle >>
steps: [ restore-gradle-cache ]
save-dependencies:
parameters:
node_modules:
type: boolean
default: true
ccache:
type: boolean
default: true
gradle:
type: boolean
default: false
steps:
- when:
condition: << parameters.node_modules >>
steps: [ save-node_modules-cache ]
- when:
condition: << parameters.ccache >>
steps: [ save-ccache, show-ccache-stats ]
- when:
condition: << parameters.gradle >>
steps: [ save-gradle-cache ]
setup-llvm-symbolizer:
steps:
- run:
name: Environment Setup
command: |
# LLVM has a hard check for "llvm-symbolizer" and doesn't support suffixed executables
ln -s /usr/bin/llvm-symbolizer-* /usr/bin/llvm-symbolizer
# We'll use tee to redirect stderr to a file so we can check for sanitiziation
# https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/1059947
sed -i 's/"$@" 2>&1/"$@"/' /usr/bin/xvfb-run
configure-cmake:
steps:
- run:
name: CMake configuration step
command: |
mkdir -p build
cd build
cmake -DWITH_COVERAGE=${WITH_COVERAGE:0} -DWITH_OSMESA=${WITH_OSMESA:0} -DWITH_EGL=${WITH_EGL:0} ..
cd ..
login-google-cloud-platform:
steps:
- run:
name: Log in to Google Cloud Platform
command: |
if [[ -n "${GLCLOUD_SERVICE_JSON}" ]]; then
echo "${GLCLOUD_SERVICE_JSON}" > secret.json
gcloud auth activate-service-account --key-file secret.json --project mapbox-gl-native-android
rm secret.json
fi
generate-api-javadoc:
steps:
- run:
name: Generate Maps SDK API javadoc and transfer to `/android-docs`
command: |
export VERSION_TAG=${CIRCLE_TAG}
export GITHUB_TOKEN=${DANGER_GITHUB_API_TOKEN}
export DOCS_REPO="android-docs"
bash scripts/trigger-maps-documentation-deploy-steps.sh
jobs:
# ------------------------------------------------------------------------------
android-arm-template:
parameters:
stl:
type: string
default: "c++_static"
image:
type: string
default: android-ndk-r21:78010c4d11
firebase_device_id:
type: string
default: sailfish
firebase_device_os:
type: string
default: "26"
abi:
type: string
default: "arm-v8"
docker:
- image: mbgl/<< parameters.image >>
resource_class: xlarge
working_directory: /src
environment:
LIBSYSCONFCPUS: 8
JOBS: 8
BUILDTYPE: Debug
IS_LOCAL_DEVELOPMENT: false
MBGL_ANDROID_STL: << parameters.stl >>
steps:
- install-dependencies: { gradle: true }
- run:
name: Initialize vendor submodules
command: git submodule update --init --recursive vendor
- run:
name: Check code style
command: make android-check
- run:
name: Run Android unit tests
command: make run-android-unit-test
- run:
name: Build libmapbox-gl.so for << parameters.abi >>
command: make android-lib-<< parameters.abi >>
- run:
name: Generate Espresso sanity tests
command: make test-code-android
- run:
name: Build Test APK
command: |
if [ -n "${MAPBOX_DEVELOPER_CONFIG_XML}" ]; then
echo "${MAPBOX_DEVELOPER_CONFIG_XML}" > MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml
make android-ui-test-<< parameters.abi >>
fi
- save-dependencies: { gradle: true }
- login-google-cloud-platform
- run:
name: Run instrumentation tests on Firebase
no_output_timeout: 20m
command: |
if [[ -n "${GLCLOUD_SERVICE_JSON}" ]]; then
gcloud firebase test android models list
gcloud firebase test android run --type instrumentation \
--app MapboxGLAndroidSDKTestApp/build/outputs/apk/debug/MapboxGLAndroidSDKTestApp-debug.apk \
--test MapboxGLAndroidSDKTestApp/build/outputs/apk/androidTest/debug/MapboxGLAndroidSDKTestApp-debug-androidTest.apk \
--device-ids << parameters.firebase_device_id >> --os-version-ids << parameters.firebase_device_os >> --locales en --orientations portrait --timeout 20m \
--environment-variables coverage=true,coverageFile="/sdcard/coverage.ec" --directories-to-pull /sdcard --results-dir mapbox-android-sdk-${CIRCLE_BUILD_NUM}
fi
- store_artifacts:
path: MapboxGLAndroidSDKTestApp/build/outputs/apk/debug
destination: .
- store_artifacts:
path: MapboxGLAndroidSDK/build/reports/lint-results.html
- store_artifacts:
path: MapboxGLAndroidSDK/build/reports/lint-results.xml
- store_artifacts:
path: MapboxGLAndroidSDK/lint-baseline.xml
- store_artifacts:
path: MapboxGLAndroidSDKTestApp/build/reports/lint-results.html
- store_artifacts:
path: MapboxGLAndroidSDKTestApp/build/reports/lint-results.xml
- store_artifacts:
path: MapboxGLAndroidSDKTestApp/lint-baseline.xml
# ------------------------------------------------------------------------------
android-release:
docker:
- image: mbgl/android-ndk-r21:78010c4d11
resource_class: xlarge
working_directory: /src
environment:
LIBSYSCONFCPUS: 8
JOBS: 8
BUILDTYPE: Release
IS_LOCAL_DEVELOPMENT: false
steps:
- install-dependencies: { gradle: true }
- run:
name: Initialize vendor submodules
command: git submodule update --init --recursive vendor
- run:
name: Android nitpick
command: make run-android-nitpick
- run:
name: Update version name
command: |
if [[ $CIRCLE_TAG == android-v* ]]; then
sed -i -e "s/^VERSION_NAME=.*/VERSION_NAME=${CIRCLE_TAG:9}/" MapboxGLAndroidSDK/gradle.properties
fi
- run:
name: Build package
command: make apackage
- run:
name: Build release Test App
command: |
if [ -n "${MAPBOX_DEVELOPER_CONFIG_XML}" ]; then
echo "${MAPBOX_DEVELOPER_CONFIG_XML}" > MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml
make android
fi
- run:
name: Generate javadoc and create PR for review
command: |
if [[ $CIRCLE_TAG == android-v* ]]; then
git config --global user.email [email protected] && git config --global user.name MapboxCI
./scripts/update-android-docs.sh -s ${CIRCLE_TAG:9} -a $ANDROID_DOCS_REPO -r $ANDROID_DOCS_REVIEWERS
fi
- save-dependencies: { gradle: true }
- login-google-cloud-platform
- run:
name: Run robotest of release Test App on Firebase
no_output_timeout: 10m
command: |
if [[ -n "${GLCLOUD_SERVICE_JSON}" ]]; then
if [[ $CIRCLE_BRANCH != main && $CIRCLE_TAG != android-v* ]]; then
gcloud firebase test android run --type robo \
--app MapboxGLAndroidSDKTestApp/build/outputs/apk/release/MapboxGLAndroidSDKTestApp-release.apk \
--device-ids sailfish --os-version-ids "26" --locales en --orientations portrait --timeout 90s
fi
fi
- store_artifacts:
path: MapboxGLAndroidSDKTestApp/build/outputs/apk/release
destination: .
- deploy:
name: Publish to SDK Registry
command: |
if [[ $CIRCLE_TAG == android-v* ]]; then
make run-android-upload-to-sdk-registry
fi
- generate-api-javadoc