From 3948381d64d5bc4b782510ff7be900b20a95ff9e Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 00:51:34 +0200 Subject: [PATCH] build: round payload size for comparison (#7174) In some cases the payload is still showing up in the CI even if there was no change to the library. This seems to be because the file sizes are not rounded and can sometimes be not very exact. Resulting in numbers like: `material_fesm_2014": 1004.1319999999998`. To have a better output in the GitHub statuses, the file size should be rounded --- tools/gulp/tasks/payload.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/gulp/tasks/payload.ts b/tools/gulp/tasks/payload.ts index 7c002324574..70fd6996206 100644 --- a/tools/gulp/tasks/payload.ts +++ b/tools/gulp/tasks/payload.ts @@ -93,10 +93,10 @@ async function calculatePayloadDiff(database: firebaseAdmin.database.Database, c // Calculate the payload diffs by subtracting the previous size of the FESM ES2015 bundles. const cdkFullSize = currentPayload.cdk_fesm_2015; - const cdkDiff = cdkFullSize - previousPayload.cdk_fesm_2015; + const cdkDiff = roundFileSize(cdkFullSize - previousPayload.cdk_fesm_2015); const materialFullSize = currentPayload.material_fesm_2015; - const materialDiff = materialFullSize - previousPayload.material_fesm_2015; + const materialDiff = roundFileSize(materialFullSize - previousPayload.material_fesm_2015); // Set the Github statuses for the packages by sending a HTTP request to the dashboard functions. await Promise.all([ @@ -174,3 +174,8 @@ function getCommitFromPreviousPayloadUpload(): string { return spawnSync('git', ['rev-parse', process.env['TRAVIS_BRANCH']]).stdout.toString().trim(); } } + +/** Rounds the specified file size to two decimal places. */ +function roundFileSize(fileSize: number) { + return Math.round(fileSize * 100) / 100; +}