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

Resolve redirects instead of manually downloading nightly Hermes #38920

Closed
wants to merge 1 commit into from
Closed
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
27 changes: 8 additions & 19 deletions packages/react-native/sdks/hermes-engine/hermes-utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def compute_hermes_source(build_from_source, hermestag_file, git, version, react
download_stable_hermes(react_native_path, version, :debug)
download_stable_hermes(react_native_path, version, :release)
elsif hermes_artifact_exists(nightly_tarball_url(version).gsub("\\", ""))
use_nightly_tarball(source, react_native_path, version)
use_nightly_tarball(source, version)
else
build_hermes_from_source(source, git)
end
Expand Down Expand Up @@ -80,11 +80,9 @@ def release_tarball_url(version, build_type)
return "https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/#{version}/react-native-artifacts-#{version}-hermes-ios-#{build_type.to_s}.tar.gz"
end

def use_nightly_tarball(source, react_native_path, version)
def use_nightly_tarball(source, version)
putsIfPodPresent('[Hermes] Nightly version, download pre-built for Hermes')
destination_path = download_nightly_hermes(react_native_path, version)
# set tarball as hermes engine
source[:http] = "file://#{destination_path}"
source[:http] = nightly_tarball_url(version)
end

def putsIfPodPresent(message, level = 'warning')
Expand Down Expand Up @@ -121,22 +119,9 @@ def download_hermes_tarball(react_native_path, tarball_url, version, configurati
return destination_path
end

# This function downloads the nightly prebuilt version of Hermes based on the passed version
# and save it in the node_module/react_native/sdks/downloads folder
# It then returns the path to the hermes tarball
#
# Parameters
# - react_native_path: the path to the React Native folder in node modules. It is used as root path to store the Hermes tarball
# - version: the version of React Native that requires the Hermes tarball
# Returns: the path to the downloaded Hermes tarball
def download_nightly_hermes(react_native_path, version)
tarball_url = nightly_tarball_url(version)
return download_hermes_tarball(react_native_path, tarball_url, version, nil)
end

def nightly_tarball_url(version)
params = "r=snapshots\&g=com.facebook.react\&a=react-native-artifacts\&c=hermes-ios-debug\&e=tar.gz\&v=#{version}-SNAPSHOT"
return "http://oss.sonatype.org/service/local/artifact/maven/redirect\?#{params}"
return resolve_url_redirects("http://oss.sonatype.org/service/local/artifact/maven/redirect\?#{params}")
end

def build_hermes_from_source(source, git)
Expand All @@ -151,6 +136,10 @@ def build_hermes_from_commit(source, git, commit)
source[:commit] = commit
end

def resolve_url_redirects(url)
return (`curl -Ls -o /dev/null -w %{url_effective} \"#{url}\"`)
end

# This function checks that Hermes artifact exists.
# As of now it should check it on the Maven repo.
#
Expand Down