Separate sizebot for experimental builds (#17100)

Configures the sizebot to leave a second comment that tracks the
experimental build artifacts.
This commit is contained in:
Andrew Clark 2019-10-15 18:43:06 -07:00 committed by GitHub
parent 3ac0eb075d
commit 2c832b4dcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 11 deletions

View File

@ -205,7 +205,26 @@ jobs:
# This runs in the process_artifacts job, too, but it's faster to run
# this step in both jobs instead of running the jobs sequentially
- run: node ./scripts/rollup/consolidateBundleSizes.js
- run: node ./scripts/tasks/danger
- run:
environment:
RELEASE_CHANNEL: stable
command: node ./scripts/tasks/danger
sizebot_experimental:
docker: *docker
environment: *environment
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
# This runs in the process_artifacts job, too, but it's faster to run
# this step in both jobs instead of running the jobs sequentially
- run: node ./scripts/rollup/consolidateBundleSizes.js
- run:
environment:
RELEASE_CHANNEL: experimental
command: node ./scripts/tasks/danger
lint_build:
docker: *docker
@ -370,6 +389,9 @@ workflows:
- process_artifacts_experimental:
requires:
- build_experimental
- sizebot_experimental:
requires:
- build_experimental
- test_build_experimental:
requires:
- build_experimental

View File

@ -32,6 +32,14 @@ const {generateResultsArray} = require('./scripts/rollup/stats');
const {existsSync, readFileSync} = require('fs');
const {exec} = require('child_process');
// This must match the name of the CI job that creates the build artifacts
const RELEASE_CHANNEL =
process.env.RELEASE_CHANNEL === 'experimental' ? 'experimental' : 'stable';
const artifactsJobName =
process.env.RELEASE_CHANNEL === 'experimental'
? 'process_artifacts_experimental'
: 'process_artifacts';
if (!existsSync('./build/bundle-sizes.json')) {
// This indicates the build failed previously.
// In that case, there's nothing for the Dangerfile to do.
@ -117,6 +125,8 @@ function git(args) {
return;
}
markdown(`## Size changes (${RELEASE_CHANNEL})`);
const upstreamRef = danger.github.pr.base.ref;
await git(`remote add upstream https://github.com/facebook/react.git`);
await git('fetch upstream');
@ -135,8 +145,7 @@ function git(args) {
}
for (let i = 0; i < statuses.length; i++) {
const status = statuses[i];
// This must match the name of the CI job that creates the build artifacts
if (status.context === 'ci/circleci: process_artifacts') {
if (status.context === `ci/circleci: ${artifactsJobName}`) {
if (status.state === 'success') {
baseCIBuildId = /\/facebook\/react\/([0-9]+)/.exec(
status.target_url

View File

@ -14,14 +14,21 @@ const extension = process.platform === 'win32' ? '.cmd' : '';
// sizebot public_repo token (this is publicly visible on purpose)
const token = '0a7d5c3cad9a6dbec2d9' + '9a5222cf49062a4c1ef7';
spawn(path.join('node_modules', '.bin', 'danger-ci' + extension), [], {
spawn(
path.join('node_modules', '.bin', 'danger-ci' + extension),
[
'--id',
process.env.RELEASE_CHANNEL === 'experimental' ? 'experimental' : 'stable',
],
{
// Allow colors to pass through
stdio: 'inherit',
env: {
...process.env,
DANGER_GITHUB_API_TOKEN: token,
},
}).on('close', function(code) {
}
).on('close', function(code) {
if (code !== 0) {
console.error('Danger failed');
} else {