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

fix(local-e2e-script): add logic to handle maven local for iOS and Android accordingly #35104

Closed
wants to merge 25 commits into from

Conversation

kelset
Copy link
Contributor

@kelset kelset commented Oct 27, 2022

Summary

This PR is a follow up of #35075 and 1546666 to ensure that even in the local e2e testing scenario the new maven approach is followed - without this, RNTestProject on Android won't work, like so:
Screenshot 2022-10-27 at 12 15 38

And iOS will always build everything from source every time.

This PR addresses both by generating the artifacts locally, and passing them to RNTestProject as if they were coming from a url (mimicking as closely as possible the behaviour for the final user)

In doing so, there's been some refactoring to prep the ground for follow up work.

  • refactor CI to rely less on scripts directly in the CircleCI config, but invoke .js ones
  • we should be able to trigger more the "manual" artifacts generation so that it will only happen once between RNTester and RNTestProject, and we can pass existing artifacts to the other flows.
  • once all of this in place, a very good improvement would be to be able to download the maven artifacts kind of like nightlies and stables do. This will only be viable by checking that there's no local changes, after which there needs to be logic to pull down from CircleCI the artifacts based on git commit <-> circleCI job references.

While at it, I've also fixed the hermes-engine podspec logic for detecting if it's on CI: basically the local e2e script needs to align with the changes done here: 4b51207

but as you can see there, the condition was actually inconsistent across the various files, so realigned to CI === 'true'. We probably didn't catch that so far 'cause the other condition in the hermes podspect (existence of hermestag_file) is only true on release branches and this new logic has not been in any release branches yet.

Changelog

[Internal] [Fixed] - add logic to local e2e script to handle maven local for iOS and Android accordingly

Test Plan

Run yarn test-e2e-local -t RNTestProject -p Android successfully.

Run yarn test-e2e-local -t RNTestProject -p iOS successfully. On the pod install stage, you will see [Hermes] Using pre-built Hermes binaries from local path.

@analysis-bot
Copy link

analysis-bot commented Oct 27, 2022

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 64c3906
Branch: main

@kelset kelset force-pushed the kelset/ensure-e2e-works-with-new-maven branch from 0d6979c to cb123ee Compare October 27, 2022 13:27
@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 Oct 27, 2022
@analysis-bot
Copy link

analysis-bot commented Oct 27, 2022

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 6,992,247 +0
android hermes armeabi-v7a 6,368,778 +0
android hermes x86 7,404,941 +0
android hermes x86_64 7,268,948 +0
android jsc arm64-v8a 8,855,839 +0
android jsc armeabi-v7a 7,594,355 +0
android jsc x86 8,913,589 +0
android jsc x86_64 9,396,951 +0

Base commit: 64c3906
Branch: main

@cortinico cortinico changed the title make rngp consider the local e2e test case Extend the local e2e test case to provide the REACT_NATIVE_MAVEN_LOCAL_REPO property Oct 27, 2022
@kelset kelset force-pushed the kelset/ensure-e2e-works-with-new-maven branch from d8feea7 to d484acf Compare October 28, 2022 10:46
@kelset kelset changed the title Extend the local e2e test case to provide the REACT_NATIVE_MAVEN_LOCAL_REPO property fix(local-e2e-script): add logic to handle maven local for iOS and Android accordingly Oct 28, 2022
// FIXME: need to figure out how to generate the hermes stuff
// (can I just do a pod install for RNTester iOS and use those files? need to find where they are stored)
// and get the Hermes reference here for the next phase
const hermesDir = 'help me';
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed on discord, we should probably call these two scripts:

I still believe that we should also provide a way where we tell the scripts from where it can download all the stuff, saving hours of building, though.

But let's start by having a version that works!

@kelset kelset force-pushed the kelset/ensure-e2e-works-with-new-maven branch from 72f3ca4 to a643659 Compare October 31, 2022 11:41
@hramos
Copy link
Contributor

hramos commented Oct 31, 2022

@kelset I am planning to rename the tarball methods in hermes-utils.js in order to make a clear distinction between the different tarballs that we deal with:

  • Hermes source code tarball, generated by GitHub and downloaded from github.com/facebook/hermes
  • Hermes prebuilt artifact tarball, generated by Circle CI and downloaded from Maven
  • Hermes debug symbols tarball, generated by Circle CI and downloaded from Maven (WIP)

Here's the PR: #35156 - I have updated all the internal references to these methods.

I realize this would conflict with your PR. What do you think? Would renaming these have an adverse impact on other scripts from the community? Would you be okay rebasing your work on top of #35156 if it is merged?

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Nice! Practically, we may potentially use the same generateiOSArtifacts in CI directly! XD

@kelset
Copy link
Contributor Author

kelset commented Oct 31, 2022

@hramos go ahead and merge yours, yeah I'll have conflicts but I'm still in the testing phase for this one so it's likely that your PR will be quicker to land

@cipolleschi
Copy link
Contributor

Question/idea for a later PR: do we want to setup a circleci job that runs this script? In that way, if someone commits something that could potentially break it, the check will ask him to also fix the script.

WDYT?

@kelset kelset force-pushed the kelset/ensure-e2e-works-with-new-maven branch from babac46 to 3befaef Compare November 1, 2022 10:25
@kelset kelset marked this pull request as ready for review November 1, 2022 11:51
@kelset
Copy link
Contributor Author

kelset commented Nov 1, 2022

update: now the PR should be ready, I've run a few more tests and done more tweaks. Every flow seems to be working as expected.

re: @cipolleschi

Question/idea for a later PR: do we want to setup a circleci job that runs this script? In that way, if someone commits something that could potentially break it, the check will ask him to also fix the script.

No, I don't think there's value in running this script specifically - on CI it'd basically just build RNTester and RNTestProject, take a lot of time and not verify much that is not already verified by other CI jobs. The main advantage of this script is in the local scenario, where you want to have 1 handy command to get easily to have a local build working so that you can play around with it in the emulator/simulator.

This topic overlaps with the E2E conversation that is been happening in parallel, so I'm sure that we'll be able to do some refactoring so that both the E2E flows and this script will have less custom code and we can generalize certain sections

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

}
// set HERMES_ENGINE_TARBALL_PATH to point to the local artifacts I just created
exec(
`HERMES_ENGINE_TARBALL_PATH=${tarballOutputPath} USE_HERMES=${
Copy link
Contributor Author

@kelset kelset Nov 1, 2022

Choose a reason for hiding this comment

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

this part I don't particularly like because it means that if the tester needs to test something else with RNTestProject - ex. test that everything still works on JSC, they will have to do a new pod install without hermes, but if after that they want to test Hermes again they will have to manually pass this HERMES_ENGINE_TARBALL_PATH variable during the pod install :(

Sadly because of limitations of shelljs we can't set ENV variables through it, and since there's no gradle.properties equivalent we're stuck with this. Hopefully it won't create many attritions

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

scripts/release-utils.js Outdated Show resolved Hide resolved
scripts/test-e2e-local.js Outdated Show resolved Hide resolved
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

left a nit comment with some context.

@kelset kelset force-pushed the kelset/ensure-e2e-works-with-new-maven branch from 0609a02 to 838bcd9 Compare November 2, 2022 11:08
@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@kelset
Copy link
Contributor Author

kelset commented Nov 2, 2022

quick headsup, I've updated this PR to account for some of the commits that landed in the last 12/24 hrs, such as:

And especially 6b8e13f which for some reason did add some new scripts but not as executable, so took care of it.

Before:
Screenshot 2022-11-02 at 12 43 43

After:
Screenshot 2022-11-02 at 12 50 32

@kelset
Copy link
Contributor Author

kelset commented Nov 2, 2022

final update (I hope 🤣):
everything working as expected:
Screenshot 2022-11-02 at 14 27 15

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@kelset kelset deleted the kelset/ensure-e2e-works-with-new-maven branch November 2, 2022 15:32
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @kelset in c540ff7.

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 Nov 2, 2022
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
…droid accordingly (facebook#35104)

Summary:
This PR is a follow up of facebook#35075 and facebook@1546666 to ensure that even in the local e2e testing scenario the new maven approach is followed - without this, RNTestProject on Android won't work, like so:
<img width="1905" alt="Screenshot 2022-10-27 at 12 15 38" src="https://user-images.githubusercontent.com/16104054/198334105-30fb2037-4e7c-4814-8c3f-2412ba0bd49f.png">

And iOS will always build everything from source every time.

This PR addresses both by generating the artifacts locally, and passing them to RNTestProject as if they were coming from a url (mimicking as closely as possible the behaviour for the final user)

In doing so, there's been some refactoring to prep the ground for follow up work.
* refactor CI to rely less on scripts directly in the CircleCI config, but invoke .js ones
* we should be able to trigger more the "manual" artifacts generation so that it will only happen once between RNTester and RNTestProject, and we can pass existing artifacts to the other flows.
* once all of this in place, a very good improvement would be to be able to download the maven artifacts kind of like nightlies and stables do. This will only be viable by checking that there's no local changes, after which there needs to be logic to pull down from CircleCI the artifacts based on git commit <-> circleCI job references.
 ---

While at it, I've also fixed the hermes-engine podspec logic for detecting if it's on CI: basically the local e2e script needs to align with the changes done here: facebook@4b51207

but as you can see there, the condition was actually inconsistent across the various files, so realigned to `CI === 'true'`. We probably didn't catch that so far 'cause the other condition in the hermes podspect (existence of `hermestag_file`) is only true on release branches and this new logic has not been in any release branches yet.

## 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] [Fixed] - add logic to local e2e script to handle maven local for iOS and Android accordingly

Pull Request resolved: facebook#35104

Test Plan:
Run ` yarn test-e2e-local -t RNTestProject -p Android` successfully.

Run ` yarn test-e2e-local -t RNTestProject -p iOS` successfully. On the pod install stage, you will see `[Hermes] Using pre-built Hermes binaries from local path.`

Reviewed By: dmytrorykun

Differential Revision: D40893239

Pulled By: cipolleschi

fbshipit-source-id: a31217ec4f177383c62292d00fabc4cbe4391cfd
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants