Separate sizebot for experimental builds (#17100)
Configures the sizebot to leave a second comment that tracks the experimental build artifacts.
Andrew Clark committed
Oct 15, 2019 at 18:43 UTC
2c832b4dcfa5406be1b16c03c78198e84380fc2e
3 files changed
+49
-11
.circleci/config.yml
+23
-1
@@ -205,7 +205,26 @@ jobs:
205
# This runs in the process_artifacts job, too, but it's faster to run
206
# this step in both jobs instead of running the jobs sequentially
207
- run: node ./scripts/rollup/consolidateBundleSizes.js
208
- - run: node ./scripts/tasks/danger
208
+ - run:
209
+ environment:
210
+ RELEASE_CHANNEL: stable
211
+ command: node ./scripts/tasks/danger
212
+
213
+ sizebot_experimental:
214
+ docker: *docker
215
+ environment: *environment
216
+ steps:
217
+ - checkout
218
+ - attach_workspace: *attach_workspace
219
+ - *restore_yarn_cache
220
+ - *run_yarn
221
+ # This runs in the process_artifacts job, too, but it's faster to run
222
+ # this step in both jobs instead of running the jobs sequentially
223
+ - run: node ./scripts/rollup/consolidateBundleSizes.js
224
+ - run:
225
+ environment:
226
+ RELEASE_CHANNEL: experimental
227
+ command: node ./scripts/tasks/danger
228
229
lint_build:
230
docker: *docker
@@ -370,6 +389,9 @@ workflows:
389
- process_artifacts_experimental:
390
requires:
391
- build_experimental
392
+ - sizebot_experimental:
393
+ requires:
394
+ - build_experimental
395
- test_build_experimental:
396
requires:
397
- build_experimental
dangerfile.js
+11
-2
@@ -32,6 +32,14 @@ const {generateResultsArray} = require('./scripts/rollup/stats');
32
const {existsSync, readFileSync} = require('fs');
33
const {exec} = require('child_process');
34
35
+// This must match the name of the CI job that creates the build artifacts
36
+const RELEASE_CHANNEL =
37
+ process.env.RELEASE_CHANNEL === 'experimental' ? 'experimental' : 'stable';
38
+const artifactsJobName =
39
+ process.env.RELEASE_CHANNEL === 'experimental'
40
+ ? 'process_artifacts_experimental'
41
+ : 'process_artifacts';
42
+
43
if (!existsSync('./build/bundle-sizes.json')) {
44
// This indicates the build failed previously.
45
// In that case, there's nothing for the Dangerfile to do.
@@ -117,6 +125,8 @@ function git(args) {
125
return;
126
}
127
128
+ markdown(`## Size changes (${RELEASE_CHANNEL})`);
129
+
130
const upstreamRef = danger.github.pr.base.ref;
131
await git(`remote add upstream https://github.com/facebook/react.git`);
132
await git('fetch upstream');
@@ -135,8 +145,7 @@ function git(args) {
145
}
146
for (let i = 0; i < statuses.length; i++) {
147
const status = statuses[i];
138
- // This must match the name of the CI job that creates the build artifacts
139
- if (status.context === 'ci/circleci: process_artifacts') {
148
+ if (status.context === `ci/circleci: ${artifactsJobName}`) {
149
if (status.state === 'success') {
150
baseCIBuildId = /\/facebook\/react\/([0-9]+)/.exec(
151
status.target_url
scripts/tasks/danger.js
+15
-8
@@ -14,14 +14,21 @@ const extension = process.platform === 'win32' ? '.cmd' : '';
14
15
// sizebot public_repo token (this is publicly visible on purpose)
16
const token = '0a7d5c3cad9a6dbec2d9' + '9a5222cf49062a4c1ef7';
17
-spawn(path.join('node_modules', '.bin', 'danger-ci' + extension), [], {
18
- // Allow colors to pass through
19
- stdio: 'inherit',
20
- env: {
21
- ...process.env,
22
- DANGER_GITHUB_API_TOKEN: token,
23
- },
24
-}).on('close', function(code) {
17
+spawn(
18
+ path.join('node_modules', '.bin', 'danger-ci' + extension),
19
+ [
20
+ '--id',
21
+ process.env.RELEASE_CHANNEL === 'experimental' ? 'experimental' : 'stable',
22
+ ],
23
+ {
24
+ // Allow colors to pass through
25
+ stdio: 'inherit',
26
+ env: {
27
+ ...process.env,
28
+ DANGER_GITHUB_API_TOKEN: token,
29
+ },
30
+ }
31
+).on('close', function(code) {
32
if (code !== 0) {
33
console.error('Danger failed');
34
} else {