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

Use the right logic to decide when we build Hermes from source #35469

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions scripts/cocoapods/__tests__/jsengine-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ class JSEngineTests < Test::Unit::TestCase
:react_native_path

def setup
File.enable_testing_mode!
@react_native_path = "../.."
podSpy_cleanUp()

end

def teardown
Expand All @@ -25,6 +27,8 @@ def teardown
Pod::UI.reset()
podSpy_cleanUp()
ENV['USE_HERMES'] = '1'
ENV['CI'] = nil
File.reset()
end

# =============== #
Expand Down Expand Up @@ -125,16 +129,26 @@ def test_setupHermes_installsPods_installsFabricSubspecWhenFabricEnabled
# TEST - isBuildingHermesFromSource #
# ================================= #
def test_isBuildingHermesFromSource_whenTarballIsNilAndVersionIsNotNightly_returnTrue
assert_true(is_building_hermes_from_source("1000.0.0"))
assert_true(is_building_hermes_from_source("1000.0.0", '../..'))
end

def test_isBuildingHermesFromSource_whenTarballIsNilAndInReleaseBranch_returnTrue
ENV['CI'] = 'true'
File.mocked_existing_files(['../../sdks/.hermesversion'])
assert_true(is_building_hermes_from_source("0.999.0", '../..'))
end

def test_isBuildingHermesFromSource_whenTarballIsNotNil_returnFalse
ENV['HERMES_ENGINE_TARBALL_PATH'] = "~/Downloads/hermes-ios-debug.tar.gz"
assert_false(is_building_hermes_from_source("1000.0.0"))
assert_false(is_building_hermes_from_source("1000.0.0", '../..'))
end

def test_isBuildingHermesFromSource_whenIsNigthly_returnsFalse
assert_false(is_building_hermes_from_source("0.0.0-"))
assert_false(is_building_hermes_from_source("0.0.0-", '../..'))
end

def test_isBuildingHermesFromSource_whenIsStbleRelease_returnsFalse
assert_false(is_building_hermes_from_source("0.71.0", '../..'))
end

end
19 changes: 12 additions & 7 deletions scripts/cocoapods/jsengine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ def remove_copy_hermes_framework_script_phase(installer, react_native_path)
project.save()
end

def is_building_hermes_from_source(react_native_version)
is_nightly = react_native_version.start_with?('0.0.0-')
has_tarball = ENV['HERMES_ENGINE_TARBALL_PATH'] != nil

# this is the same logic in the hermes-engine.podspec
if has_tarball || is_nightly
# TODO: Use this same function in the `hermes-engine.podspec` somehow
def is_building_hermes_from_source(react_native_version, react_native_path)
if ENV['HERMES_ENGINE_TARBALL_PATH'] != nil
return false
end

return true
isInMain = react_native_version.include?('1000.0.0')

hermestag_file = File.join(react_native_path, "sdks", ".hermesversion")
isInCI = ENV['CI'] === 'true'

isReleaseBranch = File.exist?(hermestag_file) && isInCI


return isInMain || isReleaseBranch
end
2 changes: 1 addition & 1 deletion scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def react_native_post_install(installer, react_native_path = "../node_modules/re
package = JSON.parse(File.read(File.join(react_native_path, "package.json")))
version = package['version']

if ReactNativePodsUtils.has_pod(installer, 'hermes-engine') && is_building_hermes_from_source(version)
if ReactNativePodsUtils.has_pod(installer, 'hermes-engine') && is_building_hermes_from_source(version, react_native_path)
add_copy_hermes_framework_script_phase(installer, react_native_path)
else
remove_copy_hermes_framework_script_phase(installer, react_native_path)
Expand Down