From bfc11efea52c63299aab5bf8b81b9b305e1675b6 Mon Sep 17 00:00:00 2001 From: Dirk-Jan Rutten Date: Sat, 22 Oct 2016 16:12:21 +0200 Subject: [PATCH 1/4] Added functionality to crash the build during CI whenever linter warnings are encountered. --- packages/react-scripts/scripts/build.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index d0b92f6a73..2fac8ec4f4 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -142,6 +142,11 @@ function build(previousSizeMap) { process.exit(1); } + if (process.env.CI && stats.compilation.warnings.length) { + printErrors('Failed to compile. Note, the build has crashed because it is being run with the environment variable CI set to true. In this mode the build crashes when any warnings are encountered.', stats.compilation.warnings); + process.exit(1); + } + console.log(chalk.green('Compiled successfully.')); console.log(); From 90d1c3970d30859f862e487d2c043a47528b1d3d Mon Sep 17 00:00:00 2001 From: Dirk-Jan Rutten Date: Fri, 28 Oct 2016 22:09:18 +0200 Subject: [PATCH 2/4] Updated the docs with a description on how to use the build in CI --- packages/react-scripts/template/README.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index f364eda382..1b99c30635 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -788,7 +788,11 @@ Note that tests run much slower with coverage so it is recommended to run it sep ### Continuous Integration -By default `npm test` runs the watcher with interactive CLI. However, you can force it to run tests once and finish the process by setting an environment variable called `CI`. Popular CI servers already set it by default but you can do this yourself too: +By default `npm test` runs the watcher with interactive CLI. However, you can force it to run tests once and finish the process by setting an environment variable called `CI`. + +When creating a build of your application with `npm run build` linter warnings are not checked by default. Like `npm test`, you can force the build to perform a linter warning check by setting the environment variable `CI`. If any warnings are encountered then the build fails. + +Popular CI servers already set the environment variable `CI` by default but you can do this yourself too: ### On CI servers #### Travis CI @@ -805,6 +809,7 @@ cache: - node_modules script: - npm test + - npm run build ``` 1. Trigger your first build with a git push. 1. [Customize your Travis CI Build](https://docs.travis-ci.com/user/customizing-the-build/) if needed. @@ -816,6 +821,10 @@ script: set CI=true&&npm test ``` +```cmd +set CI=true&&npm run build +``` + (Note: the lack of whitespace is intentional.) ##### Linux, OS X (Bash) @@ -824,9 +833,15 @@ set CI=true&&npm test CI=true npm test ``` -This way Jest will run tests once instead of launching the watcher. +```bash +CI=true npm run build +``` + +The test command will force Jest to run tests once instead of launching the watcher. + +> If you find yourself doing this often in development, please [file an issue](https://github.com/facebookincubator/create-react-app/issues/new) to tell us about your use case because we want to make watcher the best experience and are open to changing how it works to accommodate more workflows. -If you find yourself doing this often in development, please [file an issue](https://github.com/facebookincubator/create-react-app/issues/new) to tell us about your use case because we want to make watcher the best experience and are open to changing how it works to accommodate more workflows. +The build command will check for linter warning and fail the build if any are found. ### Disabling jsdom From 2b57b8eda4f7c5f8127191b30b1a584fbc74e1ec Mon Sep 17 00:00:00 2001 From: Dirk-Jan Rutten Date: Sat, 29 Oct 2016 09:48:42 +0200 Subject: [PATCH 3/4] Fixed small typo --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 1b99c30635..025e1c6060 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -841,7 +841,7 @@ The test command will force Jest to run tests once instead of launching the watc > If you find yourself doing this often in development, please [file an issue](https://github.com/facebookincubator/create-react-app/issues/new) to tell us about your use case because we want to make watcher the best experience and are open to changing how it works to accommodate more workflows. -The build command will check for linter warning and fail the build if any are found. +The build command will check for linter warning and fail if any are found. ### Disabling jsdom From 93f687a1e7c5060a73f02d27c381d9867cd19acf Mon Sep 17 00:00:00 2001 From: Dirk-Jan Rutten Date: Sun, 27 Nov 2016 18:05:38 +0100 Subject: [PATCH 4/4] Fixed description of build error. --- packages/react-scripts/scripts/build.js | 2 +- packages/react-scripts/template/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index 2fac8ec4f4..06021f685c 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -143,7 +143,7 @@ function build(previousSizeMap) { } if (process.env.CI && stats.compilation.warnings.length) { - printErrors('Failed to compile. Note, the build has crashed because it is being run with the environment variable CI set to true. In this mode the build crashes when any warnings are encountered.', stats.compilation.warnings); + printErrors('Failed to compile.', stats.compilation.warnings); process.exit(1); } diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 025e1c6060..6efc449d68 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -841,7 +841,7 @@ The test command will force Jest to run tests once instead of launching the watc > If you find yourself doing this often in development, please [file an issue](https://github.com/facebookincubator/create-react-app/issues/new) to tell us about your use case because we want to make watcher the best experience and are open to changing how it works to accommodate more workflows. -The build command will check for linter warning and fail if any are found. +The build command will check for linter warnings and fail if any are found. ### Disabling jsdom