@samitouri / QOS-React / commits / 53ef71b8e8

Add bundle linting and tests to the release script (#11662)

* Add bundle linting and tests to the release script - add yarn lint-build - use yarn lint-build in circle ci build.sh - add yarn lint-build, yarn test-prod, yarn test-build, and yarn test-build-prod to the realse script * Improve readability of release test messages * Run prettier * Updating package versions for release 16.2.0 * Seperate bundle specific tests - Moved the runYarnTask into utils since its being used two files now - Uncomment out checks I mistakenly committed * Revert a bunch of version bump changes Mistakenly commited by release script * .js for consistency

Adrian Carolli committed Nov 26, 2017 at 11:47 UTC 53ef71b8e8ba03058f99d57fcb1efe15956c3f36
6 files changed +57 -20
package.json
+1
@@ -103,6 +103,7 @@
103 "build": "npm run version-check && node scripts/rollup/build.js",
104 "linc": "node ./scripts/tasks/linc.js",
105 "lint": "node ./scripts/tasks/eslint.js",
106 + "lint-build": "node ./scripts/rollup/validate/index.js",
107 "postinstall": "node node_modules/fbjs-scripts/node/check-dev-engines.js package.json",
108 "test": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.source.js",
109 "test-prod": "cross-env NODE_ENV=production jest --config ./scripts/jest/config.source.js",
scripts/circleci/build.sh
+1 -1
@@ -9,7 +9,7 @@ yarn build --extract-errors
9 # See https://github.com/facebook/react/pull/11655.
10
11 # Do a sanity check on bundles
12 -node ./scripts/rollup/validate/index
12 +yarn lint-build
13
14 # Check that the standalone reconciler isn't borked
15 cd fixtures/reconciler
scripts/release/build-commands/run-automated-bundle-tests.js new
+30
@@ -0,0 +1,30 @@
1 +#!/usr/bin/env node
2 +
3 +'use strict';
4 +
5 +const {logPromise, runYarnTask} = require('../utils');
6 +
7 +module.exports = async ({cwd}) => {
8 + await logPromise(
9 + runYarnTask(cwd, 'lint-build', 'Lint bundle failed'),
10 + 'Running ESLint on bundle'
11 + );
12 + await logPromise(
13 + runYarnTask(
14 + cwd,
15 + 'test-build',
16 + 'Jest tests on the bundle failed in development'
17 + ),
18 + 'Running Jest tests on the bundle in the development environment',
19 + true
20 + );
21 + await logPromise(
22 + runYarnTask(
23 + cwd,
24 + 'test-build-prod',
25 + 'Jest tests on the bundle failed in production'
26 + ),
27 + 'Running Jest tests on the bundle in the production environment',
28 + true
29 + );
30 +};
scripts/release/build-commands/run-automated-tests.js
+8 -19
@@ -2,23 +2,7 @@
2
3 'use strict';
4
5 -const chalk = require('chalk');
6 -const {exec} = require('child-process-promise');
7 -const {logPromise} = require('../utils');
8 -
9 -const runYarnTask = async (cwd, task, errorMessage) => {
10 - try {
11 - await exec(`yarn ${task}`, {cwd});
12 - } catch (error) {
13 - throw Error(
14 - chalk`
15 - ${errorMessage}
16 -
17 - {white ${error.stdout}}
18 - `
19 - );
20 - }
21 -};
5 +const {logPromise, runYarnTask} = require('../utils');
6
7 module.exports = async ({cwd}) => {
8 await logPromise(runYarnTask(cwd, 'lint', 'Lint failed'), 'Running ESLint');
@@ -27,8 +11,13 @@ module.exports = async ({cwd}) => {
11 'Running Flow checks'
12 );
13 await logPromise(
30 - runYarnTask(cwd, 'test', 'Jest failed'),
31 - 'Running Jest tests',
14 + runYarnTask(cwd, 'test', 'Jest tests failed in development'),
15 + 'Running Jest tests in the development environment',
16 + true
17 + );
18 + await logPromise(
19 + runYarnTask(cwd, 'test-prod', 'Jest tests failed in production'),
20 + 'Running Jest tests in the production environment',
21 true
22 );
23 };
scripts/release/build.js
+2
@@ -21,6 +21,7 @@ const run = async () => {
21 const parseBuildParameters = require('./build-commands/parse-build-parameters');
22 const printPostBuildSummary = require('./build-commands/print-post-build-summary');
23 const runAutomatedTests = require('./build-commands/run-automated-tests');
24 + const runAutomatedBundleTests = require('./build-commands/run-automated-bundle-tests');
25 const updateGit = require('./build-commands/update-git');
26 const updatePackageVersions = require('./build-commands/update-package-versions');
27 const updateYarnDependencies = require('./build-commands/update-yarn-dependencies');
@@ -42,6 +43,7 @@ const run = async () => {
43 await runAutomatedTests(params);
44 await updatePackageVersions(params);
45 await buildArtifacts(params);
46 + await runAutomatedBundleTests(params);
47 await addGitTag(params);
48 await printPostBuildSummary(params);
49 } catch (error) {
scripts/release/utils.js
+15
@@ -82,10 +82,25 @@ const logPromise = async (promise, text, isLongRunningTask = false) => {
82 }
83 };
84
85 +const runYarnTask = async (cwd, task, errorMessage) => {
86 + try {
87 + await exec(`yarn ${task}`, {cwd});
88 + } catch (error) {
89 + throw Error(
90 + chalk`
91 + ${errorMessage}
92 +
93 + {white ${error.stdout}}
94 + `
95 + );
96 + }
97 +};
98 +
99 module.exports = {
100 execRead,
101 execUnlessDry,
102 getPublicPackages,
103 getUnexecutedCommands,
104 logPromise,
105 + runYarnTask,
106 };