diff options
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | cloudformation/travis.template | 72 | ||||
-rwxr-xr-x | platform/linux/scripts/after_success.sh | 10 | ||||
-rwxr-xr-x | platform/linux/scripts/metrics.sh | 12 | ||||
-rwxr-xr-x | scripts/log_binary_size.sh | 37 |
5 files changed, 97 insertions, 36 deletions
diff --git a/.travis.yml b/.travis.yml index bf13fb517b..a50d265cd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,6 +49,8 @@ script: after_script: - ccache --show-stats - ./platform/linux/scripts/after_script.sh ${TRAVIS_JOB_NUMBER} +after_success: + - ./platform/linux/scripts/after_success.sh matrix: include: diff --git a/cloudformation/travis.template b/cloudformation/travis.template index b65093907c..b2cf2d559b 100644 --- a/cloudformation/travis.template +++ b/cloudformation/travis.template @@ -8,42 +8,6 @@ "Properties": { "Policies": [ { - "PolicyName": "list-testing-old", - "PolicyDocument": { - "Statement": [ - { - "Action": [ - "s3:ListBucket" - ], - "Effect": "Allow", - "Resource": [ - "arn:aws:s3:::mapbox-gl-testing" - ] - } - ] - } - }, - { - "PolicyName": "build-testing-old", - "PolicyDocument": { - "Statement": [ - { - "Action": [ - "s3:DeleteObject", - "s3:GetObject", - "s3:GetObjectAcl", - "s3:PutObject", - "s3:PutObjectAcl" - ], - "Effect": "Allow", - "Resource": [ - "arn:aws:s3:::mapbox-gl-testing/*" - ] - } - ] - } - }, - { "PolicyName": "list-testing", "PolicyDocument": { "Statement": [ @@ -148,6 +112,24 @@ } ] } + }, + { + "PolicyName": "cloudwatch-metrics", + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "cloudwatch:PutMetricData", + "cloudwatch:GetMetricData", + "cloudwatch:GetMetricStatistics" + ], + "Effect": "Allow", + "Resource": [ + "*" + ] + } + ] + } } ] } @@ -179,6 +161,24 @@ } ] } + }, + { + "PolicyName": "cloudwatch-metrics", + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "cloudwatch:PutMetricData", + "cloudwatch:GetMetricData", + "cloudwatch:GetMetricStatistics" + ], + "Effect": "Allow", + "Resource": [ + "*" + ] + } + ] + } } ] } diff --git a/platform/linux/scripts/after_success.sh b/platform/linux/scripts/after_success.sh new file mode 100755 index 0000000000..3531e3fb74 --- /dev/null +++ b/platform/linux/scripts/after_success.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +if [ "${TRAVIS_PULL_REQUEST_BRANCH:-${TRAVIS_BRANCH}}" = "master" ] && [ "${BUILDTYPE}" = "Release" ]; then + CLOUDWATCH=true platform/linux/scripts/metrics.sh +else + echo "Not logging binary size for branch or Debug build" +fi diff --git a/platform/linux/scripts/metrics.sh b/platform/linux/scripts/metrics.sh new file mode 100755 index 0000000000..82dcf98d5c --- /dev/null +++ b/platform/linux/scripts/metrics.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +# Generate stripped version +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}" diff --git a/scripts/log_binary_size.sh b/scripts/log_binary_size.sh new file mode 100755 index 0000000000..45840174e9 --- /dev/null +++ b/scripts/log_binary_size.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +function filesize { + if [ `uname -s` = 'Darwin' ]; then + stat -f%z $1 + else + stat --printf=%s $1 + fi +} + +# Uploads build metrics to CloudWatch +FILE=$1 +DIMENSIONS=$2 + +if [ -z "${DIMENSIONS}" ]; then + echo "* No dimensions specified for '${FILE}'" + exit 1 +fi + +if [ -f "${FILE}" ]; then + SIZE=`filesize ${FILE}` + echo "* Reporting `LC_NUMERIC=en_US printf "%'10.f\n" ${SIZE}` bytes for '${DIMENSIONS}' (${FILE})" + if [ ${CLOUDWATCH} ]; then + aws --region us-east-1 cloudwatch put-metric-data \ + --namespace "Mapbox/GL" \ + --metric-name "BinarySize" \ + --unit "Bytes" \ + --value ${SIZE} \ + --dimensions "${DIMENSIONS}" + fi +else + echo "* File '${FILE}' does not exist" + exit 1 +fi |