Skip to content

Commit

Permalink
Fix size-check script for first push of branch (mapbox#7094)
Browse files Browse the repository at this point in the history
  • Loading branch information
anandthakker authored Aug 8, 2018
1 parent 0abdaf5 commit 9a53717
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions build/check-bundle-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const {size} = fs.statSync(file);
const gzipSize = zlib.gzipSync(fs.readFileSync(file)).length;

process.on('unhandledRejection', error => {
console.log(error);
// don't log `error` directly, because errors from child_process.execSync
// contain an (undocumented) `envPairs` with environment variable values
console.log(error.message || 'Error');
process.exit(1)
});

Expand Down Expand Up @@ -64,7 +66,7 @@ function getMergeBase() {
// base branch.
const head = process.env['CIRCLE_SHA1'];
for (const sha of execSync(`git rev-list --max-count=10 ${head}`).toString().trim().split('\n')) {
const base = execSync(`git branch -r --contains ${sha} origin/master origin/release-* origin/mb-pages`).toString().trim().replace(/^origin\//, '');
const base = execSync(`git branch -r --contains ${sha} origin/master origin/release-* origin/mb-pages`).toString().split('\n')[0].trim().replace(/^origin\//, '');
if (base) {
return Promise.resolve(execSync(`git merge-base origin/${base} ${head}`).toString().trim());
}
Expand Down Expand Up @@ -116,6 +118,8 @@ github.apps.createInstallationToken({installation_id: SIZE_CHECK_APP_INSTALLATIO
const summary = `\`${file}\` is ${size} bytes (${prettyBytes(size)}) uncompressed, ${gzipSize} (${prettyBytes(gzipSize)}) gzipped.
That's **${downloadTime3G} seconds** over slow 3G (3 Mbps), **${downloadTime4G} seconds** over fast 4G (10 Mbps).`;

console.log(`Posting check result:\n${title}\n${summary}`);

return github.checks.create({
owner: 'mapbox',
repo: 'mapbox-gl-js',
Expand Down

0 comments on commit 9a53717

Please sign in to comment.