From b21575f52ad74f4a35d4bcaf8e237c62ac43c0b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Thu, 9 Aug 2018 16:15:19 -0700 Subject: [PATCH] Check Flow and run basic packager tests using open source RN config Summary: Most of the changes associated with this commit will not be visible on GitHub, as they concern files in the internal Facebook monorepo. The bulk of this change is the addition of a new test that runs on the internal test infrastructure. The actual script used by the test has various references to the internal test infra, but a copy is produced below with some changes that should allow it to run on open source should anyone be interested in testing this outside of Facebook. The test has the main goal of catching common sources of FB-to-GitHub breakages, such as the OSS Flow config falling out of date (we use a different flow config than what is synced out in .flowconfig, and hence internally we rename this file to .github.flowconfig). It also checks that the packager can run on a brand new project, among other things. ``` set -e THIS_DIR=$(pwd) REACT_NATIVE_TEMP_DIR=$(mktemp -d /tmp/react-native-XXXXXXXX) REACT_NATIVE_APP_TEMP_DIR=$(mktemp -d /tmp/react-native-XXXXXXXX) OFFLINE_MIRROR=$(yarn config get yarn-offline-mirror) function describe { printf "\\n\\n>>>>> %s\\n\\n\\n" "$1" } function cleanup { set +e rm -rf "$REACT_NATIVE_TEMP_DIR" rm -rf "$REACT_NATIVE_APP_TEMP_DIR" rm "$OFFLINE_MIRROR/react-native-v1000.0.0.tgz" set -e } trap cleanup EXIT describe "Creating temporary react-native-github clone" cp -R "react-native" "$REACT_NATIVE_TEMP_DIR" pushd "$REACT_NATIVE_TEMP_DIR/react-native" >/dev/null echo yarn-offline-mirror="$OFFLINE_MIRROR" > .npmrc describe "Installing react-native node_modules from offline cache" yarn install --mutex network --offline --frozen-lockfile --ignore-engines --ignore-scripts 2>&1 describe "Running a Flow check" mv .github.flowconfig .flowconfig ./node_modules/.bin/flow check describe "Running a basic packager test" touch .watchmanconfig node local-cli/cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js describe "Creating package for e2e test" yarn pack REACT_NATIVE_PACKAGE="$(pwd)/react-native-v1000.0.0.tgz" REACT_VERSION=$(node -p -e "require('./package.json').peerDependencies['react']") REACT_NATIVE_HASH=$(shasum "$REACT_NATIVE_PACKAGE" | awk '{print $1;}') REACT_NATIVE_DEPS=$(node -p -e "const deps=require('./package.json').dependencies; ' ' + Object.keys(deps).map(dep => dep + ' \"' + deps[dep] +'\"').join('\n ')") popd >/dev/null describe "Installing temporary RN app" mkdir "$REACT_NATIVE_APP_TEMP_DIR/PackagerTest" pushd "$REACT_NATIVE_APP_TEMP_DIR/PackagerTest" >/dev/null cp "$REACT_NATIVE_PACKAGE" ./ cp "$REACT_NATIVE_PACKAGE" "$OFFLINE_MIRROR" cp "$REACT_NATIVE_TEMP_DIR/react-native/.npmrc" ./ cp "$REACT_NATIVE_TEMP_DIR/react-native/yarn.lock" ./ cat <> yarn.lock react-native@1000.0.0: version "1000.0.0" resolved react-native-v1000.0.0.tgz#$REACT_NATIVE_HASH dependencies: $REACT_NATIVE_DEPS LOCKFILE cat > package.json <<- EndOfFile { "name": "packager-test", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start" }, "dependencies": { "react": "$REACT_VERSION", "react-native": "1000.0.0" } } EndOfFile yarn install --mutex network --offline --frozen-lockfile --ignore-engines --ignore-scripts 2>&1 sed -e s/"HelloWorld"/PackagerTest/g "react-native/local-cli/templates/HelloWorld/app.json" > app.json cp "react-native/local-cli/templates/HelloWorld/_buckconfig" .buckconfig cp "react-native/local-cli/templates/HelloWorld/_flowconfig" .flowconfig cp "react-native/local-cli/templates/HelloWorld/_watchmanconfig" .watchmanconfig cp "react-native/local-cli/templates/HelloWorld/App.js" App.js cp "react-native/local-cli/templates/HelloWorld/index.js" index.js describe "Running a Flow check on a new RN app" flow check describe "Verifying packager can produce JS bundle for a new RN app on both platforms" node ./node_modules/react-native/local-cli/cli.js bundle --platform ios --dev true --entry-file index.js --bundle-output ios-bundle.js test -e ios-bundle.js rm ios-bundle.js node ./node_modules/react-native/local-cli/cli.js bundle --platform android --dev true --entry-file index.js --bundle-output android-bundle.js test -e android-bundle.js rm android-bundle.js popd >/dev/null ``` Reviewed By: arcanis Differential Revision: D9129463 fbshipit-source-id: a91eeaa150ae6623ee67bd758bc8a98bb31e57b8 --- .flowconfig | 2 +- .github.flowconfig.android | 4 ++-- .gitignore | 4 ---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.flowconfig b/.flowconfig index 875fc6de9..0bd9289ff 100644 --- a/.flowconfig +++ b/.flowconfig @@ -56,7 +56,6 @@ module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1' module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1' module.system.haste.paths.blacklist=.*/__tests__/.* module.system.haste.paths.blacklist=.*/__mocks__/.* -module.system.haste.paths.blacklist=/Libraries/Animated/src/polyfills/.* module.system.haste.paths.whitelist=/Libraries/.* module.system.haste.paths.whitelist=/RNTester/.* module.system.haste.paths.whitelist=/IntegrationTests/.* @@ -78,6 +77,7 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError [lints] all=warn +unnecessary-optional-chain=off # There is an ESLint rule for this unclear-type=off diff --git a/.github.flowconfig.android b/.github.flowconfig.android index 94e6b74c9..83d6e2225 100644 --- a/.github.flowconfig.android +++ b/.github.flowconfig.android @@ -56,7 +56,6 @@ module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1' module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1' module.system.haste.paths.blacklist=.*/__tests__/.* module.system.haste.paths.blacklist=.*/__mocks__/.* -module.system.haste.paths.blacklist=/Libraries/Animated/src/polyfills/.* module.system.haste.paths.whitelist=/Libraries/.* module.system.haste.paths.whitelist=/RNTester/.* module.system.haste.paths.whitelist=/IntegrationTests/.* @@ -78,6 +77,7 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError [lints] all=warn +unnecessary-optional-chain=off # There is an ESLint rule for this unclear-type=off @@ -100,4 +100,4 @@ untyped-import untyped-type-import [version] -^0.77.0 +^0.78.0 diff --git a/.gitignore b/.gitignore index 50a3ed642..4fb4a25d1 100644 --- a/.gitignore +++ b/.gitignore @@ -51,10 +51,6 @@ node_modules *.log .nvm /bots/node_modules/ - -# TODO: Check in yarn.lock in open source. Right now we need to keep it out -# from the GitHub repo as importing it might conflict with internal workspaces -yarn.lock package-lock.json # OS X