Skip to content

Commit 3010e5e

Browse files
watadarkstarEthan-Arrowood
authored andcommitted
Add bundle linting and tests to the release script (facebook#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
1 parent 1cdc272 commit 3010e5e

File tree

6 files changed

+57
-20
lines changed

6 files changed

+57
-20
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
"build": "npm run version-check && node scripts/rollup/build.js",
104104
"linc": "node ./scripts/tasks/linc.js",
105105
"lint": "node ./scripts/tasks/eslint.js",
106+
"lint-build": "node ./scripts/rollup/validate/index.js",
106107
"postinstall": "node node_modules/fbjs-scripts/node/check-dev-engines.js package.json",
107108
"test": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.source.js",
108109
"test-prod": "cross-env NODE_ENV=production jest --config ./scripts/jest/config.source.js",

scripts/circleci/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ yarn build --extract-errors
1010
# See https://github.com/facebook/react/pull/11655.
1111

1212
# Do a sanity check on bundles
13-
node ./scripts/rollup/validate/index
13+
yarn lint-build
1414

1515
# Check that the standalone reconciler isn't borked
1616
cd fixtures/reconciler
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,7 @@
22

33
'use strict';
44

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');
226

237
module.exports = async ({cwd}) => {
248
await logPromise(runYarnTask(cwd, 'lint', 'Lint failed'), 'Running ESLint');
@@ -27,8 +11,13 @@ module.exports = async ({cwd}) => {
2711
'Running Flow checks'
2812
);
2913
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',
3221
true
3322
);
3423
};

scripts/release/build.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const run = async () => {
2121
const parseBuildParameters = require('./build-commands/parse-build-parameters');
2222
const printPostBuildSummary = require('./build-commands/print-post-build-summary');
2323
const runAutomatedTests = require('./build-commands/run-automated-tests');
24+
const runAutomatedBundleTests = require('./build-commands/run-automated-bundle-tests');
2425
const updateGit = require('./build-commands/update-git');
2526
const updatePackageVersions = require('./build-commands/update-package-versions');
2627
const updateYarnDependencies = require('./build-commands/update-yarn-dependencies');
@@ -42,6 +43,7 @@ const run = async () => {
4243
await runAutomatedTests(params);
4344
await updatePackageVersions(params);
4445
await buildArtifacts(params);
46+
await runAutomatedBundleTests(params);
4547
await addGitTag(params);
4648
await printPostBuildSummary(params);
4749
} catch (error) {

scripts/release/utils.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,25 @@ const logPromise = async (promise, text, isLongRunningTask = false) => {
8282
}
8383
};
8484

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+
8599
module.exports = {
86100
execRead,
87101
execUnlessDry,
88102
getPublicPackages,
89103
getUnexecutedCommands,
90104
logPromise,
105+
runYarnTask,
91106
};

0 commit comments

Comments
 (0)