summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadia Barbosa <nadiabarbosa@me.com>2018-12-04 16:12:58 -0800
committerNadia Barbosa <captainbarbosa@users.noreply.github.com>2019-02-25 12:36:26 -0800
commitd34f0f0ef126ab794990a306a7a682daa1dbb3c8 (patch)
tree64dc7dcff7a59f40a785993c0348d34d78cdcc93
parent26e1c925f251d868d4bff39cd2c32b7839d02f4e (diff)
downloadqtlocation-mapboxgl-d34f0f0ef126ab794990a306a7a682daa1dbb3c8.tar.gz
[build] Publish Android/iOS binary sizes to S3
-rw-r--r--ci.template30
-rwxr-xr-xplatform/android/scripts/metrics.sh4
-rwxr-xr-xplatform/ios/scripts/metrics.sh5
-rwxr-xr-xscripts/publish_binary_size.js66
4 files changed, 81 insertions, 24 deletions
diff --git a/ci.template b/ci.template
index db4e59eb7e..abf123c56a 100644
--- a/ci.template
+++ b/ci.template
@@ -148,21 +148,33 @@
}
},
{
- "PolicyName": "publish-metrics",
+ "PolicyName": "publish-metrics",
+ "PolicyDocument": {
+ "Statement": [
+ {
+ "Action": [
+ "s3:PutObject",
+ "s3:GetObject",
+ "s3:GetObjectAcl"
+ ],
+ "Effect": "Allow",
+ "Resource": ["arn:aws:s3:::mapbox-loading-dock/raw/mobile.binarysize/*"]
+ }
+ ]
+ }
+ },
+ {
+ "PolicyName": "list-loading-dock",
"PolicyDocument": {
"Statement": [
{
"Action": [
- "s3:DeleteObject",
- "s3:GetObject",
- "s3:GetObjectAcl",
- "s3:PutObject",
- "s3:PutObjectAcl"
+ "s3:ListBucket"
],
- "Effect": "Allow",
"Resource": [
- "arn:aws:s3:::mapbox/mapbox-gl-native/metrics/*"
- ]
+ "arn:aws:s3:::mapbox-loading-dock"
+ ],
+ "Effect": "Allow"
}
]
}
diff --git a/platform/android/scripts/metrics.sh b/platform/android/scripts/metrics.sh
index 6c74ecced9..cc33daf174 100755
--- a/platform/android/scripts/metrics.sh
+++ b/platform/android/scripts/metrics.sh
@@ -13,5 +13,7 @@ scripts/check_binary_size.js "platform/android/MapboxGLAndroidSDK/build/intermed
scripts/check_binary_size.js "platform/android/MapboxGLAndroidSDK/build/outputs/aar/MapboxGLAndroidSDK-release.aar" "Android AAR"
if [[ $CIRCLE_BRANCH == master ]]; then
- scripts/publish_binary_size.js
+ # Build source data for http://mapbox.github.io/mapbox-gl-native/metrics/binary-size/
+ # and log binary sizes to metrics warehouse
+ scripts/publish_binary_size.js
fi
diff --git a/platform/ios/scripts/metrics.sh b/platform/ios/scripts/metrics.sh
index 3fed04d0f0..080dce7427 100755
--- a/platform/ios/scripts/metrics.sh
+++ b/platform/ios/scripts/metrics.sh
@@ -19,5 +19,8 @@ scripts/check_binary_size.js "build/ios/pkg/dynamic/Mapbox-stripped-x86_64" "iO
scripts/check_binary_size.js "build/ios/pkg/dynamic/Mapbox-stripped" "iOS Dynamic"
if [[ $CIRCLE_BRANCH == master ]]; then
- scripts/publish_binary_size.js
+ # Build source data for http://mapbox.github.io/mapbox-gl-native/metrics/binary-size/
+ # and log binary sizes to metrics warehouse
+ scripts/publish_binary_size.js
fi
+
diff --git a/scripts/publish_binary_size.js b/scripts/publish_binary_size.js
index 9b27378b74..1752366a63 100755
--- a/scripts/publish_binary_size.js
+++ b/scripts/publish_binary_size.js
@@ -33,13 +33,17 @@ github.authenticate({type: 'app', token});
const platforms = [
{ 'platform': 'iOS', 'arch': 'armv7' },
{ 'platform': 'iOS', 'arch': 'arm64' },
+ { 'platform': 'iOS', 'arch': 'Dynamic' },
{ 'platform': 'Android', 'arch': 'arm-v7' },
{ 'platform': 'Android', 'arch': 'arm-v8' },
{ 'platform': 'Android', 'arch': 'x86' },
{ 'platform': 'Android', 'arch': 'x86_64' }
];
+const sizeCheckInfo = [];
const rows = [];
+const date = new Date();
+const formattedCurrentDate = `${date.getUTCFullYear()}-${date.getUTCMonth() + 1}-${date.getUTCDate()}`
function query(after) {
return github.request({
@@ -84,6 +88,7 @@ function query(after) {
}
}`
}).then((result) => {
+
const history = result.data.data.repository.ref.target.history;
for (const edge of history.edges) {
@@ -106,28 +111,63 @@ function query(after) {
row[i + 1] = run ? +run.summary.match(/is (\d+) bytes/)[1] : undefined;
}
-
rows.push(row);
}
if (history.pageInfo.hasNextPage) {
return query(history.pageInfo.endCursor);
} else {
- return new AWS.S3({region: 'us-east-1'}).putObject({
- Body: zlib.gzipSync(JSON.stringify(rows.reverse())),
- Bucket: 'mapbox',
- Key: 'mapbox-gl-native/metrics/binary-size/data.json',
- ACL: 'public-read',
- CacheControl: 'max-age=300',
- ContentEncoding: 'gzip',
- ContentType: 'application/json'
- }).promise();
+ const latestRun = rows[0]
+ const runSizeMeasurements = latestRun.slice(1)
+
+ for (let i = 0; i < platforms.length; i++) {
+ const {platform, arch} = platforms[i];
+
+ sizeCheckInfo.push(JSON.stringify({
+ 'sdk': 'maps',
+ 'platform' : platform,
+ 'arch': arch,
+ 'size' : runSizeMeasurements[i],
+ 'created_at': formattedCurrentDate
+ }));
+ }
}
});
}
github.apps.createInstallationToken({installation_id: SIZE_CHECK_APP_INSTALLATION_ID})
.then(({data}) => {
- github.authenticate({type: 'token', token: data.token});
- return query();
- });
+ github.authenticate({type: 'token', token: data.token});
+
+ return query().then(function() {
+ // Uploads to data source used by
+ // http://mapbox.github.io/mapbox-gl-native/metrics/binary-size/
+ var firstPromise = new AWS.S3({region: 'us-east-1'}).putObject({
+ Body: zlib.gzipSync(JSON.stringify(rows.reverse())),
+ Bucket: 'mapbox',
+ Key: 'mapbox-gl-native/metrics/binary-size/data.json',
+ ACL: 'public-read',
+ CacheControl: 'max-age=300',
+ ContentEncoding: 'gzip',
+ ContentType: 'application/json'
+ }).promise();
+ // Uploads to data source used by Mapbox internal metrics dashboards
+ var secondPromise = new AWS.S3({region: 'us-east-1'}).putObject({
+ Body: zlib.gzipSync(sizeCheckInfo.join('\n')),
+ Bucket: 'mapbox-loading-dock',
+ Key: `raw/mobile.binarysize/${formattedCurrentDate}/mapbox-maps-ios-android-${process.env['CIRCLE_SHA1']}.json.gz`,
+ CacheControl: 'max-age=300',
+ ContentEncoding: 'gzip',
+ ContentType: 'application/json'
+ }).promise();
+
+ return Promise.all([firstPromise, secondPromise]).then(data => {
+ return console.log("Successfully uploaded all binary size metrics to S3");
+ }).catch(err => {
+ console.log("Error uploading binary size metrics to S3 " + err.message);
+ return err;
+ });
+ });
+});
+
+ \ No newline at end of file