From bb1e3d0e19f1e36ecb5b9e58d40bbf59fa220b73 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Mon, 20 Feb 2023 21:59:21 +0100 Subject: [PATCH] Fail yarn build if any bundle fails to build (#26207) ## Summary `yarn build` would previously still exit with zero exit code hiding build errors such as https://app.circleci.com/pipelines/github/facebook/react/38609/workflows/62a73635-3bf3-4264-8c48-a61844a27764/jobs/630503/parallel-runs/11?filterBy=ALL&invite=true#step-105-17. These issues are still surfaced due to missing size bot artifacts but the overall PR status would still be green which we don't want. Now we just exit with the same exit has a the process of a single build if it's non-zero. ## How did you test this change? - [x] fails based on the parent of 62e6c4612ec704cf07c99b318bc8f26d3ec3f588: https://app.circleci.com/pipelines/github/facebook/react/38681/workflows/654c68ed-cebc-48d4-a156-bac719772f6f/jobs/632166 - [x] passes based on `main` --- scripts/rollup/build-all-release-channels.js | 27 +++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/scripts/rollup/build-all-release-channels.js b/scripts/rollup/build-all-release-channels.js index 652d744eaaac3..0584803468891 100644 --- a/scripts/rollup/build-all-release-channels.js +++ b/scripts/rollup/build-all-release-channels.js @@ -93,15 +93,24 @@ if (process.env.CIRCLE_NODE_TOTAL) { } function buildForChannel(channel, nodeTotal, nodeIndex) { - spawnSync('node', ['./scripts/rollup/build.js', ...process.argv.slice(2)], { - stdio: ['pipe', process.stdout, process.stderr], - env: { - ...process.env, - RELEASE_CHANNEL: channel, - CIRCLE_NODE_TOTAL: nodeTotal, - CIRCLE_NODE_INDEX: nodeIndex, - }, - }); + const {status} = spawnSync( + 'node', + ['./scripts/rollup/build.js', ...process.argv.slice(2)], + { + stdio: ['pipe', process.stdout, process.stderr], + env: { + ...process.env, + RELEASE_CHANNEL: channel, + CIRCLE_NODE_TOTAL: nodeTotal, + CIRCLE_NODE_INDEX: nodeIndex, + }, + } + ); + + if (status !== 0) { + // Error of spawned process is already piped to this stderr + process.exit(status); + } } function processStable(buildDir) {