summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--circle.yml22
-rw-r--r--package.json3
-rwxr-xr-xplatform/android/scripts/metrics.sh10
-rwxr-xr-xplatform/ios/scripts/metrics.sh8
-rw-r--r--[-rwxr-xr-x]platform/linux/scripts/metrics.sh3
-rwxr-xr-xplatform/macos/scripts/metrics.sh2
-rwxr-xr-xscripts/check_binary_size.js47
-rwxr-xr-xscripts/log_binary_size.sh43
-rwxr-xr-xscripts/publish_binary_size.sh74
9 files changed, 73 insertions, 139 deletions
diff --git a/circle.yml b/circle.yml
index 0e0e463be5..661a029863 100644
--- a/circle.yml
+++ b/circle.yml
@@ -421,6 +421,9 @@ jobs:
- store_artifacts:
path: platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/release
destination: .
+ - run:
+ name: Record size
+ command: platform/android/scripts/metrics.sh
# ------------------------------------------------------------------------------
@@ -462,11 +465,9 @@ jobs:
- store_artifacts:
path: platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/release
destination: .
- - deploy:
- name: Show statistics
- command: |
- export CLOUDWATCH=true
- platform/android/scripts/metrics.sh
+ - run:
+ name: Record size
+ command: platform/android/scripts/metrics.sh
- deploy:
name: Publish to Maven
command: make run-android-upload-archives
@@ -514,11 +515,9 @@ jobs:
- store_artifacts:
path: platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/release
destination: .
- - deploy:
- name: Show statistics
- command: |
- export CLOUDWATCH=true
- platform/android/scripts/metrics.sh
+ - run:
+ name: Record size
+ command: platform/android/scripts/metrics.sh
- deploy:
name: Publish to Maven
command: make run-android-upload-archives
@@ -902,6 +901,9 @@ jobs:
- *save-cache
- *collect-xcode-build-logs
- *upload-xcode-build-logs
+ - run:
+ name: Record size
+ command: platform/ios/scripts/metrics.sh
# ------------------------------------------------------------------------------
ios-release-tag:
diff --git a/package.json b/package.json
index d2c0522a0f..7de832b116 100644
--- a/package.json
+++ b/package.json
@@ -18,16 +18,19 @@
"npm-run-all": "^4.0.2"
},
"devDependencies": {
+ "@octokit/rest": "^15.9.2",
"aws-sdk": "^2.3.5",
"csscolorparser": "^1.0.2",
"ejs": "^2.4.1",
"express": "^4.11.1",
"flow-remove-types": "^1.2.1",
"json-stringify-pretty-compact": "^1.0.4",
+ "jsonwebtoken": "^8.3.0",
"lodash": "^4.16.4",
"mapbox-gl-styles": "2.0.2",
"pixelmatch": "^4.0.2",
"pngjs": "^3.0.0",
+ "pretty-bytes": "^5.1.0",
"request": "^2.72.0",
"semver": "^5.5.0",
"tape": "^4.5.1"
diff --git a/platform/android/scripts/metrics.sh b/platform/android/scripts/metrics.sh
index a5b3b7870b..42b9fa4870 100755
--- a/platform/android/scripts/metrics.sh
+++ b/platform/android/scripts/metrics.sh
@@ -4,10 +4,10 @@ set -e
set -o pipefail
# Track individual architectures
-scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/intermediate-jars/release/jni/armeabi-v7a/libmapbox-gl.so" "Platform=Android,Arch=arm-v7"
-scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/intermediate-jars/release/jni/arm64-v8a/libmapbox-gl.so" "Platform=Android,Arch=arm-v8"
-scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/intermediate-jars/release/jni/x86/libmapbox-gl.so" "Platform=Android,Arch=x86"
-scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/intermediate-jars/release/jni/x86_64/libmapbox-gl.so" "Platform=Android,Arch=x86_64"
+scripts/check_binary_size.js "platform/android/MapboxGLAndroidSDK/build/intermediates/intermediate-jars/release/jni/armeabi-v7a/libmapbox-gl.so" "Android arm-v7"
+scripts/check_binary_size.js "platform/android/MapboxGLAndroidSDK/build/intermediates/intermediate-jars/release/jni/arm64-v8a/libmapbox-gl.so" "Android arm-v8"
+scripts/check_binary_size.js "platform/android/MapboxGLAndroidSDK/build/intermediates/intermediate-jars/release/jni/x86/libmapbox-gl.so" "Android x86"
+scripts/check_binary_size.js "platform/android/MapboxGLAndroidSDK/build/intermediates/intermediate-jars/release/jni/x86_64/libmapbox-gl.so" "Android x86_64"
# Track overall library size
-scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/outputs/aar/MapboxGLAndroidSDK-release.aar" "Platform=Android,Arch=Archive"
+scripts/check_binary_size.js "platform/android/MapboxGLAndroidSDK/build/outputs/aar/MapboxGLAndroidSDK-release.aar" "Android AAR"
diff --git a/platform/ios/scripts/metrics.sh b/platform/ios/scripts/metrics.sh
index 2a241323c2..a76290c3da 100755
--- a/platform/ios/scripts/metrics.sh
+++ b/platform/ios/scripts/metrics.sh
@@ -10,9 +10,9 @@ lipo build/ios/pkg/dynamic/Mapbox-stripped -extract arm64 -output build/ios/pkg/
lipo build/ios/pkg/dynamic/Mapbox-stripped -extract x86_64 -output build/ios/pkg/dynamic/Mapbox-stripped-x86_64
# Track individual architectures
-scripts/log_binary_size.sh "build/ios/pkg/dynamic/Mapbox-stripped-armv7" "Platform=iOS,Arch=armv7"
-scripts/log_binary_size.sh "build/ios/pkg/dynamic/Mapbox-stripped-arm64" "Platform=iOS,Arch=arm64"
-scripts/log_binary_size.sh "build/ios/pkg/dynamic/Mapbox-stripped-x86_64" "Platform=iOS,Arch=x86_64"
+scripts/check_binary_size.js "build/ios/pkg/dynamic/Mapbox-stripped-armv7" "iOS armv7"
+scripts/check_binary_size.js "build/ios/pkg/dynamic/Mapbox-stripped-arm64" "iOS arm64"
+scripts/check_binary_size.js "build/ios/pkg/dynamic/Mapbox-stripped-x86_64" "iOS x86_64"
# Track overall library size
-scripts/log_binary_size.sh "build/ios/pkg/dynamic/Mapbox-stripped" "Platform=iOS,Arch=Dynamic"
+scripts/check_binary_size.js "build/ios/pkg/dynamic/Mapbox-stripped" "iOS Dynamic"
diff --git a/platform/linux/scripts/metrics.sh b/platform/linux/scripts/metrics.sh
index 82dcf98d5c..05850e0946 100755..100644
--- a/platform/linux/scripts/metrics.sh
+++ b/platform/linux/scripts/metrics.sh
@@ -8,5 +8,4 @@ ARCH=$(uname -m)
RENDER=build/linux-${ARCH}/Release/mbgl-render
strip -s -x "${RENDER}" -o "${RENDER}-stripped"
-# Track individual architecture
-scripts/log_binary_size.sh "${RENDER}-stripped" "Platform=Linux,Compiler=${_CC},Arch=${ARCH}"
+scripts/check_binary_size.js "${RENDER}-stripped" "Linux"
diff --git a/platform/macos/scripts/metrics.sh b/platform/macos/scripts/metrics.sh
index 56790fc1e6..91dfc60358 100755
--- a/platform/macos/scripts/metrics.sh
+++ b/platform/macos/scripts/metrics.sh
@@ -4,4 +4,4 @@ set -e
set -o pipefail
# Track individual architectures
-scripts/log_binary_size.sh "build/macos/pkg/Mapbox.framework/Versions/Current/Mapbox" "Platform=macOS,Arch=x86_64"
+scripts/check_binary_size.js "build/macos/pkg/Mapbox.framework/Versions/Current/Mapbox" "macOS x86_64"
diff --git a/scripts/check_binary_size.js b/scripts/check_binary_size.js
new file mode 100755
index 0000000000..70ddbc7e0e
--- /dev/null
+++ b/scripts/check_binary_size.js
@@ -0,0 +1,47 @@
+#!/usr/bin/env node
+
+const jwt = require('jsonwebtoken');
+const github = require('@octokit/rest')();
+const prettyBytes = require('pretty-bytes');
+const fs = require('fs');
+
+const SIZE_CHECK_APP_ID = 14028;
+const SIZE_CHECK_APP_INSTALLATION_ID = 229425;
+
+const file = process.argv[2];
+const label = process.argv[3];
+const {size} = fs.statSync(file);
+
+process.on('unhandledRejection', error => {
+ console.log(error);
+ process.exit(1)
+});
+
+const key = Buffer.from(process.env['SIZE_CHECK_APP_PRIVATE_KEY'], 'base64').toString('binary');
+const payload = {
+ exp: Math.floor(Date.now() / 1000) + 60,
+ iat: Math.floor(Date.now() / 1000),
+ iss: SIZE_CHECK_APP_ID
+};
+
+const token = jwt.sign(payload, key, {algorithm: 'RS256'});
+github.authenticate({type: 'app', token});
+
+github.apps.createInstallationToken({installation_id: SIZE_CHECK_APP_INSTALLATION_ID})
+ .then(({data}) => {
+ github.authenticate({type: 'token', token: data.token});
+ return github.checks.create({
+ owner: 'mapbox',
+ repo: 'mapbox-gl-native',
+ name: `Size - ${label}`,
+ head_branch: process.env['CIRCLE_BRANCH'],
+ head_sha: process.env['CIRCLE_SHA1'],
+ status: 'completed',
+ conclusion: 'success',
+ completed_at: new Date().toISOString(),
+ output: {
+ title: prettyBytes(size),
+ summary: `\`${file}\` is ${size} bytes (${prettyBytes(size)})`
+ }
+ });
+ });
diff --git a/scripts/log_binary_size.sh b/scripts/log_binary_size.sh
deleted file mode 100755
index 1147a8c479..0000000000
--- a/scripts/log_binary_size.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-set -o pipefail
-set -u
-
-# Logs metrics on binary size to CloudWatch
-
-FILE=$1
-DIMENSIONS=$2
-
-if [ -z "${DIMENSIONS}" ]; then
- echo "* No dimensions specified for '${FILE}'"
- exit 1
-fi
-
-function filesize {
- if [ `uname -s` = 'Darwin' ]; then
- stat -f%z $1
- else
- stat --printf=%s $1
- fi
-}
-
-if [ -f "${FILE}" ]; then
- SIZE=`filesize ${FILE}`
- if [ ${CLOUDWATCH:-} ]; then
- echo "* Reporting `LC_NUMERIC=en_US printf "%'10.f\n" ${SIZE}` bytes for '${DIMENSIONS}' (${FILE})"
- aws --region us-east-1 cloudwatch put-metric-data \
- --namespace "Mapbox/GL" \
- --metric-name "BinarySize" \
- --unit "Bytes" \
- --value ${SIZE} \
- --dimensions "${DIMENSIONS}"
-
- ./scripts/publish_binary_size.sh "${DIMENSIONS}"
- else
- echo "* Measured `LC_NUMERIC=en_US printf "%'10.f\n" ${SIZE}` bytes for '${DIMENSIONS}' (${FILE})"
- fi
-else
- echo "* File '${FILE}' does not exist"
- exit 1
-fi
diff --git a/scripts/publish_binary_size.sh b/scripts/publish_binary_size.sh
deleted file mode 100755
index 08dfb88287..0000000000
--- a/scripts/publish_binary_size.sh
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-set -o pipefail
-set -u
-
-# Downloads log data from AWS CloudWatch and uploads it as a JSON file to S3 for public access.
-
-function publish_binary_size {
- local DIMENSIONS=$1
-
- if [ -z "${DIMENSIONS}" ]; then
- echo "* No dimensions specified"
- exit 1
- fi
-
- function print_dimensions {
- for ITEM in ${DIMENSIONS//,/ } ; do
- echo -n "Name=${ITEM//=/,Value=} "
- done
- }
-
- local DATE_FORMAT="%Y-%m-%dT%H:%M:%SZ"
- local DATE_END=$(date -u +${DATE_FORMAT})
-
- if [ `uname -s` = 'Darwin' ]; then # BSD date
- local DATE_BEGIN=$(date -jf "${DATE_FORMAT}" -v-60d "${DATE_END}" +"${DATE_FORMAT}")
- else # GNU date
- local DATE_BEGIN=$(date --date="${DATE_END} - 60 days" +"${DATE_FORMAT}")
- fi
-
- # Download the metrics, gzip, and upload to S3.
- aws --region us-east-1 cloudwatch get-metric-statistics \
- --namespace "Mapbox/GL" \
- --metric-name "BinarySize" \
- --unit "Bytes" \
- --start-time "${DATE_BEGIN}" \
- --end-time "${DATE_END}" \
- --period 3600 \
- --statistics Maximum \
- --dimensions `print_dimensions` \
- | gzip | aws s3 cp \
- --acl public-read \
- --cache-control "max-age=300" \
- --content-encoding gzip \
- --content-type application/json \
- - "s3://mapbox/mapbox-gl-native/metrics/binary-size/${DIMENSIONS}.json"
-
- echo "* Uploaded data to 's3://mapbox/mapbox-gl-native/metrics/binary-size/${DIMENSIONS}.json'"
-}
-
-if [ $# -gt 0 ]; then
- # Upload the specified dimension only
- publish_binary_size "$1"
-else
- # Upload all dimensions that we are tracking
- publish_binary_size "Platform=iOS,Arch=armv7"
- publish_binary_size "Platform=iOS,Arch=arm64"
- publish_binary_size "Platform=iOS,Arch=x86_64"
- publish_binary_size "Platform=iOS,Arch=Dynamic"
-
- publish_binary_size "Platform=macOS,Arch=x86_64"
-
- publish_binary_size "Platform=Linux,Compiler=clang-3.8,Arch=x86_64"
- publish_binary_size "Platform=Linux,Compiler=gcc-5,Arch=x86_64"
-
- publish_binary_size "Platform=Android,Arch=arm-v5"
- publish_binary_size "Platform=Android,Arch=arm-v7"
- publish_binary_size "Platform=Android,Arch=arm-v8"
- publish_binary_size "Platform=Android,Arch=x86"
- publish_binary_size "Platform=Android,Arch=x86_64"
- publish_binary_size "Platform=Android,Arch=mips"
- publish_binary_size "Platform=Android,Arch=Archive"
-fi