Skip to content

Commit 858f7ec

Browse files
committed
Ensure sizebot doesn't swallow large diffs
1 parent c8a0350 commit 858f7ec

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.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: 16 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,18 @@ ${significantResults.join('\n')}
263264
`
264265
: '(No significant changes)'
265266
}
266-
`);
267+
`;
268+
269+
if (message.length > 65535) {
270+
// Also logging for quick inspection.
271+
console.log(message);
272+
// But harder to find so also persisting as an artifact
273+
writeFileSync('sizebot-message.md', message);
274+
markdown(
275+
'The size diff is too large to display in a single comment. ' +
276+
`The [CircleCI artifacts for this job](${process.env.CIRCLE_BUILD_URL}/artifacts) contains a file called 'sizebot-message.md' with the full message.`
277+
);
278+
} else {
279+
markdown(message);
280+
}
267281
})();

0 commit comments

Comments
 (0)