Skip to content

Commit d66c8f2

Browse files
authored
Update sizebot to match name of CircleCI build job (facebook#15714)
The sizebot scrapes the GitHub `/statuses` endpoint to get the lastest CircleCI build number for master, in order to fetch the bundle size info for that build, which are stored as build artifacts. (There's gotta be a better way to do this, but that's what we have for now.) This updates the script to match the name of the updated CircleCI job that generates the bundle sizes.
1 parent 5c2124f commit d66c8f2

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

.circleci/config.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ jobs:
126126
- run: ./scripts/circleci/update_package_versions.sh
127127
- run: ./scripts/circleci/build.sh
128128
- run: cp ./scripts/rollup/results.json ./build/bundle-sizes.json
129-
- run: node ./scripts/tasks/danger
130129
- run: ./scripts/circleci/upload_build.sh
131130
- run: ./scripts/circleci/pack_and_store_artifact.sh
132131
- store_artifacts:
@@ -143,6 +142,18 @@ jobs:
143142
- facebook-www
144143
- node_modules
145144
- react-native
145+
- bundle-sizes.json
146+
147+
sizebot:
148+
build:
149+
docker: *docker
150+
environment: *environment
151+
steps:
152+
- checkout
153+
- attach_workspace: *attach_workspace
154+
- *restore_yarn_cache
155+
- *run_yarn
156+
- run: node ./scripts/tasks/danger
146157

147158
test_build:
148159
docker: *docker
@@ -193,6 +204,9 @@ workflows:
193204
- build:
194205
requires:
195206
- setup
207+
- sizebot:
208+
requires:
209+
- build
196210
- test_build:
197211
requires:
198212
- build

dangerfile.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ if (!existsSync('./build/bundle-sizes.json')) {
3636
// This indicates the build failed previously.
3737
// In that case, there's nothing for the Dangerfile to do.
3838
// Exit early to avoid leaving a redundant (and potentially confusing) PR comment.
39+
warn(
40+
'No bundle size information found. This indicates the build ' +
41+
'job failed.'
42+
);
3943
process.exit(0);
4044
}
4145

@@ -127,7 +131,8 @@ function git(args) {
127131
const statuses = await statusesResponse.json();
128132
for (let i = 0; i < statuses.length; i++) {
129133
const status = statuses[i];
130-
if (status.context === 'ci/circleci') {
134+
// This must match the name of the CI job that creates the build artifacts
135+
if (status.context === 'ci/circleci: build') {
131136
if (status.state === 'success') {
132137
baseCIBuildId = /\/facebook\/react\/([0-9]+)/.exec(
133138
status.target_url
@@ -271,5 +276,7 @@ function git(args) {
271276
</details>
272277
`;
273278
markdown(summary);
279+
} else {
280+
markdown('No significant bundle size changes to report.');
274281
}
275282
})();

0 commit comments

Comments
 (0)