Skip to content

Commit 8f212cc

Browse files
authored
Ensure sizebot doesn't swallow large diffs (#28845)
1 parent 17e920c commit 8f212cc

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ jobs:
211211
- setup_node_modules
212212
- run:
213213
command: node ./scripts/tasks/danger
214+
- store_artifacts:
215+
path: sizebot-message.md
214216

215217
build_devtools_and_process_artifacts:
216218
docker: *docker

dangerfile.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const {markdown, danger, warn} = require('danger');
3131
const {promisify} = require('util');
3232
const glob = promisify(require('glob'));
3333
const gzipSize = require('gzip-size');
34+
const {writeFileSync} = require('fs');
3435

3536
const {readFileSync, statSync} = require('fs');
3637

@@ -236,7 +237,7 @@ function row(result, baseSha, headSha) {
236237
}
237238
}
238239

239-
markdown(`
240+
const message = `
240241
Comparing: ${baseSha}...${headSha}
241242
242243
## Critical size changes
@@ -263,5 +264,17 @@ ${significantResults.join('\n')}
263264
`
264265
: '(No significant changes)'
265266
}
266-
`);
267+
`;
268+
269+
// GitHub comments are limited to 65536 characters.
270+
if (message.length > 65536) {
271+
// Make message available as an artifact
272+
writeFileSync('sizebot-message.md', message);
273+
markdown(
274+
'The size diff is too large to display in a single comment. ' +
275+
`The [CircleCI job](${process.env.CIRCLE_BUILD_URL}) contains an artifact called 'sizebot-message.md' with the full message.`
276+
);
277+
} else {
278+
markdown(message);
279+
}
267280
})();

0 commit comments

Comments
 (0)