Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 529616a

Browse files
committed
[build] add continous integration
1 parent 7acfd3a commit 529616a

File tree

7 files changed

+387
-4
lines changed

7 files changed

+387
-4
lines changed

Diff for: .circleci/config.yml

+337
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,337 @@
1+
version: 2.1
2+
3+
workflows:
4+
version: 2
5+
mapbox-gl-native-android:
6+
jobs:
7+
- android-arm-template:
8+
name: android-debug-arm-v8
9+
- android-release:
10+
filters:
11+
tags:
12+
only: /android-v.*/
13+
14+
commands:
15+
npm-install:
16+
steps:
17+
- run:
18+
name: npm install
19+
command: npm install --ignore-scripts
20+
prepare-ccache:
21+
steps:
22+
- run:
23+
name: Prepare ccache
24+
command: |
25+
# CircleCI doesn't have any way to embed arbitrary environment variables or command output
26+
# into cache keys, so we're using the workaround of writing the desired content to a file,
27+
# and then using `{{ checksum "filename" }}` in the cache key.
28+
echo "$CIRCLE_BRANCH"
29+
echo "$CIRCLE_BRANCH" > .circle-branch
30+
echo "$CIRCLE_SHA1"
31+
echo "$CIRCLE_SHA1" > .circle-sha1
32+
echo "$CIRCLE_TARGET_BRANCH"
33+
echo "${CIRCLE_TARGET_BRANCH:master}" > .circle-target-branch
34+
echo "$CIRCLE_MERGE_BASE"
35+
echo "${CIRCLE_MERGE_BASE:master}" > .circle-merge-base
36+
ccache --clear
37+
reset-ccache-stats:
38+
steps:
39+
- run:
40+
name: Clear ccache statistics
41+
command: |
42+
ccache --zero-stats
43+
ccache --max-size=2G
44+
ccache --show-stats
45+
show-ccache-stats:
46+
steps:
47+
- run:
48+
name: Show ccache statistics
49+
command: ccache --show-stats
50+
save-node_modules-cache:
51+
steps:
52+
- save_cache:
53+
name: Save node_modules cache
54+
key: 'node_modules/v1/{{ arch }}/{{ checksum "package.json" }}'
55+
paths: [ "node_modules" ]
56+
restore-node_modules-cache:
57+
steps:
58+
- restore_cache:
59+
name: Restore node_modules cache
60+
keys:
61+
- 'node_modules/v1/{{ arch }}/{{ checksum "package.json" }}'
62+
- 'node_modules/v1/{{ arch }}'
63+
save-ccache:
64+
steps:
65+
- save_cache:
66+
name: Save ccache
67+
key: 'ccache/v1/{{ arch }}/{{ .Environment.CIRCLE_JOB }}/{{ checksum ".circle-branch" }}/{{ checksum ".circle-sha1" }}'
68+
paths: [ "~/.ccache" ]
69+
restore-ccache:
70+
steps:
71+
- restore_cache:
72+
name: Restore ccache
73+
keys:
74+
- 'ccache/v1/{{ arch }}/{{ .Environment.CIRCLE_JOB }}/{{ checksum ".circle-branch" }}/{{ checksum ".circle-sha1" }}'
75+
- 'ccache/v1/{{ arch }}/{{ .Environment.CIRCLE_JOB }}/{{ checksum ".circle-branch" }}'
76+
- 'ccache/v1/{{ arch }}/{{ .Environment.CIRCLE_JOB }}/{{ checksum ".circle-target-branch" }}/{{ checksum ".circle-merge-base" }}'
77+
- 'ccache/v1/{{ arch }}/{{ .Environment.CIRCLE_JOB }}/{{ checksum ".circle-target-branch" }}'
78+
- 'ccache/v1/{{ arch }}/{{ .Environment.CIRCLE_JOB }}'
79+
save-gradle-cache:
80+
steps:
81+
- save_cache:
82+
name: Save gradle cache
83+
key: 'gradle/v1/{{ checksum "gradle/dependencies.gradle" }}/{{ checksum "build.gradle" }}/{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}'
84+
paths: [ "/root/.gradle" ]
85+
restore-gradle-cache:
86+
steps:
87+
- restore_cache:
88+
name: Restore gradle cache
89+
keys:
90+
- 'gradle/v1/{{ checksum "gradle/dependencies.gradle" }}/{{ checksum "build.gradle" }}/{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}'
91+
- 'gradle/v1'
92+
install-dependencies:
93+
parameters:
94+
node_modules:
95+
type: boolean
96+
default: true
97+
ccache:
98+
type: boolean
99+
default: true
100+
gradle:
101+
type: boolean
102+
default: false
103+
steps:
104+
- checkout
105+
- when:
106+
condition: << parameters.node_modules >>
107+
steps: [ restore-node_modules-cache, npm-install ]
108+
- when:
109+
condition: << parameters.ccache >>
110+
steps: [ prepare-ccache, restore-ccache, reset-ccache-stats ]
111+
- when:
112+
condition: << parameters.gradle >>
113+
steps: [ restore-gradle-cache ]
114+
save-dependencies:
115+
parameters:
116+
node_modules:
117+
type: boolean
118+
default: true
119+
ccache:
120+
type: boolean
121+
default: true
122+
gradle:
123+
type: boolean
124+
default: false
125+
steps:
126+
- when:
127+
condition: << parameters.node_modules >>
128+
steps: [ save-node_modules-cache ]
129+
- when:
130+
condition: << parameters.ccache >>
131+
steps: [ save-ccache, show-ccache-stats ]
132+
- when:
133+
condition: << parameters.gradle >>
134+
steps: [ save-gradle-cache ]
135+
setup-llvm-symbolizer:
136+
steps:
137+
- run:
138+
name: Environment Setup
139+
command: |
140+
# LLVM has a hard check for "llvm-symbolizer" and doesn't support suffixed executables
141+
ln -s /usr/bin/llvm-symbolizer-* /usr/bin/llvm-symbolizer
142+
# We'll use tee to redirect stderr to a file so we can check for sanitiziation
143+
# https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/1059947
144+
sed -i 's/"$@" 2>&1/"$@"/' /usr/bin/xvfb-run
145+
configure-cmake:
146+
steps:
147+
- run:
148+
name: CMake configuration step
149+
command: |
150+
mkdir -p build
151+
cd build
152+
cmake -DWITH_COVERAGE=${WITH_COVERAGE:0} -DWITH_OSMESA=${WITH_OSMESA:0} -DWITH_EGL=${WITH_EGL:0} ..
153+
cd ..
154+
login-google-cloud-platform:
155+
steps:
156+
- run:
157+
name: Log in to Google Cloud Platform
158+
command: |
159+
if [[ -n "${GLCLOUD_SERVICE_JSON}" ]]; then
160+
echo "${GLCLOUD_SERVICE_JSON}" > secret.json
161+
gcloud auth activate-service-account --key-file secret.json --project mapbox-gl-native-android
162+
rm secret.json
163+
fi
164+
165+
jobs:
166+
# ------------------------------------------------------------------------------
167+
android-arm-template:
168+
parameters:
169+
stl:
170+
type: string
171+
default: "c++_static"
172+
image:
173+
type: string
174+
default: android-ndk-r20:7b7c4b42cf
175+
firebase_device_id:
176+
type: string
177+
default: sailfish
178+
firebase_device_os:
179+
type: string
180+
default: "26"
181+
abi:
182+
type: string
183+
default: "arm-v8"
184+
docker:
185+
- image: mbgl/<< parameters.image >>
186+
resource_class: xlarge
187+
working_directory: /src
188+
environment:
189+
LIBSYSCONFCPUS: 8
190+
JOBS: 8
191+
BUILDTYPE: Debug
192+
IS_LOCAL_DEVELOPMENT: false
193+
MBGL_ANDROID_STL: << parameters.stl >>
194+
steps:
195+
- install-dependencies: { gradle: true }
196+
- run:
197+
name: Initialize vendor submodules
198+
command: git submodule update --init --recursive vendor
199+
- run:
200+
name: Check code style
201+
command: make android-check
202+
- run:
203+
name: Run Android unit tests
204+
command: make run-android-unit-test
205+
- run:
206+
name: Build libmapbox-gl.so for << parameters.abi >>
207+
command: make android-lib-<< parameters.abi >>
208+
- run:
209+
name: Generate Espresso sanity tests
210+
command: make test-code-android
211+
- run:
212+
name: Build Test APK
213+
command: |
214+
if [ -n "${MAPBOX_DEVELOPER_CONFIG_XML}" ]; then
215+
echo "${MAPBOX_DEVELOPER_CONFIG_XML}" > MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml
216+
make android-ui-test-<< parameters.abi >>
217+
fi
218+
- save-dependencies: { gradle: true }
219+
- login-google-cloud-platform
220+
- run:
221+
name: Run instrumentation tests on Firebase
222+
no_output_timeout: 20m
223+
command: |
224+
if [[ -n "${GLCLOUD_SERVICE_JSON}" ]]; then
225+
gcloud firebase test android models list
226+
gcloud firebase test android run --type instrumentation \
227+
--app MapboxGLAndroidSDKTestApp/build/outputs/apk/debug/MapboxGLAndroidSDKTestApp-debug.apk \
228+
--test MapboxGLAndroidSDKTestApp/build/outputs/apk/androidTest/debug/MapboxGLAndroidSDKTestApp-debug-androidTest.apk \
229+
--device-ids << parameters.firebase_device_id >> --os-version-ids << parameters.firebase_device_os >> --locales en --orientations portrait --timeout 20m \
230+
--environment-variables coverage=true,coverageFile="/sdcard/coverage.ec" --directories-to-pull /sdcard --results-dir mapbox-android-sdk-${CIRCLE_BUILD_NUM}
231+
fi
232+
- store_artifacts:
233+
path: MapboxGLAndroidSDKTestApp/build/outputs/apk/debug
234+
destination: .
235+
- store_artifacts:
236+
path: MapboxGLAndroidSDK/build/reports/lint-results.html
237+
- store_artifacts:
238+
path: MapboxGLAndroidSDK/build/reports/lint-results.xml
239+
- store_artifacts:
240+
path: MapboxGLAndroidSDK/lint-baseline.xml
241+
- store_artifacts:
242+
path: MapboxGLAndroidSDKTestApp/build/reports/lint-results.html
243+
- store_artifacts:
244+
path: MapboxGLAndroidSDKTestApp/build/reports/lint-results.xml
245+
- store_artifacts:
246+
path: MapboxGLAndroidSDKTestApp/lint-baseline.xml
247+
- store_artifacts:
248+
path: MapboxGLAndroidSDK/build/intermediates/cmake/debug/obj
249+
250+
# ------------------------------------------------------------------------------
251+
android-release:
252+
docker:
253+
- image: mbgl/android-ndk-r20:7b7c4b42cf
254+
resource_class: xlarge
255+
working_directory: /src
256+
environment:
257+
LIBSYSCONFCPUS: 8
258+
JOBS: 8
259+
BUILDTYPE: Release
260+
IS_LOCAL_DEVELOPMENT: false
261+
steps:
262+
- install-dependencies: { gradle: true }
263+
- run:
264+
name: Initialize vendor submodules
265+
command: git submodule update --init --recursive vendor
266+
- run:
267+
name: Android nitpick
268+
command: make run-android-nitpick
269+
- run:
270+
name: Trigger core benchmark run
271+
command: |
272+
if [ -n "${MOBILE_METRICS_TOKEN}" ]; then
273+
if [[ $CIRCLE_BRANCH == master ]]; then
274+
curl -u $MOBILE_METRICS_TOKEN -d build_parameters[CIRCLE_JOB]=android-core-benchmark https://circleci.com/api/v1.1/project/github/mapbox/mobile-metrics/tree/master
275+
fi
276+
fi
277+
- run:
278+
name: Trigger android benchmark run
279+
command: |
280+
if [ -n "${MOBILE_METRICS_TOKEN}" ]; then
281+
if [[ $CIRCLE_BRANCH == master ]]; then
282+
curl -u $MOBILE_METRICS_TOKEN -d build_parameters[CIRCLE_JOB]=android-benchmark https://circleci.com/api/v1.1/project/github/mapbox/mobile-metrics/tree/master
283+
fi
284+
fi
285+
- run:
286+
name: Generate Maven credentials
287+
command: |
288+
if [ -n "${BINTRAY_USER}" ]; then
289+
echo "BINTRAY_USER=$BINTRAY_USER
290+
BINTRAY_API_KEY=$BINTRAY_API_KEY
291+
GPG_PASSPHRASE=$GPG_PASSPHRASE"
292+
fi
293+
- run:
294+
name: Update version name
295+
command: |
296+
if [[ $CIRCLE_TAG == android-v* ]]; then
297+
sed -i -e "s/^VERSION_NAME=.*/VERSION_NAME=${CIRCLE_TAG:9}/" MapboxGLAndroidSDK/gradle.properties
298+
fi
299+
- run:
300+
name: Build package
301+
command: make apackage
302+
- run:
303+
name: Build release Test App
304+
command: make android
305+
- run:
306+
name: Generate javadoc
307+
command: make android-javadoc
308+
- save-dependencies: { gradle: true }
309+
- run:
310+
name: gzip debugable .so files
311+
command: |
312+
gzip MapboxGLAndroidSDK/build/intermediates/cmake/release/obj/arm64-v8a/libmapbox-gl.so && \
313+
gzip MapboxGLAndroidSDK/build/intermediates/cmake/release/obj/armeabi-v7a/libmapbox-gl.so && \
314+
gzip MapboxGLAndroidSDK/build/intermediates/cmake/release/obj/x86/libmapbox-gl.so && \
315+
gzip MapboxGLAndroidSDK/build/intermediates/cmake/release/obj/x86_64/libmapbox-gl.so
316+
- store_artifacts:
317+
path: MapboxGLAndroidSDKTestApp/build/outputs/apk/release
318+
destination: .
319+
- store_artifacts:
320+
path: MapboxGLAndroidSDK/build/intermediates/cmake/release/obj/arm64-v8a/libmapbox-gl.so.gz
321+
- store_artifacts:
322+
path: MapboxGLAndroidSDK/build/intermediates/cmake/release/obj/armeabi-v7a/libmapbox-gl.so.gz
323+
- store_artifacts:
324+
path: MapboxGLAndroidSDK/build/intermediates/cmake/release/obj/x86/libmapbox-gl.so.gz
325+
- store_artifacts:
326+
path: MapboxGLAndroidSDK/build/intermediates/cmake/release/obj/x86_64/libmapbox-gl.so.gz
327+
- deploy:
328+
name: Publish to Bintray
329+
command: |
330+
if [[ $CIRCLE_BRANCH == master ]] || [[ $CIRCLE_BRANCH == release-* ]] || [[ $CIRCLE_TAG == android-v* ]]; then
331+
version=$(cat MapboxGLAndroidSDK/gradle.properties | grep "VERSION_NAME")
332+
if [[ $version != *"SNAPSHOT"* ]]; then
333+
make run-android-upload-to-bintray
334+
else
335+
make run-android-upload-to-artifactory
336+
fi
337+
fi

Diff for: .gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,5 @@ MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/acti
3131
# Input files for running render tests
3232
MapboxGLAndroidSDKTestApp/src/main/assets/integration/
3333

34-
# Local AS configuration file
35-
gradle.properties
36-
3734
# Node modules
3835
node_modules

Diff for: Makefile

+22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
export BUILDTYPE ?= Debug
2+
export IS_LOCAL_DEVELOPMENT ?= true
3+
export TARGET_BRANCH ?= master
4+
5+
CMAKE ?= cmake
6+
7+
8+
ifeq ($(BUILDTYPE), Release)
9+
else ifeq ($(BUILDTYPE), RelWithDebInfo)
10+
else ifeq ($(BUILDTYPE), Sanitize)
11+
else ifeq ($(BUILDTYPE), Debug)
12+
else
13+
$(error BUILDTYPE must be Debug, Sanitize, Release or RelWithDebInfo)
14+
endif
15+
16+
buildtype := $(shell echo "$(BUILDTYPE)" | tr "[A-Z]" "[a-z]")
17+
18+
HOST_PLATFORM = linux
19+
HOST_PLATFORM_VERSION = $(shell uname -m)
20+
export NINJA = platform/linux/ninja
21+
export JOBS ?= $(shell grep --count processor /proc/cpuinfo)
22+
123
#### Android targets ###########################################################
224

325
MBGL_ANDROID_ABIS = arm-v7;armeabi-v7a

Diff for: MapboxGLAndroidSDK/gradle.properties

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
VERSION_NAME=8.5.0-SNAPSHOT
2+
3+
# Only build native dependencies for the current ABI
4+
# See https://code.google.com/p/android/issues/detail?id=221098#c20
5+
android.buildOnlyTargetAbi=true
6+
7+
# Roboelectric 4.0 required config for < Android Studio v3.3.0
8+
# http://robolectric.org/migrating/#migrating-to-40
9+
android.enableUnitTestBinaryResources=true

Diff for: gradle/native-build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ ext.nativeBuild = { nativeTargets ->
4646
arguments "-DANDROID_CCACHE=/usr/bin/ccache"
4747
}
4848

49+
cFlags "-Qunused-arguments"
50+
cppFlags "-Qunused-arguments"
51+
4952
for (target in nativeTargets) {
5053
targets target
5154
}

0 commit comments

Comments
 (0)