forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run the same JavaScript test script in Sandcastle and Circle (faceboo…
…k#24422) Summary: Consolidate JavaScript tests from open source into a single script that can be executed by both Circle CI and Sandcastle, the internal Facebook CI. [General] [Changed] - Switch internal and external CI to use the same script when running JavaScript tests Pull Request resolved: facebook#24422 Reviewed By: cpojer Differential Revision: D14895773 fbshipit-source-id: d428929cc4e5219e02f5920259e08e0b3d24874c
- Loading branch information
1 parent
00243c5
commit 5bac2b7
Showing
2 changed files
with
92 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* This script runs JavaScript tests. | ||
* Available arguments: | ||
* --maxWorkers [num] - how many workers, default 1 | ||
* --jestBinary [path] - path to jest binary, defaults to local node modules | ||
* --yarnBinary [path] - path to yarn binary, defaults to yarn | ||
*/ | ||
/*eslint-disable no-undef */ | ||
require('shelljs/global'); | ||
|
||
const argv = require('yargs').argv; | ||
const path = require('path'); | ||
|
||
const numberOfMaxWorkers = argv.maxWorkers || 1; | ||
let exitCode; | ||
|
||
const JEST_BINARY = argv.jestBinary || './node_modules/.bin/jest'; | ||
const YARN_BINARY = argv.yarnBinary || 'yarn'; | ||
|
||
function describe(message) { | ||
echo(`\n\n>>>>> ${message}\n\n\n`); | ||
} | ||
|
||
try { | ||
echo('Executing JavaScript tests'); | ||
|
||
describe('Test: eslint'); | ||
if (exec(`${YARN_BINARY} run lint`).code) { | ||
echo('Failed to run eslint.'); | ||
exitCode = 1; | ||
throw Error(exitCode); | ||
} | ||
|
||
describe('Test: Flow check (iOS)'); | ||
if (exec(`${YARN_BINARY} run flow-check-ios`).code) { | ||
echo('Failed to run flow.'); | ||
exitCode = 1; | ||
throw Error(exitCode); | ||
} | ||
describe('Test: Flow check (Android)'); | ||
if (exec(`${YARN_BINARY} run flow-check-android`).code) { | ||
echo('Failed to run flow.'); | ||
exitCode = 1; | ||
throw Error(exitCode); | ||
} | ||
|
||
describe('Test: Jest'); | ||
if ( | ||
exec( | ||
`${JEST_BINARY} --maxWorkers=${numberOfMaxWorkers} --ci --reporters="default" --reporters="jest-junit"`, | ||
).code | ||
) { | ||
echo('Failed to run JavaScript tests.'); | ||
echo('Most likely the code is broken.'); | ||
exitCode = 1; | ||
throw Error(exitCode); | ||
} | ||
|
||
exitCode = 0; | ||
} finally { | ||
// Do cleanup here | ||
echo('Finished.'); | ||
} | ||
exit(exitCode); | ||
|
||
/*eslint-enable no-undef */ |