[build] publish binary size statistics to S3

This commit is contained in:
Konstantin Käfer
2016-11-18 15:51:35 +01:00
parent 66e6946b8c
commit ba2e44d4d7
2 changed files with 92 additions and 11 deletions

View File

@@ -2,6 +2,17 @@
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
@@ -11,25 +22,20 @@ function filesize {
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
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"