From b6dfc8b08cfd3a39445ba005fa2d87d33e188de9 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Fri, 11 Oct 2019 15:29:23 +0300 Subject: [PATCH] ci: log calculated file sizes for each build (#33099) The `payload-size.sh` script is mainly used on CI to calculate, check and potentially save (on non-PR builds) the sizes of the bundles for various apps (including angular.io). If everything goes well (i.e. the checks pass, meaning that the sizes did not increase above the specified threshold) nothing is shown in the CI logs. In some cases, it is useful to be able to see what the sizes were in a specific build; e.g. for debugging purposes or when investigating a gradual increase that happened over time. (Some of this info is available on https://size.angular.io/, but not all.) Previously, the only way to find out what the sizes were for a specific build was to checkout the corresponding commit locally and build the target app, which in turn requires building all Angular packages and can take some time. Given that the sizes are already calculated on CI, this was a waste. This commit makes it easy to find out the bundle sizes for a specific build/commit by always printing out the calculated sizes (thus making them show up in the CI logs). PR Close #33099 --- scripts/ci/payload-size.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/ci/payload-size.sh b/scripts/ci/payload-size.sh index 7a399b7aae..35e6701193 100644 --- a/scripts/ci/payload-size.sh +++ b/scripts/ci/payload-size.sh @@ -26,9 +26,16 @@ getGzipSize() { calculateSize() { label=$(echo "$filename" | sed "s/.*\///" | sed "s/\..*//") - payloadData="$payloadData\"uncompressed/$label\": $(stat -c%s "$filename"), " - payloadData="$payloadData\"gzip7/$label\": $(getGzipSize "$filename" 7), " - payloadData="$payloadData\"gzip9/$label\": $(getGzipSize "$filename" 9), " + rawSize=$(stat -c%s "$filename") + gzip7Size=$(getGzipSize "$filename" 7) + gzip9Size=$(getGzipSize "$filename" 9) + + # Log the sizes (for information/debugging purposes). + printf "Size: %6d (gzip7: %6d, gzip9: %6d) %s\n" $rawSize $gzip7Size $gzip9Size $label + + payloadData="$payloadData\"uncompressed/$label\": $rawSize, " + payloadData="$payloadData\"gzip7/$label\": $gzip7Size, " + payloadData="$payloadData\"gzip9/$label\": $gzip9Size, " } # Check whether the file size is under limit.