Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2c832b4

Browse files
authored
Separate sizebot for experimental builds (facebook#17100)
Configures the sizebot to leave a second comment that tracks the experimental build artifacts.
1 parent 3ac0eb0 commit 2c832b4

File tree

3 files changed

+49
-11
lines changed

3 files changed

+49
-11
lines changed

.circleci/config.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,26 @@ jobs:
205205
# This runs in the process_artifacts job, too, but it's faster to run
206206
# this step in both jobs instead of running the jobs sequentially
207207
- 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
209228

210229
lint_build:
211230
docker: *docker
@@ -370,6 +389,9 @@ workflows:
370389
- process_artifacts_experimental:
371390
requires:
372391
- build_experimental
392+
- sizebot_experimental:
393+
requires:
394+
- build_experimental
373395
- test_build_experimental:
374396
requires:
375397
- build_experimental

dangerfile.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ const {generateResultsArray} = require('./scripts/rollup/stats');
3232
const {existsSync, readFileSync} = require('fs');
3333
const {exec} = require('child_process');
3434

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+
3543
if (!existsSync('./build/bundle-sizes.json')) {
3644
// This indicates the build failed previously.
3745
// In that case, there's nothing for the Dangerfile to do.
@@ -117,6 +125,8 @@ function git(args) {
117125
return;
118126
}
119127

128+
markdown(`## Size changes (${RELEASE_CHANNEL})`);
129+
120130
const upstreamRef = danger.github.pr.base.ref;
121131
await git(`remote add upstream https://github.com/facebook/react.git`);
122132
await git('fetch upstream');
@@ -135,8 +145,7 @@ function git(args) {
135145
}
136146
for (let i = 0; i < statuses.length; i++) {
137147
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}`) {
140149
if (status.state === 'success') {
141150
baseCIBuildId = /\/facebook\/react\/([0-9]+)/.exec(
142151
status.target_url

scripts/tasks/danger.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,21 @@ const extension = process.platform === 'win32' ? '.cmd' : '';
1414

1515
// sizebot public_repo token (this is publicly visible on purpose)
1616
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) {
2532
if (code !== 0) {
2633
console.error('Danger failed');
2734
} else {

0 commit comments

Comments
 (0)