Run the same JavaScript test script in Sandcastle and Circle (#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: https://github.com/facebook/react-native/pull/24422

Reviewed By: cpojer

Differential Revision: D14895773

fbshipit-source-id: d428929cc4e5219e02f5920259e08e0b3d24874c
This commit is contained in:
Héctor Ramos
2019-04-12 09:50:13 -07:00
committed by Facebook Github Bot
parent 00243c580f
commit 5bac2b761e
2 changed files with 92 additions and 6 deletions

View File

@@ -266,6 +266,7 @@ jobs:
- run:
name: Lint code
command: scripts/circleci/exec_swallow_error.sh yarn lint --format junit -o ~/react-native/reports/junit/eslint/results.xml
when: always
- run:
name: Check for errors in code using Flow (iOS)
@@ -284,6 +285,11 @@ jobs:
./scripts/circleci/validate_yarn_lockfile.sh
when: always
- run:
name: Check formatting
command: yarn run format-check
when: always
- store_test_results:
path: ~/react-native/reports/junit
- store_artifacts:
@@ -299,11 +305,13 @@ jobs:
- attach_workspace:
at: ~/react-native
- run: *run-js-tests
- run:
name: JavaScript Test Suite
command: node ./scripts/run-ci-javascript-tests.js --maxWorkers 2
- run:
name: JavaScript End-to-End Test Suite
command: node ./scripts/run-ci-e2e-tests.js --js --retries 3;
command: node ./scripts/run-ci-e2e-tests.js --js --retries 3
- store_test_results:
path: ~/react-native/reports/junit
@@ -319,9 +327,9 @@ jobs:
- run: *yarn
- run: *run-js-tests
- run: yarn run format-check
- run:
name: JavaScript Test Suite
command: node ./scripts/run-ci-javascript-tests.js --maxWorkers 2
- store_test_results:
path: ~/react-native/reports/junit
@@ -608,7 +616,8 @@ workflows:
- test_android: *run-after-checkout
- test_ios: *run-after-checkout
- test_detox_end_to_end: *run-after-checkout
- test_docker_build
- test_docker_build:
filters: *filter-ignore-gh-pages
releases:
jobs:

View File

@@ -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 */