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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃彈 Make bundle-size reporting failures non-blocking #32864

Merged
merged 1 commit into from
Feb 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
61 changes: 30 additions & 31 deletions build-system/tasks/bundle-size/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const {
VERSION: internalRuntimeVersion,
} = require('../../compile/internal-version');
const {cyan, red, yellow} = require('kleur/colors');
const {log} = require('../../common/logging');
const {log, logWithoutTimestamp} = require('../../common/logging');
const {report, NoTTYReport} = require('@ampproject/filesize');

const requestPost = util.promisify(require('request').post);
Expand Down Expand Up @@ -113,6 +113,7 @@ async function storeBundleSize() {
}

const commitHash = gitCommitHash();
log('Storing bundle sizes for commit', cyan(shortSha(commitHash)) + '...');
try {
const response = await requestPost({
uri: url.resolve(
Expand All @@ -125,15 +126,10 @@ async function storeBundleSize() {
bundleSizes: await getBrotliBundleSizes(),
},
});
checkResponse(
response,
'Successfully stored bundle sizes for commit',
cyan(shortSha(commitHash)) + '.'
);
checkResponse(response, 'Successfully stored bundle sizes.');
} catch (error) {
log(red('Could not store bundle sizes'));
log(red(error));
process.exitCode = 1;
log(yellow('WARNING:'), 'Could not store bundle sizes');
logWithoutTimestamp(error);
return;
}
}
Expand All @@ -144,26 +140,28 @@ async function storeBundleSize() {
async function skipBundleSize() {
if (isPullRequestBuild()) {
const commitHash = gitCommitHash();
log(
'Skipping bundle size reporting for commit',
cyan(shortSha(commitHash)) + '...'
);
try {
const response = await requestPost(
url.resolve(
bundleSizeAppBaseUrl,
path.join('commit', commitHash, 'skip')
)
);
checkResponse(
response,
'Skipped bundle size reporting for commit',
cyan(shortSha(commitHash)) + '.'
);
checkResponse(response, 'Successfully skipped bundle size reporting.');
} catch (error) {
log(red('Could not report a skipped pull request'));
log(red(error));
process.exitCode = 1;
log(yellow('WARNING:'), 'Could not skip bundle size reporting');
logWithoutTimestamp(error);
return;
}
} else {
log(yellow('Pull requests can be marked as skipped only during CI builds'));
log(
yellow('WARNING'),
'Pull requests can be marked as skipped only during CI builds'
);
}
}

Expand All @@ -174,6 +172,12 @@ async function reportBundleSize() {
if (isPullRequestBuild()) {
const baseSha = gitCiMasterBaseline();
const commitHash = gitCommitHash();
log(
'Reporting bundle sizes for commit',
cyan(shortSha(commitHash)),
'using baseline commit',
cyan(shortSha(baseSha)) + '...'
);
try {
const response = await requestPost({
uri: url.resolve(
Expand All @@ -186,24 +190,19 @@ async function reportBundleSize() {
bundleSizes: await getBrotliBundleSizes(),
},
});
checkResponse(
response,
'Successfully reported bundle sizes for commit',
cyan(shortSha(commitHash)),
'using baseline commit',
cyan(shortSha(baseSha)) + '.'
);
checkResponse(response, 'Successfully reported bundle sizes.');
} catch (error) {
log(red('Could not report the bundle sizes for this pull request'));
log(red(error));
process.exitCode = 1;
log(
yellow('WARNING:'),
'Could not report the bundle sizes for this pull request'
);
logWithoutTimestamp(error);
return;
}
} else {
log(
yellow(
'Bundle sizes from pull requests can be reported only during CI builds'
)
yellow('WARNING:'),
'Bundle sizes from pull requests can be reported only during CI builds'
);
}
}
Expand Down