From 1e3e78ce713ce8abf2c7087689ea1bccd6dda39a Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Mon, 14 Oct 2024 23:44:18 +0200 Subject: [PATCH] . --- .github/generate-dist-files-size-diff.mjs | 13 ++++++++++++- .github/workflows/dist-files-size-diff.yaml | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/generate-dist-files-size-diff.mjs b/.github/generate-dist-files-size-diff.mjs index 6df0b3c575..0e68be7255 100644 --- a/.github/generate-dist-files-size-diff.mjs +++ b/.github/generate-dist-files-size-diff.mjs @@ -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 += ``; 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 += ``; + } + output += ` - +
FileDiff (B)Diff (%)
${packageName}
${file} ${details.state === 'added' ? '(new)' : (details.state === 'removed' ? '(deleted)' : '')}${fileShort} ${details.state === 'added' ? '(new)' : (details.state === 'removed' ? '(deleted)' : '')} Size: ${formatBytes(base[file]?.size || 0)}${formatBytes(pr[file]?.size || 0)}
Gzip: ${formatBytes(base[file]?.size_gz || 0)}${formatBytes(pr[file]?.size_gz || 0)}
diff --git a/.github/workflows/dist-files-size-diff.yaml b/.github/workflows/dist-files-size-diff.yaml index 679cec6787..a32bd41e28 100644 --- a/.github/workflows/dist-files-size-diff.yaml +++ b/.github/workflows/dist-files-size-diff.yaml @@ -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: @@ -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()