Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run the same JavaScript test script in Sandcastle and Circle #24422

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 15 additions & 6 deletions .circleci/config.yml
Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
77 changes: 77 additions & 0 deletions scripts/run-ci-javascript-tests.js
@@ -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 */