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

[CI] Fix e2e detox build step #24953

Closed
wants to merge 4 commits into from

Conversation

nossbigg
Copy link
Contributor

@nossbigg nossbigg commented May 19, 2019

Summary

Fixes the e2e detox build step by manually overriding PROJECT_ROOT for the project's JS bundle build step.

After seeing quite a few comments suggesting running some variant of the react-native bundle manually on your own so as to build the jsbundle required as part of the build step for RNTester project...

The main issue I found was that the working directory in which react-native-xcode.sh executed the CLI bundle step was not correct. The PROJECT_ROOT was not resolving to the root of the react-native project directory, but instead to something to the effect of /Users/gibson.cheng/IdeaProjects/react-native/../.. - of which of course the build step would not be able to find the react-native project to run the build against.

I'm not sure if new generated react-native projects require this manual override, so I only applied it to the RNTester project. Reviewers are welcome to correct my understanding and solutioning to this matter :)

@hramos, if this works, perhaps there would not be a need to push through with #24936. Also, this contributes to #23561.

Changelog

[Internal] [Fixed] - Fix build-ios-e2e build step

Test Plan

  1. build-ios-e2e should work now

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 19, 2019
Manually provide PROJECT_ROOT for RNTester project js bundle build step
@nossbigg nossbigg force-pushed the fix-rntester-e2e-build branch from ece87d2 to e608c4c Compare May 19, 2019 16:41
@nossbigg nossbigg changed the title Fix e2e RNTester build step [CI] Fix e2e RNTester build step May 19, 2019
@nossbigg nossbigg changed the title [CI] Fix e2e RNTester build step [CI] Fix e2e detox build step May 19, 2019
@hramos
Copy link
Contributor

hramos commented May 20, 2019

Thanks for the PR! I'll update mine and avoid disabling the Detox tests.

Copy link
Contributor

@hramos hramos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the Detox e2e tests finished successfully. Thanks for doing this. Could you verify if it would be possible to override the $PROJECT_ROOT envvar when invoking the react-native-xcode.sh script instead?

outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n$SRCROOT/../scripts/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js\n";
shellScript = "export NODE_BINARY=node\n$SRCROOT/../scripts/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js $SRCROOT/..\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
shellScript = "export NODE_BINARY=node\n$SRCROOT/../scripts/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js $SRCROOT/..\n";
shellScript = "export NODE_BINARY=node\nPROJECT_ROOT=$SRCROOT/.. $SRCROOT/../scripts/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js\n";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work, in place of adding a second parameter to the script? It would remove the need for $PROJECT_ROOT_OVERRIDE.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supplying PROJECT_ROOT via env var whilst starting the react-native-xcode.sh won't override the PROJECT_ROOT var inside the script, as the var is constructed inside the shell script (with no existing logic to accept overrides externally).

REACT_NATIVE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# The project should be located next to where react-native is installed
# in node_modules.
PROJECT_ROOT=${PROJECT_ROOT:-"$REACT_NATIVE_DIR/../.."}
cd "$PROJECT_ROOT" || exit

I agree with you that supplying the PROJECT_ROOT_OVERRIDE via script arg is not as elegant as supplying it via env var. In the case of the latter approach, the initialization of the script will look something like:

PROJECT_ROOT_OVERRIDE=$SRCROOT/.. $SRCROOT/../scripts/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js;

If this is workable, i'll go ahead with it 👍

Copy link
Contributor

@hramos hramos May 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is it should be overridable. The following line sets PROJECT_ROOT to the current value of PROJECT_ROOT, unless it is not defined, in which case it is set to "$REACT_NATIVE_DIR/../..".

PROJECT_ROOT=${PROJECT_ROOT:-"$REACT_NATIVE_DIR/../.."} 

I verified that's the case in https://circleci.com/gh/hramos/react-native/5739
. I'll apply those changes and land.

@hramos hramos added the 🔩Test Infrastructure Test infrastructure and continuous integration. label May 20, 2019
@nossbigg nossbigg force-pushed the fix-rntester-e2e-build branch from 67924c0 to f8483ee Compare May 20, 2019 10:49
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hramos is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @nossbigg in adc0878.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label May 20, 2019
@nossbigg
Copy link
Contributor Author

Thanks for the merge, @hramos! :)

vovkasm pushed a commit to vovkasm/react-native that referenced this pull request Aug 12, 2019
Summary:
Fixes the e2e detox build step by manually overriding `PROJECT_ROOT` for the project's JS bundle build step.

After seeing [quite](facebook#18472 (comment)) [a](facebook#18472 (comment)) [few](facebook#15432 (comment)) [comments](https://stackoverflow.com/a/49506072) suggesting running some variant of the `react-native bundle` manually on your own so as to build the jsbundle required as part of the build step for RNTester project...

The main issue I found was that the working directory in which `react-native-xcode.sh` executed the CLI bundle step was not correct. The `PROJECT_ROOT` was not resolving to the root of the `react-native` project directory, but instead to something to the effect of `/Users/gibson.cheng/IdeaProjects/react-native/../..` - of which of course the build step would not be able to find the `react-native` project to run the build against.

I'm not sure if new generated `react-native` projects require this manual override, so I only applied it to the RNTester project. Reviewers are welcome to correct my understanding and solutioning to this matter :)

hramos, if this works, perhaps there would not be a need to push through with facebook#24936. Also, this  contributes to facebook#23561.

## Changelog

[Internal] [Fixed] - Fix build-ios-e2e build step
Pull Request resolved: facebook#24953

Differential Revision: D15415850

Pulled By: hramos

fbshipit-source-id: baaff09f81f01be4da1608e0b2898d037db35c23
(cherry picked from commit adc0878)
M-i-k-e-l pushed a commit to M-i-k-e-l/react-native that referenced this pull request Mar 10, 2020
Summary:
Fixes the e2e detox build step by manually overriding `PROJECT_ROOT` for the project's JS bundle build step.

After seeing [quite](facebook#18472 (comment)) [a](facebook#18472 (comment)) [few](facebook#15432 (comment)) [comments](https://stackoverflow.com/a/49506072) suggesting running some variant of the `react-native bundle` manually on your own so as to build the jsbundle required as part of the build step for RNTester project...

The main issue I found was that the working directory in which `react-native-xcode.sh` executed the CLI bundle step was not correct. The `PROJECT_ROOT` was not resolving to the root of the `react-native` project directory, but instead to something to the effect of `/Users/gibson.cheng/IdeaProjects/react-native/../..` - of which of course the build step would not be able to find the `react-native` project to run the build against.

I'm not sure if new generated `react-native` projects require this manual override, so I only applied it to the RNTester project. Reviewers are welcome to correct my understanding and solutioning to this matter :)

hramos, if this works, perhaps there would not be a need to push through with facebook#24936. Also, this  contributes to facebook#23561.

## Changelog

[Internal] [Fixed] - Fix build-ios-e2e build step
Pull Request resolved: facebook#24953

Differential Revision: D15415850

Pulled By: hramos

fbshipit-source-id: baaff09f81f01be4da1608e0b2898d037db35c23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. 🔩Test Infrastructure Test infrastructure and continuous integration.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants