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
This commit is contained in:
George Kalpakas 2019-10-11 15:29:23 +03:00 committed by Miško Hevery
parent 8b0cb2f0c5
commit b6dfc8b08c
1 changed files with 10 additions and 3 deletions

View File

@ -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.