From 445f7896c136934af90c0b90e1bb208992df5da3 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Fri, 23 Nov 2018 21:08:23 +0200 Subject: [PATCH] build: error when files specified in payload size limits are missing (#27250) PR Close #27250 --- aio/scripts/_payload-limits.json | 3 +-- scripts/ci/payload-size.js | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/aio/scripts/_payload-limits.json b/aio/scripts/_payload-limits.json index b538c760b6..8ea659c881 100755 --- a/aio/scripts/_payload-limits.json +++ b/aio/scripts/_payload-limits.json @@ -4,8 +4,7 @@ "uncompressed": { "runtime": 3881, "main": 499953, - "polyfills": 53926, - "prettify": 14917 + "polyfills": 53926 } } } diff --git a/scripts/ci/payload-size.js b/scripts/ci/payload-size.js index bf1699ab55..36193d0707 100644 --- a/scripts/ci/payload-size.js +++ b/scripts/ci/payload-size.js @@ -21,7 +21,14 @@ for (const compressionType in limitSizes) { const expectedSize = limitPerFile[filename]; const actualSize = currentSizes[`${compressionType}/${filename}`]; - if (Math.abs(actualSize - expectedSize) > expectedSize / 100) { + if (actualSize === undefined) { + failed = true; + // An expected compression type/file combination is missing. Maybe the file was renamed or + // removed. Report it as an error, so the user updates the corresponding limit file. + console.log( + `Commit ${commit} ${compressionType} ${filename} meassurement is missing. ` + + 'Maybe the file was renamed or removed.'); + } else if (Math.abs(actualSize - expectedSize) > expectedSize / 100) { failed = true; // We must also catch when the size is significantly lower than the payload limit, so // we are forced to update the expected payload number when the payload size reduces.