Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kocal committed Oct 14, 2024
1 parent 4274e69 commit 1e3e78c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 12 additions & 1 deletion .github/generate-dist-files-size-diff.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,25 @@ export function main() {
return output;
}

const displayedPackageRow = new Set();
output += 'Thanks for the PR! Here is the difference in size of the dist files between the base and the PR.\n';
output += 'Please review the changes and make sure they are expected.\n\n';
output += `<table>
<thead><tr><th>File</th><th>Diff (B)</th><th>Diff (%)</th></tr></thead>
<tbody>`;
for (const [file, details] of files.entries()) {
const isBridge = file.includes('src/Bridge');
const packageName = file.split('/')[1];
const bridgeName = isBridge ? file.split('/')[4] : '';
const fileShort = file.replace(isBridge ? `src/${packageName}/src/Bridge/${bridgeName}/assets/dist/` : `src/${packageName}/assets/dist/`, '');

if (!displayedPackageRow.has(packageName)) {
displayedPackageRow.add(packageName);
output += `<tr><td colspan="3"><b>${packageName}</b></td></tr>`;
}

output += `<tr>
<td><code>${file}</code> ${details.state === 'added' ? '(new)' : (details.state === 'removed' ? '(deleted)' : '')}</td>
<td><code>${fileShort}</code> ${details.state === 'added' ? '(new)' : (details.state === 'removed' ? '(deleted)' : '')}</td>
<td>
Size: <code>${formatBytes(base[file]?.size || 0)}</code> → <code>${formatBytes(pr[file]?.size || 0)}</code><br>
Gzip: <code>${formatBytes(base[file]?.size_gz || 0)}</code> → <code>${formatBytes(pr[file]?.size_gz || 0)}</code><br>
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/dist-files-size-diff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ name: Dist Files Size Diff
on:
pull_request:
paths:
- 'src/*/**'
- '!src/*/doc/**'
- '.github/**'
- 'src/*/assets/dist/**'
- 'src/*/src/Bridge/*/assets/dist/**'

jobs:
dist-files-size-diff:
Expand Down Expand Up @@ -60,6 +59,7 @@ jobs:
with:
result-encoding: string
script: |
console.log(context);
const { main } = await import('${{ github.workspace }}/.github/generate-dist-files-size-diff.mjs')
return await main()
Expand Down

0 comments on commit 1e3e78c

Please sign in to comment.