Skip to content

Commit 3948381

Browse files
devversionjelbourn
authored andcommitted
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
1 parent 39c7b81 commit 3948381

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tools/gulp/tasks/payload.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ async function calculatePayloadDiff(database: firebaseAdmin.database.Database, c
9393

9494
// Calculate the payload diffs by subtracting the previous size of the FESM ES2015 bundles.
9595
const cdkFullSize = currentPayload.cdk_fesm_2015;
96-
const cdkDiff = cdkFullSize - previousPayload.cdk_fesm_2015;
96+
const cdkDiff = roundFileSize(cdkFullSize - previousPayload.cdk_fesm_2015);
9797

9898
const materialFullSize = currentPayload.material_fesm_2015;
99-
const materialDiff = materialFullSize - previousPayload.material_fesm_2015;
99+
const materialDiff = roundFileSize(materialFullSize - previousPayload.material_fesm_2015);
100100

101101
// Set the Github statuses for the packages by sending a HTTP request to the dashboard functions.
102102
await Promise.all([
@@ -174,3 +174,8 @@ function getCommitFromPreviousPayloadUpload(): string {
174174
return spawnSync('git', ['rev-parse', process.env['TRAVIS_BRANCH']]).stdout.toString().trim();
175175
}
176176
}
177+
178+
/** Rounds the specified file size to two decimal places. */
179+
function roundFileSize(fileSize: number) {
180+
return Math.round(fileSize * 100) / 100;
181+
}

0 commit comments

Comments
 (0)