[ci] Check package size for Pull Requests (#17739)

This commit is contained in:
James Chen
2024-10-18 17:53:58 +08:00
committed by GitHub
parent b34203f33c
commit 75c9870fff
6 changed files with 92 additions and 9 deletions
+13 -2
View File
@@ -4,9 +4,17 @@ const fs = require('fs');
const interfaceDiffPath = ps.join(__dirname, '../../interface-diff.txt');
let reportContent = fs.readFileSync(interfaceDiffPath, 'utf8');
// Remove the first line that show the package size.
const firstLineEnd = reportContent.indexOf('\n');
const packageSizeIncreasePrompt = reportContent.substring(0, firstLineEnd);
reportContent = reportContent.substring(firstLineEnd + 1);
//
if (reportContent.includes('@')) {
reportContent = reportContent.split('\n').slice(3).join('\n');
reportContent = `## Interface Check Report
reportContent = `## ${packageSizeIncreasePrompt}
## Interface Check Report
\`\`\`diff
! WARNING this pull request has changed these public interfaces:
@@ -14,7 +22,10 @@ ${reportContent}
\`\`\`
`;
} else {
reportContent = `## Interface Check Report
reportContent = `## ${packageSizeIncreasePrompt}
## Interface Check Report
This pull request does not change any public interfaces !`;
}
fs.writeFileSync(interfaceDiffPath, reportContent, 'utf8');