Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure sizebot doesn't swallow large diffs #28845

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ jobs:
- setup_node_modules
- run:
command: node ./scripts/tasks/danger
- store_artifacts:
path: sizebot-message.md

build_devtools_and_process_artifacts:
docker: *docker
Expand Down
17 changes: 15 additions & 2 deletions dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const {markdown, danger, warn} = require('danger');
const {promisify} = require('util');
const glob = promisify(require('glob'));
const gzipSize = require('gzip-size');
const {writeFileSync} = require('fs');

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

Expand Down Expand Up @@ -236,7 +237,7 @@ function row(result, baseSha, headSha) {
}
}

markdown(`
const message = `
Comparing: ${baseSha}...${headSha}

## Critical size changes
Expand All @@ -263,5 +264,17 @@ ${significantResults.join('\n')}
`
: '(No significant changes)'
}
`);
`;

// GitHub comments are limited to 65536 characters.
if (message.length > 65536) {
// Make message available as an artifact
writeFileSync('sizebot-message.md', message);
markdown(
'The size diff is too large to display in a single comment. ' +
`The [CircleCI job](${process.env.CIRCLE_BUILD_URL}) contains an artifact called 'sizebot-message.md' with the full message.`
);
} else {
markdown(message);
}
})();