Skip to content

Commit

Permalink
ci: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Feb 4, 2024
1 parent 115bb7b commit 4f4d603
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/blade-danger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ jobs:
env:
DANGER_GITHUB_API_TOKEN: ${{ env.GITHUB_ACCESS_TOKEN }}
DANGER_DISABLE_TRANSPILATION: 'true'
BASE_BUNDLE_SIZE_STATS_URL: 'https://raw.githubusercontent.com/razorpay/blade/test-bundle-size-diff/baseBundleSizeStats.json'
4 changes: 2 additions & 2 deletions packages/blade/PRBundleSizeStats.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
{
"name": "Button",
"passed": true,
"size": 28142,
"size": 223142,
"sizeLimit": 2000000,
"loading": 0.5496484375
},
{
"name": "Card",
"passed": true,
"size": 38142,
"size": 3142,
"sizeLimit": 2000000,
"loading": 0.5496484375
}
Expand Down
2 changes: 1 addition & 1 deletion packages/blade/dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const showBundleSizeDiff = async () => {
const { diffTable } = await generateBundleDiff(danger);

markdown(`
## Bundle Size Diff
## Bundle Size Report
${diffTable}
`);
};
Expand Down
27 changes: 21 additions & 6 deletions packages/blade/scripts/generateBundleDiff.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,32 @@ const generateBundleDiff = async () => {
);
}

bundleDiff.forEach((component) => {
const currentComponent = currentBundleSizeStats.find((stat) => stat.name === component.name);
const baseComponent = baseBundleSizeStats.find((stat) => stat.name === component.name);

if (baseComponent && !currentComponent) {
component.diffSize = -baseComponent.size;
component.baseSize = baseComponent.size;
component.prSize = 0;
} else if (!baseComponent && currentComponent) {
component.diffSize = currentComponent.size;
component.baseSize = 0;
component.prSize = currentComponent.size;
} else {
component.diffSize = currentComponent.size - baseComponent.size;
component.baseSize = baseComponent.size;
component.prSize = currentComponent.size;
}
});

const diffTable = `
| Component | Base Size | Current Size | Diff |
| --- | --- | --- | --- |
${bundleDiff
.map(
({ name, size: baseSize }) =>
`| ${name} | ${baseBundleSizeStats.length === 0 ? '-' : baseSize} | ${
currentBundleSizeStats.find((stat) => stat.name === name).size / 1000
} | ${
(currentBundleSizeStats.find((stat) => stat.name === name).size - baseSize) / 1000
} kb |`,
({ name, baseSize, prSize, diffSize }) =>
`| ${name} | ${baseSize / 1000} | ${prSize / 1000} | ${diffSize / 1000} kb |`,
)
.join('\n')}
`;
Expand Down

0 comments on commit 4f4d603

Please sign in to comment.