-
Notifications
You must be signed in to change notification settings - Fork 25k
Improve test manual e2e script #28382
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
Changes from all commits
c793805
e05db3b
6d6e5d8
15ace70
976e3e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -24,98 +24,139 @@ info() { | |||||
| echo -e "$BLUE""$*""$ENDCOLOR" | ||||||
| } | ||||||
|
|
||||||
| kill_packagers() { | ||||||
| success "Killing any running packagers" | ||||||
| lsof -i :8081 | grep LISTEN | ||||||
| lsof -i :8081 | grep LISTEN | /usr/bin/awk '{print $2}' | xargs kill | ||||||
| } | ||||||
|
|
||||||
| REPO_ROOT=$(pwd) | ||||||
| CLI_PATH="$REPO_ROOT/cli.js" | ||||||
|
|
||||||
| PACKAGE_VERSION=$(cat package.json \ | ||||||
| | grep version \ | ||||||
| | head -1 \ | ||||||
| | awk -F: '{ print $2 }' \ | ||||||
| | sed 's/[",]//g' \ | ||||||
| | tr -d '[[:space:]]') | ||||||
|
|
||||||
| success "Preparing version $PACKAGE_VERSION" | ||||||
|
|
||||||
| repo_root=$(pwd) | ||||||
|
|
||||||
| rm -rf android | ||||||
| ./gradlew :ReactAndroid:installArchives || error "Couldn't generate artifacts" | ||||||
|
|
||||||
| success "Generated artifacts for Maven" | ||||||
|
|
||||||
| npm install | ||||||
|
|
||||||
| success "Killing any running packagers" | ||||||
| lsof -i :8081 | grep LISTEN | ||||||
| lsof -i :8081 | grep LISTEN | /usr/bin/awk '{print $2}' | xargs kill | ||||||
|
|
||||||
| info "Start the packager in another terminal by running 'npm start' from the root" | ||||||
| info "and then press any key." | ||||||
| info "" | ||||||
| read -n 1 | ||||||
|
|
||||||
| ./gradlew :RNTester:android:app:installJscDebug || error "Couldn't build RNTester Android" | ||||||
| ANDROID_EMULATOR_NAME=${ANDROID_EMULATOR_NAME:-$(emulator -list-avds | awk '{print $1}')} | ||||||
|
|
||||||
| info "Press any key to run RNTester in an already running Android emulator/device" | ||||||
| info "" | ||||||
| read -n 1 | ||||||
| adb shell am start -n com.facebook.react.uiapp/.RNTesterActivity | ||||||
| # Prepare | ||||||
| { | ||||||
| info "Preparing version $PACKAGE_VERSION" | ||||||
|
|
||||||
| info "Press any key to open the workspace in Xcode, then build and test manually." | ||||||
| info "" | ||||||
| read -n 1 | ||||||
| success "Installing CocoaPods dependencies" | ||||||
| rm -rf RNTester/Pods && cd RNTester && pod install | ||||||
| open "RNTester/RNTesterPods.xcworkspace" | ||||||
| # Do this as early as possible, so there's a bit of time for the emulator to launch before we interact with it | ||||||
| info "Launching Android emulator: $ANDROID_EMULATOR_NAME" | ||||||
| emulator -no-boot-anim -avd "$ANDROID_EMULATOR_NAME" & | ||||||
|
|
||||||
| info "When done testing RNTester app on iOS and Android press any key to continue." | ||||||
| info "" | ||||||
| read -n 1 | ||||||
| yarn install | ||||||
|
|
||||||
| success "Killing packager" | ||||||
| lsof -i :8081 | grep LISTEN | ||||||
| lsof -i :8081 | grep LISTEN | /usr/bin/awk '{print $2}' | xargs kill | ||||||
| rm -rf android | ||||||
| ./gradlew :ReactAndroid:installArchives || error "Couldn't generate artifacts" | ||||||
|
|
||||||
| npm pack | ||||||
|
|
||||||
| PACKAGE=$(pwd)/react-native-$PACKAGE_VERSION.tgz | ||||||
| success "Package bundled ($PACKAGE)" | ||||||
|
|
||||||
| node scripts/set-rn-template-version.js "file:$PACKAGE" | ||||||
| success "React Native version changed in the template" | ||||||
|
|
||||||
| project_name="RNTestProject" | ||||||
|
|
||||||
| cd /tmp/ | ||||||
| rm -rf "$project_name" | ||||||
| node "$repo_root/cli.js" init "$project_name" --template "$repo_root" | ||||||
|
|
||||||
| info "Double checking the versions in package.json are correct:" | ||||||
| grep "\"react-native\": \".*react-native-$PACKAGE_VERSION.tgz\"" "/tmp/${project_name}/package.json" || error "Incorrect version number in /tmp/${project_name}/package.json" | ||||||
| grep -E "com.facebook.react:react-native:\\+" "${project_name}/android/app/build.gradle" || error "Dependency in /tmp/${project_name}/android/app/build.gradle must be com.facebook.react:react-native:+" | ||||||
|
|
||||||
| success "New sample project generated at /tmp/${project_name}" | ||||||
|
|
||||||
| info "Test the following on Android:" | ||||||
| info " - Disable Fast Refresh. It might be enabled from last time (the setting is stored on the device)" | ||||||
| info " - Verify 'Reload JS' works" | ||||||
| info "" | ||||||
| info "Press any key to run the sample in Android emulator/device" | ||||||
| info "" | ||||||
| read -n 1 | ||||||
| cd "/tmp/${project_name}" && npx react-native run-android | ||||||
| kill_packagers | ||||||
| } | ||||||
|
|
||||||
| info "Test the following on iOS:" | ||||||
| info " - Disable Fast Refresh. It might be enabled from last time (the setting is stored on the device)" | ||||||
| info " - Verify 'Reload JS' works" | ||||||
| info " - Test Chrome debugger by adding breakpoints and reloading JS. We don't have tests for Chrome debugging." | ||||||
| info " - Disable Chrome debugging." | ||||||
| info " - Enable Fast Refresh, change a file (index.js) and save. The UI should refresh." | ||||||
| info " - Disable Fast Refresh." | ||||||
| info "" | ||||||
| info "Press any key to open the project in Xcode" | ||||||
| info "" | ||||||
| read -n 1 | ||||||
| open "/tmp/${project_name}/ios/${project_name}.xcodeproj" | ||||||
| # Test RNTester | ||||||
| { | ||||||
| info "Starting the packager in the background" | ||||||
| node "$CLI_PATH" start & | ||||||
|
|
||||||
| # Android | ||||||
| { | ||||||
| ./gradlew :RNTester:android:app:installJscDebug || error "Couldn't build RNTester Android" | ||||||
|
|
||||||
| info "Deleting previously installed Android RNTester app" | ||||||
| adb uninstall com.facebook.react.uiapp | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice |
||||||
|
|
||||||
| info "Press any key to run RNTester in an already running Android emulator/device" | ||||||
| info "" | ||||||
| read -n 1 | ||||||
| adb shell am start -n com.facebook.react.uiapp/.RNTesterActivity | ||||||
| } | ||||||
|
|
||||||
| # iOS | ||||||
| pushd RNTester | ||||||
| { | ||||||
| info "Press any key to open the workspace in Xcode, then build and test manually." | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if it should live here or not, but I was wondering if it was useful to run |
||||||
| info "" | ||||||
| read -n 1 | ||||||
| success "Installing CocoaPods dependencies" | ||||||
| rm -rf Pods && pod install | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...and
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, yeah that seems a bit much. What is your experience with this?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tbh just that I am a bad person and I do tabula rasa on my projects when I need to ensure full clean 😂 and you know way better than me how Pods work so I'm fully ok with not including this command 👍 |
||||||
| open "RNTesterPods.xcworkspace" | ||||||
| } | ||||||
| popd | ||||||
|
|
||||||
| info "When done testing RNTester app on iOS and Android press any key to continue." | ||||||
| info "" | ||||||
| read -n 1 | ||||||
|
|
||||||
| kill_packagers | ||||||
| } | ||||||
|
|
||||||
| cd "$repo_root" | ||||||
| # Test new app from template | ||||||
| { | ||||||
| npm pack | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(or is it a npm specific command?)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really, but it also doesn’t do anything with version resolving, so I’m less worried about it. I can take a look, though, and make the whole script uniform 👍 |
||||||
|
|
||||||
| PACKAGE=$(pwd)/react-native-$PACKAGE_VERSION.tgz | ||||||
| success "Package bundled ($PACKAGE)" | ||||||
|
|
||||||
| node scripts/set-rn-template-version.js "file:$PACKAGE" | ||||||
| success "React Native version changed in the template" | ||||||
|
|
||||||
| project_name="RNTestProject" | ||||||
| project_dirname="/tmp" | ||||||
| project_path="${project_dirname}/${project_name}" | ||||||
|
|
||||||
| pushd "$project_dirname" | ||||||
| { | ||||||
| rm -rf "$project_name" | ||||||
| node "$CLI_PATH" init "$project_name" --template "$REPO_ROOT" | ||||||
| } | ||||||
| popd | ||||||
|
|
||||||
| info "Double checking the versions in package.json are correct:" | ||||||
| grep "\"react-native\": \".*react-native-$PACKAGE_VERSION.tgz\"" "${project_path}/package.json" || error "Incorrect version number in ${project_path}/package.json" | ||||||
| grep -E "com.facebook.react:react-native:\\+" "${project_path}/android/app/build.gradle" || error "Dependency in ${project_path}/android/app/build.gradle must be com.facebook.react:react-native:+" | ||||||
|
|
||||||
| success "New sample project generated at ${project_path}" | ||||||
|
|
||||||
| pushd "$project_path" | ||||||
| { | ||||||
| # Android | ||||||
| { | ||||||
| info "Deleting previously installed Android $project_name app" | ||||||
| adb uninstall com.$(echo $project_name | awk '{print tolower($0)}') | ||||||
|
|
||||||
| info "Test the following on Android:" | ||||||
| info " - Disable Fast Refresh. It might be enabled from last time (the setting is stored on the device)" | ||||||
| info " - Verify 'Reload JS' works" | ||||||
| info "" | ||||||
| info "Press any key to run the sample in Android emulator/device" | ||||||
| info "" | ||||||
| read -n 1 | ||||||
| node "$CLI_PATH" run-android | ||||||
| } | ||||||
|
|
||||||
| # iOS | ||||||
| { | ||||||
| info "Test the following on iOS:" | ||||||
| info " - Disable Fast Refresh. It might be enabled from last time (the setting is stored on the device)" | ||||||
| info " - Verify 'Reload JS' works" | ||||||
| info " - Test Chrome debugger by adding breakpoints and reloading JS. We don't have tests for Chrome debugging." | ||||||
| info " - Disable Chrome debugging." | ||||||
| info " - Enable Fast Refresh, change a file (index.js) and save. The UI should refresh." | ||||||
| info " - Disable Fast Refresh." | ||||||
| info "" | ||||||
| info "Press any key to open the project in Xcode" | ||||||
| info "" | ||||||
| read -n 1 | ||||||
| node "$CLI_PATH" run-ios | ||||||
| } | ||||||
| } | ||||||
| popd | ||||||
| } | ||||||
|
|
||||||
| info "Next steps:" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tbh I think that these last 2 lines could be even be removed, I don't think they provide any actual value. Or maybe we could change the link to point to https://github.com/react-native-community/releases/blob/master/README.md or even https://github.com/react-native-community/releases/blob/master/docs/release-process.md? |
||||||
| info " - https://github.com/facebook/react-native/blob/master/Releases.md" | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably change a bit this section to 'clean up the house' more. For ex. I'd extract (similar to what happens to
kill_packagers) all the cleanup part to its own method and in it, something along the lines of:and call it after
info "Preparing version $PACKAGE_VERSION"What do you think?
PS: maybe we could even add some more scripts to that like
rm -rf ~/Library/Developer/Xcode/DerivedData/*