react-native-macos/scripts/run-ci-e2e-tests.js

310 строки
9.6 KiB
JavaScript
Исходник Обычный вид История

/**
* Copyright (c) Meta Platforms, Inc. and 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 tests that React Native end to end installation/bootstrap works for different platforms
* Available arguments:
* --ios - 'react-native init' and check iOS app doesn't redbox
* --android - 'react-native init' and check Android app doesn't redbox
* --js - 'react-native init' and only check the packager returns a bundle
* --skip-cli-install - to skip react-native-cli global installation (for local debugging)
* --retries [num] - how many times to retry possible flaky commands: yarn add and running tests, default 1
*/
const {cd, cp, echo, exec, exit, mv, rm} = require('shelljs');
const spawn = require('child_process').spawn;
const argv = require('yargs').argv;
const path = require('path');
Use verdaccio for the template e2e test (#34577) Summary: This PR adds [verdaccio](https://github.com/verdaccio/verdaccio) to release packages in the `packages` directory during the E2E test on CI. The rationale behind this is the following: - Firstly, we wanted to push the [monorepo RFC](https://github.com/react-native-community/discussions-and-proposals/pull/480). We hit an issue when renaming the packages to follow the same convention caused by the e2e test using the template to fail. This is because the template installs packages from the live version of npm – and if you just rename a package in a given PR without releasing it, the package understandably can't be installed since it's not published, yet – as you can see [here](https://app.circleci.com/pipelines/github/facebook/react-native/15286/workflows/149df51f-f59b-4eb3-b92c-20c513111f04/jobs/282135?invite=true#step-108-283). - Secondly, the current e2e test on `main` does not actually test the latest code of the packages in the `packages` directory as it simply downloads the latest versions from npm. This creates a divide between what's tested and what users should expect when using nightlies or when a new minor is released. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Internal] [Changed] - Use verdaccio for template e2e test Pull Request resolved: https://github.com/facebook/react-native/pull/34577 Test Plan: `test_js` CI check should pass. Additionally, I have temporarily updated the [PR](https://github.com/facebook/react-native/pull/34572) renaming `assets` to `assets-registry` to include the verdaccio changes – the `test_js` passes there, additionally proving merging this PR will unblock us with the rename PRs. Reviewed By: cipolleschi Differential Revision: D39723048 Pulled By: cortinico fbshipit-source-id: aeff3811967360740df3b3dbf1df50e506fb72d8
2022-09-22 15:02:37 +03:00
const {setupVerdaccio} = require('./setup-verdaccio');
const SCRIPTS = __dirname;
const ROOT = path.normalize(path.join(__dirname, '..'));
const tryExecNTimes = require('./try-n-times');
const REACT_NATIVE_TEMP_DIR = exec(
'mktemp -d /tmp/react-native-XXXXXXXX',
).stdout.trim();
const REACT_NATIVE_APP_DIR = `${REACT_NATIVE_TEMP_DIR}/template`;
const numberOfRetries = argv.retries || 1;
let SERVER_PID;
let APPIUM_PID;
Use verdaccio for the template e2e test (#34577) Summary: This PR adds [verdaccio](https://github.com/verdaccio/verdaccio) to release packages in the `packages` directory during the E2E test on CI. The rationale behind this is the following: - Firstly, we wanted to push the [monorepo RFC](https://github.com/react-native-community/discussions-and-proposals/pull/480). We hit an issue when renaming the packages to follow the same convention caused by the e2e test using the template to fail. This is because the template installs packages from the live version of npm – and if you just rename a package in a given PR without releasing it, the package understandably can't be installed since it's not published, yet – as you can see [here](https://app.circleci.com/pipelines/github/facebook/react-native/15286/workflows/149df51f-f59b-4eb3-b92c-20c513111f04/jobs/282135?invite=true#step-108-283). - Secondly, the current e2e test on `main` does not actually test the latest code of the packages in the `packages` directory as it simply downloads the latest versions from npm. This creates a divide between what's tested and what users should expect when using nightlies or when a new minor is released. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Internal] [Changed] - Use verdaccio for template e2e test Pull Request resolved: https://github.com/facebook/react-native/pull/34577 Test Plan: `test_js` CI check should pass. Additionally, I have temporarily updated the [PR](https://github.com/facebook/react-native/pull/34572) renaming `assets` to `assets-registry` to include the verdaccio changes – the `test_js` passes there, additionally proving merging this PR will unblock us with the rename PRs. Reviewed By: cipolleschi Differential Revision: D39723048 Pulled By: cortinico fbshipit-source-id: aeff3811967360740df3b3dbf1df50e506fb72d8
2022-09-22 15:02:37 +03:00
let VERDACCIO_PID;
let exitCode;
function describe(message) {
echo(`\n\n>>>>> ${message}\n\n\n`);
}
try {
if (argv.android) {
describe('Compile Android binaries');
if (
exec(
'./gradlew :ReactAndroid:installArchives -Pjobs=1 -Dorg.gradle.jvmargs="-Xmx512m -XX:+HeapDumpOnOutOfMemoryError"',
).code
) {
echo('Failed to compile Android binaries');
exitCode = 1;
throw Error(exitCode);
}
}
describe('Create react-native package');
if (exec('node ./scripts/set-rn-version.js --version 1000.0.0').code) {
echo('Failed to set version and update package.json ready for release');
exitCode = 1;
throw Error(exitCode);
}
if (exec('npm pack').code) {
echo('Failed to pack react-native');
exitCode = 1;
throw Error(exitCode);
}
const REACT_NATIVE_PACKAGE = path.join(ROOT, 'react-native-*.tgz');
Use verdaccio for the template e2e test (#34577) Summary: This PR adds [verdaccio](https://github.com/verdaccio/verdaccio) to release packages in the `packages` directory during the E2E test on CI. The rationale behind this is the following: - Firstly, we wanted to push the [monorepo RFC](https://github.com/react-native-community/discussions-and-proposals/pull/480). We hit an issue when renaming the packages to follow the same convention caused by the e2e test using the template to fail. This is because the template installs packages from the live version of npm – and if you just rename a package in a given PR without releasing it, the package understandably can't be installed since it's not published, yet – as you can see [here](https://app.circleci.com/pipelines/github/facebook/react-native/15286/workflows/149df51f-f59b-4eb3-b92c-20c513111f04/jobs/282135?invite=true#step-108-283). - Secondly, the current e2e test on `main` does not actually test the latest code of the packages in the `packages` directory as it simply downloads the latest versions from npm. This creates a divide between what's tested and what users should expect when using nightlies or when a new minor is released. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Internal] [Changed] - Use verdaccio for template e2e test Pull Request resolved: https://github.com/facebook/react-native/pull/34577 Test Plan: `test_js` CI check should pass. Additionally, I have temporarily updated the [PR](https://github.com/facebook/react-native/pull/34572) renaming `assets` to `assets-registry` to include the verdaccio changes – the `test_js` passes there, additionally proving merging this PR will unblock us with the rename PRs. Reviewed By: cipolleschi Differential Revision: D39723048 Pulled By: cortinico fbshipit-source-id: aeff3811967360740df3b3dbf1df50e506fb72d8
2022-09-22 15:02:37 +03:00
describe('Set up Verdaccio');
VERDACCIO_PID = setupVerdaccio();
describe('Publish packages');
const packages = JSON.parse(
JSON.parse(exec('yarn --json workspaces info').stdout).data,
);
Object.keys(packages).forEach(packageName => {
exec(
`cd ${packages[packageName].location} && npm publish --registry http://localhost:4873 --yes --access public`,
);
});
describe('Scaffold a basic React Native app from template');
exec(`rsync -a ${ROOT}/template ${REACT_NATIVE_TEMP_DIR}`);
cd(REACT_NATIVE_APP_DIR);
const METRO_CONFIG = path.join(ROOT, 'metro.config.js');
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392) Summary: Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`. Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job. What was done in this PR: * The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use. * The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument. * The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument * The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument ## Changelog [Internal] [CI] - ✅ Green CI, disabled test infrastructure work Pull Request resolved: https://github.com/facebook/react-native/pull/28392 Test Plan: Verified on Circle CI Reviewed By: cpojer Differential Revision: D20665512 Pulled By: hramos fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 16:49:03 +03:00
const RN_GET_POLYFILLS = path.join(ROOT, 'rn-get-polyfills.js');
const RN_POLYFILLS_PATH = 'packages/polyfills/';
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392) Summary: Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`. Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job. What was done in this PR: * The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use. * The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument. * The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument * The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument ## Changelog [Internal] [CI] - ✅ Green CI, disabled test infrastructure work Pull Request resolved: https://github.com/facebook/react-native/pull/28392 Test Plan: Verified on Circle CI Reviewed By: cpojer Differential Revision: D20665512 Pulled By: hramos fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 16:49:03 +03:00
exec(`mkdir -p ${RN_POLYFILLS_PATH}`);
cp(METRO_CONFIG, '.');
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392) Summary: Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`. Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job. What was done in this PR: * The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use. * The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument. * The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument * The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument ## Changelog [Internal] [CI] - ✅ Green CI, disabled test infrastructure work Pull Request resolved: https://github.com/facebook/react-native/pull/28392 Test Plan: Verified on Circle CI Reviewed By: cpojer Differential Revision: D20665512 Pulled By: hramos fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 16:49:03 +03:00
cp(RN_GET_POLYFILLS, '.');
exec(
`rsync -a ${ROOT}/${RN_POLYFILLS_PATH} ${REACT_NATIVE_APP_DIR}/${RN_POLYFILLS_PATH}`,
);
mv('_flowconfig', '.flowconfig');
mv('_watchmanconfig', '.watchmanconfig');
mv('_bundle', '.bundle');
describe('Install React Native package');
exec(`npm install ${REACT_NATIVE_PACKAGE}`);
describe('Install node_modules');
if (
tryExecNTimes(
() => {
return exec('npm install').code;
},
numberOfRetries,
() => exec('sleep 10s'),
)
) {
echo('Failed to execute npm install');
echo('Most common reason is npm registry connectivity, try again');
exitCode = 1;
throw Error(exitCode);
}
exec('rm -rf ./node_modules/react-native/template');
if (argv.android) {
describe('Install end-to-end framework');
if (
tryExecNTimes(
() =>
exec(
Fix and update end to end tests for Android (#23958) Summary: This PRs makes an attempt at fixing the set up of the Android end to end tests, and the tests themselves. The end goal is to re-enable the tests on CircleCI (see #23561 for more details). The goal of this PR is to the end to end tests to a working state. Better tests can be added at a later point. I changed the tests using the menu button. These tests made something silently crash/hang, after which it was no longer possible to get an element or even get the source. A fix for this needs further investigation. Also, I enabled the tests in the CircleCI config, however CircleCI is currently failing on them with the following error: ``` info Running /opt/android/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081 error: closed info Could not run adb reverse: Command failed: /opt/android/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081 info Starting the app on emulator-5554 (/opt/android/platform-tools/adb -s emulator-5554 shell am start -n com.endtoendtest/com.endtoendtest.MainActivity)... Starting: Intent { cmp=com.endtoendtest/.MainActivity } Too long with no output (exceeded 10m0s) ``` Some help here would be appreciated. An alternative is to not enable the tests yet on CircleCI in this PR. [Android] [fixed] - Fix and update end to end tests for Android Pull Request resolved: https://github.com/facebook/react-native/pull/23958 Differential Revision: D14502884 Pulled By: hramos fbshipit-source-id: 4316c3fd817451d332e64a10d88389b74a60d3dd
2019-03-18 17:34:26 +03:00
'yarn add --dev appium@1.11.1 mocha@2.4.5 wd@1.11.1 colors@1.0.3 pretty-data2@0.40.1',
{silent: true},
).code,
numberOfRetries,
)
) {
echo('Failed to install appium');
echo('Most common reason is npm registry connectivity, try again');
exitCode = 1;
throw Error(exitCode);
}
cp(`${SCRIPTS}/android-e2e-test.js`, 'android-e2e-test.js');
cd('android');
describe('Download Maven deps');
exec('./gradlew :app:copyDownloadableDepsToLibs');
cd('..');
Fix and update end to end tests for Android (#23958) Summary: This PRs makes an attempt at fixing the set up of the Android end to end tests, and the tests themselves. The end goal is to re-enable the tests on CircleCI (see #23561 for more details). The goal of this PR is to the end to end tests to a working state. Better tests can be added at a later point. I changed the tests using the menu button. These tests made something silently crash/hang, after which it was no longer possible to get an element or even get the source. A fix for this needs further investigation. Also, I enabled the tests in the CircleCI config, however CircleCI is currently failing on them with the following error: ``` info Running /opt/android/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081 error: closed info Could not run adb reverse: Command failed: /opt/android/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081 info Starting the app on emulator-5554 (/opt/android/platform-tools/adb -s emulator-5554 shell am start -n com.endtoendtest/com.endtoendtest.MainActivity)... Starting: Intent { cmp=com.endtoendtest/.MainActivity } Too long with no output (exceeded 10m0s) ``` Some help here would be appreciated. An alternative is to not enable the tests yet on CircleCI in this PR. [Android] [fixed] - Fix and update end to end tests for Android Pull Request resolved: https://github.com/facebook/react-native/pull/23958 Differential Revision: D14502884 Pulled By: hramos fbshipit-source-id: 4316c3fd817451d332e64a10d88389b74a60d3dd
2019-03-18 17:34:26 +03:00
describe('Generate key');
Fix and update end to end tests for Android (#23958) Summary: This PRs makes an attempt at fixing the set up of the Android end to end tests, and the tests themselves. The end goal is to re-enable the tests on CircleCI (see #23561 for more details). The goal of this PR is to the end to end tests to a working state. Better tests can be added at a later point. I changed the tests using the menu button. These tests made something silently crash/hang, after which it was no longer possible to get an element or even get the source. A fix for this needs further investigation. Also, I enabled the tests in the CircleCI config, however CircleCI is currently failing on them with the following error: ``` info Running /opt/android/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081 error: closed info Could not run adb reverse: Command failed: /opt/android/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081 info Starting the app on emulator-5554 (/opt/android/platform-tools/adb -s emulator-5554 shell am start -n com.endtoendtest/com.endtoendtest.MainActivity)... Starting: Intent { cmp=com.endtoendtest/.MainActivity } Too long with no output (exceeded 10m0s) ``` Some help here would be appreciated. An alternative is to not enable the tests yet on CircleCI in this PR. [Android] [fixed] - Fix and update end to end tests for Android Pull Request resolved: https://github.com/facebook/react-native/pull/23958 Differential Revision: D14502884 Pulled By: hramos fbshipit-source-id: 4316c3fd817451d332e64a10d88389b74a60d3dd
2019-03-18 17:34:26 +03:00
exec('rm android/app/debug.keystore');
if (
exec(
'keytool -genkey -v -keystore android/app/debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Android Debug,O=Android,C=US"',
).code
) {
echo('Key could not be generated');
exitCode = 1;
throw Error(exitCode);
}
describe(`Start appium server, ${APPIUM_PID}`);
const appiumProcess = spawn('node', ['./node_modules/.bin/appium']);
APPIUM_PID = appiumProcess.pid;
describe('Build the app');
if (exec('react-native run-android').code) {
Fix and update end to end tests for Android (#23958) Summary: This PRs makes an attempt at fixing the set up of the Android end to end tests, and the tests themselves. The end goal is to re-enable the tests on CircleCI (see #23561 for more details). The goal of this PR is to the end to end tests to a working state. Better tests can be added at a later point. I changed the tests using the menu button. These tests made something silently crash/hang, after which it was no longer possible to get an element or even get the source. A fix for this needs further investigation. Also, I enabled the tests in the CircleCI config, however CircleCI is currently failing on them with the following error: ``` info Running /opt/android/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081 error: closed info Could not run adb reverse: Command failed: /opt/android/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081 info Starting the app on emulator-5554 (/opt/android/platform-tools/adb -s emulator-5554 shell am start -n com.endtoendtest/com.endtoendtest.MainActivity)... Starting: Intent { cmp=com.endtoendtest/.MainActivity } Too long with no output (exceeded 10m0s) ``` Some help here would be appreciated. An alternative is to not enable the tests yet on CircleCI in this PR. [Android] [fixed] - Fix and update end to end tests for Android Pull Request resolved: https://github.com/facebook/react-native/pull/23958 Differential Revision: D14502884 Pulled By: hramos fbshipit-source-id: 4316c3fd817451d332e64a10d88389b74a60d3dd
2019-03-18 17:34:26 +03:00
echo('could not execute react-native run-android');
exitCode = 1;
throw Error(exitCode);
}
describe(`Start Metro, ${SERVER_PID}`);
// shelljs exec('', {async: true}) does not emit stdout events, so we rely on good old spawn
Use verdaccio for the template e2e test (#34577) Summary: This PR adds [verdaccio](https://github.com/verdaccio/verdaccio) to release packages in the `packages` directory during the E2E test on CI. The rationale behind this is the following: - Firstly, we wanted to push the [monorepo RFC](https://github.com/react-native-community/discussions-and-proposals/pull/480). We hit an issue when renaming the packages to follow the same convention caused by the e2e test using the template to fail. This is because the template installs packages from the live version of npm – and if you just rename a package in a given PR without releasing it, the package understandably can't be installed since it's not published, yet – as you can see [here](https://app.circleci.com/pipelines/github/facebook/react-native/15286/workflows/149df51f-f59b-4eb3-b92c-20c513111f04/jobs/282135?invite=true#step-108-283). - Secondly, the current e2e test on `main` does not actually test the latest code of the packages in the `packages` directory as it simply downloads the latest versions from npm. This creates a divide between what's tested and what users should expect when using nightlies or when a new minor is released. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Internal] [Changed] - Use verdaccio for template e2e test Pull Request resolved: https://github.com/facebook/react-native/pull/34577 Test Plan: `test_js` CI check should pass. Additionally, I have temporarily updated the [PR](https://github.com/facebook/react-native/pull/34572) renaming `assets` to `assets-registry` to include the verdaccio changes – the `test_js` passes there, additionally proving merging this PR will unblock us with the rename PRs. Reviewed By: cipolleschi Differential Revision: D39723048 Pulled By: cortinico fbshipit-source-id: aeff3811967360740df3b3dbf1df50e506fb72d8
2022-09-22 15:02:37 +03:00
const packagerProcess = spawn('yarn', ['start', '--max-workers 1']);
SERVER_PID = packagerProcess.pid;
// wait a bit to allow packager to startup
exec('sleep 15s');
describe('Test: Android end-to-end test');
if (
tryExecNTimes(
() => {
return exec('node node_modules/.bin/_mocha android-e2e-test.js').code;
},
numberOfRetries,
() => exec('sleep 10s'),
)
) {
echo('Failed to run Android end-to-end tests');
echo('Most likely the code is broken');
exitCode = 1;
throw Error(exitCode);
}
}
if (argv.ios) {
cd('ios');
// shelljs exec('', {async: true}) does not emit stdout events, so we rely on good old spawn
const packagerEnv = Object.create(process.env);
packagerEnv.REACT_NATIVE_MAX_WORKERS = 1;
describe('Start Metro');
const packagerProcess = spawn('yarn', ['start'], {
stdio: 'inherit',
env: packagerEnv,
});
SERVER_PID = packagerProcess.pid;
exec('sleep 15s');
// prepare cache to reduce chances of possible red screen "Can't find variable __fbBatchedBridge..."
exec(
'response=$(curl --write-out %{http_code} --silent --output /dev/null localhost:8081/index.bundle?platform=ios&dev=true)',
);
echo(`Metro is running, ${SERVER_PID}`);
describe('Install CocoaPod dependencies');
exec('bundle exec pod install');
describe('Test: iOS end-to-end test');
if (
// TODO: Get target OS and simulator from .tests.env
tryExecNTimes(
() => {
return exec(
[
'xcodebuild',
'-workspace',
'"HelloWorld.xcworkspace"',
'-destination',
'"platform=iOS Simulator,name=iPhone 8,OS=13.3"',
'-scheme',
'"HelloWorld"',
'-sdk',
'iphonesimulator',
'-UseModernBuildSystem=NO',
'test',
].join(' ') +
' | ' +
[
'xcpretty',
'--report',
'junit',
'--output',
'"~/react-native/reports/junit/iOS-e2e/results.xml"',
].join(' ') +
' && exit ${PIPESTATUS[0]}',
).code;
},
numberOfRetries,
() => exec('sleep 10s'),
)
) {
echo('Failed to run iOS end-to-end tests');
echo('Most likely the code is broken');
exitCode = 1;
throw Error(exitCode);
}
cd('..');
}
if (argv.js) {
// Check the packager produces a bundle (doesn't throw an error)
describe('Test: Verify packager can generate an Android bundle');
if (
exec(
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392) Summary: Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`. Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job. What was done in this PR: * The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use. * The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument. * The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument * The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument ## Changelog [Internal] [CI] - ✅ Green CI, disabled test infrastructure work Pull Request resolved: https://github.com/facebook/react-native/pull/28392 Test Plan: Verified on Circle CI Reviewed By: cpojer Differential Revision: D20665512 Pulled By: hramos fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 16:49:03 +03:00
'yarn react-native bundle --verbose --entry-file index.js --platform android --dev true --bundle-output android-bundle.js --max-workers 1',
).code
) {
echo('Could not build Android bundle');
exitCode = 1;
throw Error(exitCode);
}
describe('Test: Verify packager can generate an iOS bundle');
if (
exec(
'yarn react-native bundle --entry-file index.js --platform ios --dev true --bundle-output ios-bundle.js --max-workers 1',
).code
) {
echo('Could not build iOS bundle');
exitCode = 1;
throw Error(exitCode);
}
describe('Test: Flow check');
// The resolve package included a test for a malformed package.json (see https://github.com/browserify/resolve/issues/89)
// that is failing the flow check. We're removing it.
rm('-rf', './node_modules/resolve/test/resolver/malformed_package_json');
if (exec(`${ROOT}/node_modules/.bin/flow check`).code) {
echo('Flow check failed.');
exitCode = 1;
throw Error(exitCode);
}
}
exitCode = 0;
} finally {
describe('Clean up');
if (SERVER_PID) {
echo(`Killing packager ${SERVER_PID}`);
exec(`kill -9 ${SERVER_PID}`);
// this is quite drastic but packager starts a daemon that we can't kill by killing the parent process
// it will be fixed in April (quote David Aurelio), so until then we will kill the zombie by the port number
exec("lsof -i tcp:8081 | awk 'NR!=1 {print $2}' | xargs kill");
}
if (APPIUM_PID) {
echo(`Killing appium ${APPIUM_PID}`);
exec(`kill -9 ${APPIUM_PID}`);
}
Use verdaccio for the template e2e test (#34577) Summary: This PR adds [verdaccio](https://github.com/verdaccio/verdaccio) to release packages in the `packages` directory during the E2E test on CI. The rationale behind this is the following: - Firstly, we wanted to push the [monorepo RFC](https://github.com/react-native-community/discussions-and-proposals/pull/480). We hit an issue when renaming the packages to follow the same convention caused by the e2e test using the template to fail. This is because the template installs packages from the live version of npm – and if you just rename a package in a given PR without releasing it, the package understandably can't be installed since it's not published, yet – as you can see [here](https://app.circleci.com/pipelines/github/facebook/react-native/15286/workflows/149df51f-f59b-4eb3-b92c-20c513111f04/jobs/282135?invite=true#step-108-283). - Secondly, the current e2e test on `main` does not actually test the latest code of the packages in the `packages` directory as it simply downloads the latest versions from npm. This creates a divide between what's tested and what users should expect when using nightlies or when a new minor is released. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Internal] [Changed] - Use verdaccio for template e2e test Pull Request resolved: https://github.com/facebook/react-native/pull/34577 Test Plan: `test_js` CI check should pass. Additionally, I have temporarily updated the [PR](https://github.com/facebook/react-native/pull/34572) renaming `assets` to `assets-registry` to include the verdaccio changes – the `test_js` passes there, additionally proving merging this PR will unblock us with the rename PRs. Reviewed By: cipolleschi Differential Revision: D39723048 Pulled By: cortinico fbshipit-source-id: aeff3811967360740df3b3dbf1df50e506fb72d8
2022-09-22 15:02:37 +03:00
if (VERDACCIO_PID) {
echo(`Killing verdaccio ${VERDACCIO_PID}`);
exec(`kill -9 ${VERDACCIO_PID}`);
}
}
exit(exitCode);