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
This commit is contained in:
Adrian Carolli
2017-11-26 11:47:20 -05:00
committed by Dan Abramov
parent f53bd033e7
commit 53ef71b8e8
6 changed files with 57 additions and 20 deletions

View File

@@ -103,6 +103,7 @@
"build": "npm run version-check && node scripts/rollup/build.js",
"linc": "node ./scripts/tasks/linc.js",
"lint": "node ./scripts/tasks/eslint.js",
"lint-build": "node ./scripts/rollup/validate/index.js",
"postinstall": "node node_modules/fbjs-scripts/node/check-dev-engines.js package.json",
"test": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.source.js",
"test-prod": "cross-env NODE_ENV=production jest --config ./scripts/jest/config.source.js",

View File

@@ -9,7 +9,7 @@ yarn build --extract-errors
# See https://github.com/facebook/react/pull/11655.
# Do a sanity check on bundles
node ./scripts/rollup/validate/index
yarn lint-build
# Check that the standalone reconciler isn't borked
cd fixtures/reconciler

View File

@@ -0,0 +1,30 @@
#!/usr/bin/env node
'use strict';
const {logPromise, runYarnTask} = require('../utils');
module.exports = async ({cwd}) => {
await logPromise(
runYarnTask(cwd, 'lint-build', 'Lint bundle failed'),
'Running ESLint on bundle'
);
await logPromise(
runYarnTask(
cwd,
'test-build',
'Jest tests on the bundle failed in development'
),
'Running Jest tests on the bundle in the development environment',
true
);
await logPromise(
runYarnTask(
cwd,
'test-build-prod',
'Jest tests on the bundle failed in production'
),
'Running Jest tests on the bundle in the production environment',
true
);
};

View File

@@ -2,23 +2,7 @@
'use strict';
const chalk = require('chalk');
const {exec} = require('child-process-promise');
const {logPromise} = require('../utils');
const runYarnTask = async (cwd, task, errorMessage) => {
try {
await exec(`yarn ${task}`, {cwd});
} catch (error) {
throw Error(
chalk`
${errorMessage}
{white ${error.stdout}}
`
);
}
};
const {logPromise, runYarnTask} = require('../utils');
module.exports = async ({cwd}) => {
await logPromise(runYarnTask(cwd, 'lint', 'Lint failed'), 'Running ESLint');
@@ -27,8 +11,13 @@ module.exports = async ({cwd}) => {
'Running Flow checks'
);
await logPromise(
runYarnTask(cwd, 'test', 'Jest failed'),
'Running Jest tests',
runYarnTask(cwd, 'test', 'Jest tests failed in development'),
'Running Jest tests in the development environment',
true
);
await logPromise(
runYarnTask(cwd, 'test-prod', 'Jest tests failed in production'),
'Running Jest tests in the production environment',
true
);
};

View File

@@ -21,6 +21,7 @@ const run = async () => {
const parseBuildParameters = require('./build-commands/parse-build-parameters');
const printPostBuildSummary = require('./build-commands/print-post-build-summary');
const runAutomatedTests = require('./build-commands/run-automated-tests');
const runAutomatedBundleTests = require('./build-commands/run-automated-bundle-tests');
const updateGit = require('./build-commands/update-git');
const updatePackageVersions = require('./build-commands/update-package-versions');
const updateYarnDependencies = require('./build-commands/update-yarn-dependencies');
@@ -42,6 +43,7 @@ const run = async () => {
await runAutomatedTests(params);
await updatePackageVersions(params);
await buildArtifacts(params);
await runAutomatedBundleTests(params);
await addGitTag(params);
await printPostBuildSummary(params);
} catch (error) {

View File

@@ -82,10 +82,25 @@ const logPromise = async (promise, text, isLongRunningTask = false) => {
}
};
const runYarnTask = async (cwd, task, errorMessage) => {
try {
await exec(`yarn ${task}`, {cwd});
} catch (error) {
throw Error(
chalk`
${errorMessage}
{white ${error.stdout}}
`
);
}
};
module.exports = {
execRead,
execUnlessDry,
getPublicPackages,
getUnexecutedCommands,
logPromise,
runYarnTask,
};