Skip to content
Permalink
Browse files

Separate sizebot for experimental builds (#17100)

Configures the sizebot to leave a second comment that tracks the
experimental build artifacts.
  • Loading branch information
acdlite committed Oct 16, 2019
1 parent 3ac0eb0 commit 2c832b4dcfa5406be1b16c03c78198e84380fc2e
Showing with 49 additions and 11 deletions.
  1. +23 −1 .circleci/config.yml
  2. +11 −2 dangerfile.js
  3. +15 −8 scripts/tasks/danger.js
@@ -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
@@ -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
@@ -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), [], {
// Allow colors to pass through
stdio: 'inherit',
env: {
...process.env,
DANGER_GITHUB_API_TOKEN: token,
},
}).on('close', function(code) {
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) {
if (code !== 0) {
console.error('Danger failed');
} else {

0 comments on commit 2c832b4

Please sign in to comment.
You can’t perform that action at this time.