From d07d8b5d463baaf890fbadff63d2caccd10cf981 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Tue, 15 Oct 2019 15:18:45 -0700 Subject: [PATCH] Separate sizebot for experimental builds Configures the sizebot to leave a second comment that tracks the experimental build artifacts. --- .circleci/config.yml | 24 +++++++++++++++++++++++- dangerfile.js | 13 +++++++++++-- scripts/tasks/danger.js | 23 +++++++++++++++-------- 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 98915ea14a38e..6cf01d037c99e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/dangerfile.js b/dangerfile.js index 985c6b675626d..f4624a17c173d 100644 --- a/dangerfile.js +++ b/dangerfile.js @@ -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 diff --git a/scripts/tasks/danger.js b/scripts/tasks/danger.js index ebe488bf59831..e85dba26219cb 100644 --- a/scripts/tasks/danger.js +++ b/scripts/tasks/danger.js @@ -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 {