diff --git a/.github/actions/test-ios-helloworld/action.yml b/.github/actions/test-ios-helloworld/action.yml index 0a9a6939bba..39e6f3881f1 100644 --- a/.github/actions/test-ios-helloworld/action.yml +++ b/.github/actions/test-ios-helloworld/action.yml @@ -25,21 +25,16 @@ runs: uses: ./.github/actions/setup-node - name: Run yarn install uses: ./.github/actions/yarn-install - - name: Create Hermes folder - shell: bash - run: mkdir -p "$HERMES_WS_DIR" - - name: Download Hermes - uses: actions/download-artifact@v4 - with: - name: hermes-darwin-bin-${{ inputs.flavor }} - path: /tmp/hermes/hermes-runtime-darwin/ - - name: Print Downloaded hermes - shell: bash - run: ls -lR "$HERMES_WS_DIR" - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ inputs.ruby-version }} + - name: Set nightly Hermes versions + shell: bash + run: | + node ./scripts/releases/use-hermes-nightly.js + - name: Run yarn install again, with the correct hermes version + uses: ./.github/actions/yarn-install - name: Download ReactNativeDependencies uses: actions/download-artifact@v4 with: @@ -66,20 +61,6 @@ runs: args+=(--frameworks dynamic) fi - # Tarball is restored with capital flavors suffix, but somehow the tarball name from JS at line 96 returns as lowercased. - # Let's ensure that the tarballs have the right names - - if [[ -f "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Debug.tar.gz" ]]; then - mv "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Debug.tar.gz" "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-debug.tar.gz" - fi - - if [[ -f "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Release.tar.gz" ]]; then - mv "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Release.tar.gz" "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-release.tar.gz" - fi - - BUILD_TYPE="${{ inputs.flavor }}" - TARBALL_FILENAME=$(node ../../packages/react-native/scripts/hermes/get-tarball-name.js --buildType "$BUILD_TYPE") - export HERMES_ENGINE_TARBALL_PATH="$HERMES_WS_DIR/hermes-runtime-darwin/$TARBALL_FILENAME" export RCT_USE_LOCAL_RN_DEP="/tmp/third-party/ReactNativeDependencies${{ inputs.flavor }}.xcframework.tar.gz" export RCT_TESTONLY_RNCORE_TARBALL_PATH="/tmp/ReactCore/ReactCore${{ inputs.flavor }}.xcframework.tar.gz" diff --git a/.github/actions/test-ios-rntester/action.yml b/.github/actions/test-ios-rntester/action.yml index b54e4a36c6e..1465dac90b5 100644 --- a/.github/actions/test-ios-rntester/action.yml +++ b/.github/actions/test-ios-rntester/action.yml @@ -10,9 +10,6 @@ inputs: run-unit-tests: description: whether unit tests should run or not. default: "false" - hermes-tarball-artifacts-dir: - description: The directory where the hermes tarball artifacts are stored - default: /tmp/hermes/hermes-runtime-darwin flavor: description: The flavor of the build. Must be one of "Debug", "Release". default: Debug @@ -36,56 +33,19 @@ runs: uses: ./.github/actions/setup-node - name: Run yarn uses: ./.github/actions/yarn-install - - name: Download Hermes - uses: actions/download-artifact@v4 - with: - name: hermes-darwin-bin-${{ inputs.flavor }} - path: ${{ inputs.hermes-tarball-artifacts-dir }} - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ inputs.ruby-version }} + - name: Set nightly Hermes versions + shell: bash + run: | + node ./scripts/releases/use-hermes-nightly.js + - name: Run yarn install again, with the correct hermes version + uses: ./.github/actions/yarn-install - name: Prepare IOS Tests if: ${{ inputs.run-unit-tests == 'true' }} uses: ./.github/actions/prepare-ios-tests - - name: Set HERMES_ENGINE_TARBALL_PATH envvar if Hermes tarball is present - shell: bash - run: | - HERMES_TARBALL_ARTIFACTS_DIR=${{ inputs.hermes-tarball-artifacts-dir }} - if [ ! -d $HERMES_TARBALL_ARTIFACTS_DIR ]; then - echo "Hermes tarball artifacts dir not present ($HERMES_TARBALL_ARTIFACTS_DIR). Build Hermes from source." - exit 0 - fi - - TARBALL_FILENAME=$(node ./packages/react-native/scripts/hermes/get-tarball-name.js --buildType "${{ inputs.flavor }}") - TARBALL_PATH=$HERMES_TARBALL_ARTIFACTS_DIR/$TARBALL_FILENAME - - echo "Looking for $TARBALL_FILENAME in $HERMES_TARBALL_ARTIFACTS_DIR" - echo "$TARBALL_PATH" - - if [ ! -f $TARBALL_PATH ]; then - echo "Hermes tarball not present ($TARBALL_PATH). Build Hermes from source." - exit 0 - fi - - echo "Found Hermes tarball at $TARBALL_PATH" - echo "HERMES_ENGINE_TARBALL_PATH=$TARBALL_PATH" >> $GITHUB_ENV - - name: Print Hermes version - shell: bash - run: | - HERMES_TARBALL_ARTIFACTS_DIR=${{ inputs.hermes-tarball-artifacts-dir }} - TARBALL_FILENAME=$(node ./packages/react-native/scripts/hermes/get-tarball-name.js --buildType "${{ inputs.flavor }}") - TARBALL_PATH=$HERMES_TARBALL_ARTIFACTS_DIR/$TARBALL_FILENAME - if [[ -e $TARBALL_PATH ]]; then - tar -xf $TARBALL_PATH - echo 'print(HermesInternal?.getRuntimeProperties?.()["OSS Release Version"])' > test.js - chmod +x ./destroot/bin/hermes - ./destroot/bin/hermes test.js - rm test.js - rm -rf destroot - else - echo 'No Hermes tarball found.' - fi - name: Download ReactNativeDependencies uses: actions/download-artifact@v4 with: @@ -105,7 +65,6 @@ runs: - name: Install CocoaPods dependencies shell: bash run: | - export HERMES_ENGINE_TARBALL_PATH=$HERMES_ENGINE_TARBALL_PATH export RCT_USE_LOCAL_RN_DEP="/tmp/third-party/ReactNativeDependencies${{ inputs.flavor }}.xcframework.tar.gz" export RCT_TESTONLY_RNCORE_TARBALL_PATH="/tmp/ReactCore/ReactCore${{ inputs.flavor }}.xcframework.tar.gz" @@ -116,7 +75,7 @@ runs: cd packages/rn-tester bundle install - bundle exec pod install + bundle exec pod update hermes-engine --no-repo-update - name: Build RNTester shell: bash run: | diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 3abef2c1272..f4fe714006f 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -108,6 +108,8 @@ jobs: prebuild_react_native_core: uses: ./.github/workflows/prebuild-ios-core.yml + with: + use-hermes-nightly: true secrets: inherit needs: [prebuild_apple_dependencies, build_hermes_macos] diff --git a/.github/workflows/prebuild-ios-core.yml b/.github/workflows/prebuild-ios-core.yml index b2d05c5e88f..340cd7098d1 100644 --- a/.github/workflows/prebuild-ios-core.yml +++ b/.github/workflows/prebuild-ios-core.yml @@ -2,7 +2,12 @@ name: Prebuild iOS Dependencies on: workflow_call: # this directive allow us to call this workflow from other workflows - + inputs: + use-hermes-nightly: + description: 'Whether to use the hermes nightly build or read the version from the versions.properties file' + type: boolean + required: false + default: false jobs: build-rn-slice: @@ -36,35 +41,16 @@ jobs: - name: Yarn Install if: steps.restore-ios-slice.outputs.cache-hit != 'true' uses: ./.github/actions/yarn-install - - name: Download Hermes - if: steps.restore-ios-slice.outputs.cache-hit != 'true' - uses: actions/download-artifact@v4 - with: - name: hermes-darwin-bin-${{ matrix.flavor }} - path: /tmp/hermes/hermes-runtime-darwin - - name: Extract Hermes - if: steps.restore-ios-slice.outputs.cache-hit != 'true' + - name: Set Hermes version shell: bash run: | - HERMES_TARBALL_ARTIFACTS_DIR=/tmp/hermes/hermes-runtime-darwin - if [ ! -d $HERMES_TARBALL_ARTIFACTS_DIR ]; then - echo "Hermes tarball artifacts dir not present ($HERMES_TARBALL_ARTIFACTS_DIR)." - exit 0 + if [ "${{ inputs.use-hermes-nightly }}" == "true" ]; then + HERMES_VERSION="nightly" + else + HERMES_VERSION=$(sed -n 's/^HERMES_VERSION_NAME=//p' packages/react-native/sdks/hermes-engine/version.properties) fi - - TARBALL_FILENAME=$(node ./packages/react-native/scripts/hermes/get-tarball-name.js --buildType "${{ matrix.flavor }}") - TARBALL_PATH=$HERMES_TARBALL_ARTIFACTS_DIR/$TARBALL_FILENAME - - echo "Looking for $TARBALL_FILENAME in $HERMES_TARBALL_ARTIFACTS_DIR" - echo "$TARBALL_PATH" - - if [ ! -f $TARBALL_PATH ]; then - echo "Hermes tarball not present ($TARBALL_PATH). Build Hermes from source." - exit 0 - fi - - echo "Found Hermes tarball at $TARBALL_PATH" - echo "HERMES_ENGINE_TARBALL_PATH=$TARBALL_PATH" >> $GITHUB_ENV + echo "Using Hermes version: $HERMES_VERSION" + echo "HERMES_VERSION=$HERMES_VERSION" >> $GITHUB_ENV - name: Download ReactNativeDependencies uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml index cca5c3385b3..59265786c01 100644 --- a/.github/workflows/test-all.yml +++ b/.github/workflows/test-all.yml @@ -120,6 +120,8 @@ jobs: prebuild_react_native_core: uses: ./.github/workflows/prebuild-ios-core.yml + with: + use-hermes-nightly: ${{ !endsWith(github.ref_name, '-stable') }} secrets: inherit needs: [prebuild_apple_dependencies, build_hermes_macos] @@ -127,9 +129,6 @@ jobs: runs-on: macos-14 needs: [build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies, prebuild_react_native_core] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin steps: - name: Checkout uses: actions/checkout@v4 @@ -145,9 +144,6 @@ jobs: runs-on: macos-14-large needs: [build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies, prebuild_react_native_core] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin continue-on-error: true strategy: fail-fast: false @@ -169,9 +165,6 @@ jobs: runs-on: macos-14-large needs: [test_ios_rntester] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin strategy: fail-fast: false matrix: @@ -259,9 +252,6 @@ jobs: REACT_NATIVE_PKG=$(find /tmp/react-native-tmp -type f -name "*.tgz") echo "React Native tgs is $REACT_NATIVE_PKG" - HERMES_PATH=$(find /tmp/react-native-tmp -type f -name "*.tar.gz") - echo "Hermes path is $HERMES_PATH" - # For stable branches, we want to use the stable branch of the template # In all the other cases, we want to use "main" BRANCH=${{ github.ref_name }} @@ -278,7 +268,7 @@ jobs: export RCT_USE_LOCAL_RN_DEP=/tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz # Disable prebuilds for now, as they are causing issues with E2E tests for 0.82-stable branch # export RCT_TESTONLY_RNCORE_TARBALL_PATH="/tmp/ReactCore/ReactCore${{ matrix.flavor }}.xcframework.tar.gz" - HERMES_ENGINE_TARBALL_PATH=$HERMES_PATH RCT_NEW_ARCH_ENABLED=$NEW_ARCH_ENABLED bundle exec pod install + RCT_NEW_ARCH_ENABLED=$NEW_ARCH_ENABLED bundle exec pod install xcodebuild \ -scheme "RNTestProject" \ @@ -535,6 +525,12 @@ jobs: cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }} - name: Run yarn install uses: ./.github/actions/yarn-install + - name: Set nightly Hermes versions + shell: bash + run: | + node ./scripts/releases/use-hermes-nightly.js + - name: Run yarn install again, with the correct hermes version + uses: ./.github/actions/yarn-install - name: Prepare the Helloworld application shell: bash run: node ./scripts/e2e/init-project-e2e.js --useHelloWorld --pathToLocalReactNative "$GITHUB_WORKSPACE/build/$(cat build/react-native-package-version)" diff --git a/packages/react-native/scripts/ios-prebuild/hermes.js b/packages/react-native/scripts/ios-prebuild/hermes.js index 1adab0fc4a1..72c0c4c2073 100644 --- a/packages/react-native/scripts/ios-prebuild/hermes.js +++ b/packages/react-native/scripts/ios-prebuild/hermes.js @@ -29,7 +29,7 @@ import type {BuildFlavor, Destination, Platform} from './types'; * environment variable. If this varuable is set, the script will use the local tarball instead of downloading it. */ async function prepareHermesArtifactsAsync( - version /*:string*/, + reactNativeVersion /*:string*/, buildType /*: BuildFlavor */, ) /*: Promise */ { hermesLog(`Preparing Hermes...`); @@ -54,7 +54,7 @@ async function prepareHermesArtifactsAsync( // Only check if the artifacts folder exists if we are not using a local tarball if (!localPath) { // Resolve the version from the environment variable or use the default version - let resolvedVersion = process.env.HERMES_VERSION ?? version; + let resolvedVersion = process.env.HERMES_VERSION ?? 'nightly'; if (resolvedVersion === 'nightly') { hermesLog('Using latest nightly tarball'); @@ -104,7 +104,7 @@ async function prepareHermesArtifactsAsync( async function getNightlyVersionFromNPM() /*: Promise */ { const npmResponse /*: Response */ = await fetch( - 'https://registry.npmjs.org/react-native/nightly', + 'https://registry.npmjs.org/hermes-compiler/nightly', ); if (!npmResponse.ok) { @@ -191,15 +191,15 @@ function getTarballUrl( // The mirror's structure must be the same of the Maven repo the react-native core team publishes on Maven Central. const mavenRepoUrl = process.env.ENTERPRISE_REPOSITORY ?? 'https://repo1.maven.org/maven2'; - const namespace = 'com/facebook/react'; - return `${mavenRepoUrl}/${namespace}/react-native-artifacts/${version}/react-native-artifacts-${version}-hermes-ios-${buildType.toLowerCase()}.tar.gz`; + const namespace = 'com/facebook/hermes'; + return `${mavenRepoUrl}/${namespace}/hermes-ios/${version}/hermes-ios-${version}-hermes-ios-${buildType.toLowerCase()}.tar.gz`; } async function getNightlyTarballUrl( version /*: string */, buildType /*: BuildFlavor */, ) /*: Promise */ { - const artifactCoordinate = 'react-native-artifacts'; + const artifactCoordinate = 'hermes-ios'; const artifactName = `hermes-ios-${buildType.toLowerCase()}.tar.gz`; return await computeNightlyTarballURL( version, diff --git a/packages/react-native/scripts/ios-prebuild/utils.js b/packages/react-native/scripts/ios-prebuild/utils.js index d9dec121dd5..6e8c2c77644 100644 --- a/packages/react-native/scripts/ios-prebuild/utils.js +++ b/packages/react-native/scripts/ios-prebuild/utils.js @@ -65,7 +65,7 @@ async function computeNightlyTarballURL( artifactCoordinate /*: string */, artifactName /*: string */, ) /*: Promise */ { - const xmlUrl = `https://central.sonatype.com/repository/maven-snapshots/com/facebook/react/${artifactCoordinate}/${version}-SNAPSHOT/maven-metadata.xml`; + const xmlUrl = `https://central.sonatype.com/repository/maven-snapshots/com/facebook/hermes/${artifactCoordinate}/${version}-SNAPSHOT/maven-metadata.xml`; const response = await fetch(xmlUrl); if (!response.ok) { @@ -97,7 +97,7 @@ async function computeNightlyTarballURL( const buildNumber = buildNumberMatch[1]; const fullVersion = `${version}-${timestamp}-${buildNumber}`; - const finalUrl = `https://central.sonatype.com/repository/maven-snapshots/com/facebook/react/${artifactCoordinate}/${version}-SNAPSHOT/${artifactCoordinate}-${fullVersion}-${artifactName}`; + const finalUrl = `https://central.sonatype.com/repository/maven-snapshots/com/facebook/hermes/${artifactCoordinate}/${version}-SNAPSHOT/${artifactCoordinate}-${fullVersion}-${artifactName}`; return finalUrl; } diff --git a/private/helloworld/android/app/build.gradle b/private/helloworld/android/app/build.gradle index b7518d235d4..2b7bf819e0b 100644 --- a/private/helloworld/android/app/build.gradle +++ b/private/helloworld/android/app/build.gradle @@ -115,5 +115,5 @@ android { dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android") - implementation("com.facebook.react:hermes-android") + implementation("com.facebook.hermes:hermes-android") } diff --git a/scripts/releases/use-hermes-nightly.js b/scripts/releases/use-hermes-nightly.js new file mode 100644 index 00000000000..5dc782e93d1 --- /dev/null +++ b/scripts/releases/use-hermes-nightly.js @@ -0,0 +1,21 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +const {updateHermesVersionsToNightly} = require('./utils/hermes-utils'); + +async function main() { + await updateHermesVersionsToNightly(); +} + +if (require.main === module) { + void main(); +}