parent
e2b76bb386
commit
ac93f1235e
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"aio":{"master":{"change":"application","gzip7":{"inline":925,"main":119519,"polyfills":11863},"gzip9":{"inline":925,"main":119301,"polyfills":11861},"uncompressed":{"inline":1533,"main":486493,"polyfills":37068}}}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -u -e -o pipefail
|
||||
|
||||
declare -A payloadLimits
|
||||
payloadLimits["aio", "uncompressed", "inline"]=1600
|
||||
payloadLimits["aio", "uncompressed", "main"]=487000
|
||||
payloadLimits["aio", "uncompressed", "polyfills"]=38000
|
||||
payloadLimits["aio", "gzip7", "inline"]=1000
|
||||
payloadLimits["aio", "gzip7", "main"]=120000
|
||||
payloadLimits["aio", "gzip7", "polyfills"]=11900
|
||||
payloadLimits["aio", "gzip9", "inline"]=1000
|
||||
payloadLimits["aio", "gzip9", "main"]=120000
|
||||
payloadLimits["aio", "gzip9", "polyfills"]=11900
|
|
@ -7,7 +7,6 @@ readonly parentDir=$(dirname $thisDir)
|
|||
|
||||
# Track payload size functions
|
||||
source ../scripts/ci/payload-size.sh
|
||||
source ${thisDir}/_payload-limits.sh
|
||||
|
||||
trackPayloadSize "aio" "dist/*.bundle.js" true true
|
||||
trackPayloadSize "aio" "dist/*.bundle.js" true true "${thisDir}/_payload-limits.json"
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"cli-hello-world":{"master":{"gzip7":{"inline":847,"main":42533,"polyfills":20207},"gzip9":{"inline":847,"main":42483,"polyfills":20204},"uncompressed":{"inline":1447,"main":154295,"polyfills":61254}}},
|
||||
"hello_world__closure":{"master":{"gzip7":{"bundle":32793},"gzip9":{"bundle":32758},"uncompressed":{"bundle":100661}}}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -u -e -o pipefail
|
||||
|
||||
declare -A payloadLimits
|
||||
payloadLimits["hello_world__closure", "uncompressed", "bundle"]=106000
|
||||
payloadLimits["hello_world__closure", "gzip7", "bundle"]=35000
|
||||
payloadLimits["hello_world__closure", "gzip9", "bundle"]=35000
|
||||
|
||||
payloadLimits["cli-hello-world", "uncompressed", "inline"]=1500
|
||||
payloadLimits["cli-hello-world", "uncompressed", "main"]=160000
|
||||
payloadLimits["cli-hello-world", "uncompressed", "polyfills"]=66000
|
||||
payloadLimits["cli-hello-world", "gzip7", "inline"]=900
|
||||
payloadLimits["cli-hello-world", "gzip7", "main"]=45000
|
||||
payloadLimits["cli-hello-world", "gzip7", "polyfills"]=22000
|
||||
payloadLimits["cli-hello-world", "gzip9", "inline"]=900
|
||||
payloadLimits["cli-hello-world", "gzip9", "main"]=45000
|
||||
payloadLimits["cli-hello-world", "gzip9", "polyfills"]=22000
|
||||
|
|
@ -4,9 +4,10 @@ set -e -o pipefail
|
|||
|
||||
cd `dirname $0`
|
||||
|
||||
readonly thisDir=$(cd $(dirname $0); pwd)
|
||||
|
||||
# Track payload size functions
|
||||
source ../scripts/ci/payload-size.sh
|
||||
source ./_payload-limits.sh
|
||||
|
||||
# Workaround https://github.com/yarnpkg/yarn/issues/2165
|
||||
# Yarn will cache file://dist URIs and not update Angular code
|
||||
|
@ -48,7 +49,7 @@ for testDir in $(ls | grep -v node_modules) ; do
|
|||
if [[ $testDir == cli-hello-world ]]; then
|
||||
yarn build
|
||||
fi
|
||||
trackPayloadSize "$testDir" "dist/*.js" true false
|
||||
trackPayloadSize "$testDir" "dist/*.js" true false "${thisDir}/_payload-limits.json"
|
||||
fi
|
||||
)
|
||||
done
|
||||
|
|
|
@ -1,21 +1,30 @@
|
|||
|
||||
const fs = require('fs');
|
||||
const latest = JSON.parse(fs.readFileSync('/tmp/latest.log', 'utf8'));
|
||||
// Get branch and project name from command line arguments
|
||||
const [, , limitFile, project, branch] = process.argv;
|
||||
|
||||
const limit = JSON.parse(fs.readFileSync(limitFile, 'utf8'));
|
||||
const current = JSON.parse(fs.readFileSync('/tmp/current.log', 'utf8'));
|
||||
|
||||
|
||||
const limitData = limit[project][branch] || limit[project]["master"];
|
||||
|
||||
if (!limitData) {
|
||||
console.error(`No limit data found.`);
|
||||
// If no payload limit file found, we don't need to check the size
|
||||
exit(0);
|
||||
}
|
||||
|
||||
let failed = false;
|
||||
for (let commit in latest) {
|
||||
if (typeof latest[commit] === 'object') {
|
||||
for (let compressionType in latest[commit]) {
|
||||
if (typeof latest[commit][compressionType] === 'object') {
|
||||
for (let file in latest[commit][compressionType]) {
|
||||
const name = `${compressionType}/${file}`;
|
||||
const number = latest[commit][compressionType][file];
|
||||
if (current[name] - number > number / 100) {
|
||||
console.log(`Commit ${commit} ${compressionType} ${file} increase from ${number} to ${current[name]}`);
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
for (let compressionType in limitData) {
|
||||
if (typeof limitData[compressionType] === 'object') {
|
||||
for (let file in limitData[compressionType]) {
|
||||
const name = `${compressionType}/${file}`;
|
||||
const number = limitData[compressionType][file];
|
||||
if (Math.abs(current[name] - number) > number / 100) {
|
||||
console.log(`Commit ${commit} ${compressionType} ${file} changed from ${number} to ${current[name]}.
|
||||
If this is a desired change, please update the payload size limits in file ${limitFile}`);
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,12 +22,9 @@ calculateSize() {
|
|||
# Write to global variable $failed
|
||||
# Read from global variables $size, $size7, $size9, $label, $limitUncompressed
|
||||
checkSize() {
|
||||
for fileType in "uncompressed" "gzip7" "gzip9"; do
|
||||
if [[ ${size[$fileType]} -gt ${payloadLimits[$name, $fileType, $label]} ]]; then
|
||||
failed=true
|
||||
echo "$fileType $label size is ${size[$fileType]} which is greater than ${payloadLimits[$name, $fileType, $label]}"
|
||||
fi
|
||||
done
|
||||
name="$1"
|
||||
limitFile="$2"
|
||||
node ${PROJECT_ROOT}/scripts/ci/payload-size.js $limitFile $name $TRAVIS_BRANCH
|
||||
}
|
||||
|
||||
# Write timestamp to global variable $payloadData
|
||||
|
@ -92,14 +89,12 @@ uploadData() {
|
|||
set +x
|
||||
$PROJECT_ROOT/node_modules/.bin/firebase database:update --data "$payloadData" --project $PROJECT_NAME --confirm --token "$ANGULAR_PAYLOAD_FIREBASE_TOKEN" $dbPath
|
||||
fi
|
||||
|
||||
curl "https://angular-payload-size.firebaseio.com/payload/${name}/${safeBranchName}.json?orderBy=\"timestamp\"&limitToLast=1" > /tmp/latest.log
|
||||
node ${PROJECT_ROOT}/scripts/ci/payload-size.js
|
||||
}
|
||||
|
||||
# Track payload size, $1 is the name in database, $2 is the file path
|
||||
# $3 is whether we check the payload size and fail the test if the size exceeds
|
||||
# limit, $4 is whether record the type of changes: true | false
|
||||
# $5 is the payload size limit file
|
||||
trackPayloadSize() {
|
||||
name="$1"
|
||||
path="$2"
|
||||
|
@ -111,9 +106,6 @@ trackPayloadSize() {
|
|||
for filename in $path; do
|
||||
declare -A size
|
||||
calculateSize
|
||||
if [[ $checkSize = true ]]; then
|
||||
checkSize
|
||||
fi
|
||||
done
|
||||
addTimestamp
|
||||
if [[ $trackChange = true ]]; then
|
||||
|
@ -121,6 +113,9 @@ trackPayloadSize() {
|
|||
fi
|
||||
addMessage
|
||||
uploadData $name
|
||||
if [[ $checkSize = true ]]; then
|
||||
checkSize $name "$5"
|
||||
fi
|
||||
if [[ $failed = true ]]; then
|
||||
echo exit 1
|
||||
exit 1
|
||||
|
|
Loading…
Reference in New Issue