Skip to content

Commit

Permalink
Separate sizebot for experimental builds
Browse files Browse the repository at this point in the history
Configures the sizebot to leave a second comment that tracks the
experimental build artifacts.
  • Loading branch information
acdlite committed Oct 15, 2019
1 parent 30c5daf commit d07d8b5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 11 deletions.
24 changes: 23 additions & 1 deletion .circleci/config.yml
Expand Up @@ -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
Expand Down Expand Up @@ -370,6 +389,9 @@ workflows:
- process_artifacts_experimental:
requires:
- build_experimental
- sizebot_experimental:
requires:
- build_experimental
- test_build_experimental:
requires:
- build_experimental
Expand Down
13 changes: 11 additions & 2 deletions dangerfile.js
Expand Up @@ -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.
Expand Down Expand Up @@ -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');
Expand All @@ -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
Expand Down
23 changes: 15 additions & 8 deletions scripts/tasks/danger.js
Expand Up @@ -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 {
Expand Down

0 comments on commit d07d8b5

Please sign in to comment.