From 7e34a001a5da3efad5ebaf9bf3847ea373daaa20 Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Wed, 13 Aug 2025 10:57:52 +0200 Subject: [PATCH 1/3] Failing test --- .github/workflows/build-android.yml | 58 -- .../workflows/build-apple-slices-hermes.yml | 77 --- .github/workflows/build-emscripten.yml | 48 -- .github/workflows/build-hermes-macos.yml | 145 ---- .github/workflows/build-hermesc-apple.yml | 23 - .github/workflows/build-hermesc-linux.yml | 44 -- .github/workflows/build-hermesc-windows.yml | 71 -- .github/workflows/build.yml | 627 ++---------------- .github/workflows/create-tag.yml | 36 - .github/workflows/publish.yml | 95 --- .github/workflows/rn-build-hermes.yml | 78 --- .github/workflows/run-tests.yml | 219 ------ .github/workflows/test-apple-runtime.yml | 66 -- .../hermes/test/HermesIntlTest262.java | 3 +- lib/VM/JSArray.cpp | 17 +- 15 files changed, 60 insertions(+), 1547 deletions(-) delete mode 100644 .github/workflows/build-android.yml delete mode 100644 .github/workflows/build-apple-slices-hermes.yml delete mode 100644 .github/workflows/build-emscripten.yml delete mode 100644 .github/workflows/build-hermes-macos.yml delete mode 100644 .github/workflows/build-hermesc-apple.yml delete mode 100644 .github/workflows/build-hermesc-linux.yml delete mode 100644 .github/workflows/build-hermesc-windows.yml delete mode 100644 .github/workflows/create-tag.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/rn-build-hermes.yml delete mode 100644 .github/workflows/run-tests.yml delete mode 100644 .github/workflows/test-apple-runtime.yml diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml deleted file mode 100644 index cd612b2fa21..00000000000 --- a/.github/workflows/build-android.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: build-android - -on: - workflow_call: - inputs: - release-type: - required: true - description: The type of release we are building. It could be commitly, release or dry-run - type: string - -jobs: - build-android: - runs-on: 8-core-ubuntu - env: - HERMES_WS_DIR: /home/runner/work/hermes/hermes - container: - image: reactnativecommunity/react-native-android:latest - env: - TERM: "dumb" - GRADLE_OPTS: "-Dorg.gradle.daemon=false" - ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }} - ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }} - ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }} - ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build Hermes Compiler - run: |- - cmake -S . -B build - # Build the Hermes compiler so that the cross compiler build can - # access it to build the VM - cmake --build ./build --target hermesc -j 4 - - name: Setup node.js - uses: ./.github/actions/setup-node - - name: Install node dependencies - uses: ./.github/actions/yarn-install - - name: Set React Native Version - shell: bash - run: node ./utils/scripts/hermes/set-artifacts-version.js --build-type ${{ inputs.release-type }} - - name: Build android - shell: bash - run: | - cd android - - if [[ "${{ inputs.release-type }}" == "commitly" ]]; then - export ORG_GRADLE_PROJECT_isSnapshot="true" - TASKS=":publishAllToMavenTempLocal :publishToSonatype :build" - else - TASKS=":publishAllToMavenTempLocal :build" - fi - - ./gradlew $TASKS -PenableWarningsAsErrors=true - - name: Upload Maven Artifacts - uses: actions/upload-artifact@v4.3.4 - with: - name: maven-local - path: /tmp/maven-local diff --git a/.github/workflows/build-apple-slices-hermes.yml b/.github/workflows/build-apple-slices-hermes.yml deleted file mode 100644 index cdc08187c01..00000000000 --- a/.github/workflows/build-apple-slices-hermes.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: build-apple-slices-hermes - -on: - workflow_call - -jobs: - build_apple_slices_hermes: - runs-on: macos-14 - env: - IOS_DEPLOYMENT_TARGET: "15.1" - XROS_DEPLOYMENT_TARGET: "1.0" - MAC_DEPLOYMENT_TARGET: "10.15" - strategy: - fail-fast: false - matrix: - flavor: [Debug, Release] - slice: [macosx, iphoneos, iphonesimulator, appletvos, appletvsimulator, catalyst, xros, xrsimulator] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup xcode - uses: ./.github/actions/setup-xcode - - name: Restore HermesC Artifact - uses: actions/download-artifact@v4 - with: - name: hermesc-apple - path: ./build_host_hermesc - - name: Build the Hermes ${{ matrix.slice }} frameworks - shell: bash - run: | - SLICE=${{ matrix.slice }} - FLAVOR=${{ matrix.flavor }} - FINAL_PATH=build_"$SLICE"_"$FLAVOR" - echo "Final path for this slice is: $FINAL_PATH" - - # HermesC is used to build hermes, so it has to be executable - chmod +x ./build_host_hermesc/bin/hermesc - - if [[ "$SLICE" == "macosx" ]]; then - echo "[HERMES] Building Hermes for MacOS" - - chmod +x ./utils/build-mac-framework-rn.sh - BUILD_TYPE="${{ matrix.flavor }}" ./utils/build-mac-framework-rn.sh - else - echo "[HERMES] Building Hermes for iOS: $SLICE" - - chmod +x ./utils/build-ios-framework-rn.sh - BUILD_TYPE="${{ matrix.flavor }}" ./utils/build-ios-framework-rn.sh "$SLICE" - fi - - echo "Moving from build_$SLICE to $FINAL_PATH" - mv build_"$SLICE" "$FINAL_PATH" - - # check whether everything is there - if [[ -d "$FINAL_PATH/lib/hermesvm.framework" ]]; then - echo "Successfully built hermesvm.framework for $SLICE in $FLAVOR" - else - echo "Failed to built hermesvm.framework for $SLICE in $FLAVOR" - exit 1 - fi - - if [[ -d "$FINAL_PATH/lib/hermesvm.framework.dSYM" ]]; then - echo "Successfully built hermesvm.framework.dSYM for $SLICE in $FLAVOR" - else - echo "Failed to built hermesvm.framework.dSYM for $SLICE in $FLAVOR" - echo "Please try again" - exit 1 - fi - - name: Compress slices to preserve Symlinks - shell: bash - run: | - tar -czv -f build_${{ matrix.slice }}_${{ matrix.flavor }}.tar.gz build_${{ matrix.slice }}_${{ matrix.flavor }} - - name: Upload Artifact for Slice (${{ matrix.slice }}, ${{ matrix.flavor }}} - uses: actions/upload-artifact@v4.3.4 - with: - name: slice-${{ matrix.slice }}-${{ matrix.flavor }} - path: ./build_${{ matrix.slice }}_${{ matrix.flavor }}.tar.gz diff --git a/.github/workflows/build-emscripten.yml b/.github/workflows/build-emscripten.yml deleted file mode 100644 index ef6670ad48e..00000000000 --- a/.github/workflows/build-emscripten.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: build-emscripten - -on: - workflow_call - -jobs: - build-emscripten: - runs-on: ubuntu-22.04 - container: - image: emscripten/emsdk:3.1.17 - steps: - - name: Install dependencies - run: |- - apt update - apt install -y libicu-dev libreadline-dev - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Build Hermes Compiler - run: |- - cmake -S hermes -B build_host_hermesc - cmake --build ./build_host_hermesc --target hermesc -j 4 - - name: Build Hermes with Emscripten for Website Playground - run: |- - echo LINKER_FLAGS: $LINKER_FLAGS - cmake -S hermes -B playground \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_EXE_LINKER_FLAGS="$LINKER_FLAGS" \ - -DCMAKE_TOOLCHAIN_FILE="$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" \ - -DIMPORT_HOST_COMPILERS="$PWD/build_host_hermesc/ImportHostCompilers.cmake" - cmake --build ./playground --target hermes -j 4 - cmake --build ./playground --target hermesc -j 4 - cmake --build ./playground --target emhermesc -j 4 - EMHERMESC="$PWD/playground/bin/emhermesc.js" node ./hermes/tools/emhermesc/test.js - env: - LINKER_FLAGS: "-s WASM=1 -s ALLOW_MEMORY_GROWTH=0 -s TOTAL_MEMORY=33554432 -s MODULARIZE=1 -s EXPORT_NAME=createHermes -s INVOKE_RUN=0 -s EXIT_RUNTIME=1 -s NODERAWFS=0 -s EXTRA_EXPORTED_RUNTIME_METHODS=[callMain,FS] -s EXPORTED_FUNCTIONS=[_malloc,_free]" - - name: Create Playground tarball - run: |- - mkdir output staging - cp ./playground/bin/hermes.js ./playground/bin/hermes.wasm staging - tar -C staging -czvf output/${TAR_NAME} . - shasum -a 256 output/${TAR_NAME} > output/${TAR_NAME}.sha256 - env: - TAR_NAME: hermes-cli-emscripten.tar.gz - - uses: actions/upload-artifact@v4.3.1 - with: - name: emscripten-hermes - path: output diff --git a/.github/workflows/build-hermes-macos.yml b/.github/workflows/build-hermes-macos.yml deleted file mode 100644 index 13f676dbf88..00000000000 --- a/.github/workflows/build-hermes-macos.yml +++ /dev/null @@ -1,145 +0,0 @@ -name: build-hermes-macos - -on: - workflow_call - -jobs: - build-hermes-macos: - runs-on: macos-14 - continue-on-error: true - env: - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin - strategy: - fail-fast: false - matrix: - flavor: [Debug, Release] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup xcode - uses: ./.github/actions/setup-xcode - - name: Setup node.js - uses: ./.github/actions/setup-node - - name: Yarn Install Dependencies - uses: ./.github/actions/yarn-install - - name: Download slice artifacts - uses: actions/download-artifact@v4 - with: - pattern: slice-*-${{ matrix.flavor }} - path: . - merge-multiple: true - - name: Unzip slices - shell: bash - run: | - ls -l . - tar -xzv -f build_catalyst_${{ matrix.flavor }}.tar.gz - tar -xzv -f build_iphoneos_${{ matrix.flavor }}.tar.gz - tar -xzv -f build_iphonesimulator_${{ matrix.flavor }}.tar.gz - tar -xzv -f build_appletvos_${{ matrix.flavor }}.tar.gz - tar -xzv -f build_appletvsimulator_${{ matrix.flavor }}.tar.gz - tar -xzv -f build_macosx_${{ matrix.flavor }}.tar.gz - tar -xzv -f build_xros_${{ matrix.flavor }}.tar.gz - tar -xzv -f build_xrsimulator_${{ matrix.flavor }}.tar.gz - - name: Move back build folders - shell: bash - run: | - ls -l build_* - mv build_catalyst_${{ matrix.flavor }} build_catalyst - mv build_iphoneos_${{ matrix.flavor }} build_iphoneos - mv build_iphonesimulator_${{ matrix.flavor }} build_iphonesimulator - mv build_appletvos_${{ matrix.flavor }} build_appletvos - mv build_appletvsimulator_${{ matrix.flavor }} build_appletvsimulator - mv build_macosx_${{ matrix.flavor }} build_macosx - mv build_xros_${{ matrix.flavor }} build_xros - mv build_xrsimulator_${{ matrix.flavor }} build_xrsimulator - - name: Prepare destroot folder - shell: bash - run: | - chmod +x ./utils/build-apple-framework-rn.sh - source ./utils/build-apple-framework-rn.sh - prepare_dest_root_for_ci - - name: Create fat framework for iOS - shell: bash - run: | - echo "[HERMES] Creating the universal framework" - chmod +x ./utils/build-ios-framework-rn.sh - ./utils/build-ios-framework-rn.sh build_framework - - chmod +x ./destroot/bin/hermesc - - name: Package the Hermes Apple frameworks - shell: bash - run: | - BUILD_TYPE="${{ matrix.flavor }}" - echo "Packaging Hermes Apple frameworks for $BUILD_TYPE build type" - - TARBALL_OUTPUT_DIR=$(mktemp -d /tmp/hermes-tarball-output-XXXXXXXX) - - echo "Packaging Hermes Apple frameworks for $BUILD_TYPE build type" - - TARBALL_OUTPUT_PATH=$(node ./utils/scripts/hermes/create-tarball.js \ - --inputDir . \ - --buildType "$BUILD_TYPE" \ - --outputDir $TARBALL_OUTPUT_DIR) - - echo "Hermes tarball saved to $TARBALL_OUTPUT_PATH" - - mkdir -p $HERMES_TARBALL_ARTIFACTS_DIR - cp $TARBALL_OUTPUT_PATH $HERMES_TARBALL_ARTIFACTS_DIR/. - - mkdir -p /tmp/hermes/osx-bin/${{ matrix.flavor }} - cp ./build_macosx/bin/* /tmp/hermes/osx-bin/${{ matrix.flavor }} - ls -lR /tmp/hermes/osx-bin/ - - name: Create dSYM archive - shell: bash - run: | - FLAVOR=${{ matrix.flavor }} - WORKING_DIR="/tmp/hermes_tmp/dSYM/$FLAVOR" - - mkdir -p "$WORKING_DIR/macosx" - mkdir -p "$WORKING_DIR/catalyst" - mkdir -p "$WORKING_DIR/iphoneos" - mkdir -p "$WORKING_DIR/iphonesimulator" - mkdir -p "$WORKING_DIR/appletvos" - mkdir -p "$WORKING_DIR/appletvsimulator" - mkdir -p "$WORKING_DIR/xros" - mkdir -p "$WORKING_DIR/xrsimulator" - - DSYM_FILE_PATH=lib/hermesvm.framework.dSYM - cp -r build_macosx/$DSYM_FILE_PATH "$WORKING_DIR/macosx/" - cp -r build_catalyst/$DSYM_FILE_PATH "$WORKING_DIR/catalyst/" - cp -r build_iphoneos/$DSYM_FILE_PATH "$WORKING_DIR/iphoneos/" - cp -r build_iphonesimulator/$DSYM_FILE_PATH "$WORKING_DIR/iphonesimulator/" - cp -r build_appletvos/$DSYM_FILE_PATH "$WORKING_DIR/appletvos/" - cp -r build_appletvsimulator/$DSYM_FILE_PATH "$WORKING_DIR/appletvsimulator/" - cp -r build_xros/$DSYM_FILE_PATH "$WORKING_DIR/xros/" - cp -r build_xrsimulator/$DSYM_FILE_PATH "$WORKING_DIR/xrsimulator/" - - DEST_DIR="/tmp/hermes/dSYM/$FLAVOR" - tar -C "$WORKING_DIR" -czvf "hermesvm.framework.dSYM" . - - mkdir -p "$DEST_DIR" - mv "hermesvm.framework.dSYM" "$DEST_DIR" - - name: Upload hermes dSYM artifacts - uses: actions/upload-artifact@v4.3.4 - with: - name: hermes-dSYM-${{ matrix.flavor }} - path: /tmp/hermes/dSYM/${{ matrix.flavor }} - - name: Upload hermes Runtime artifacts - uses: actions/upload-artifact@v4.3.4 - with: - name: hermes-darwin-bin-${{ matrix.flavor }} - path: /tmp/hermes/hermes-runtime-darwin/hermes-ios-${{ matrix.flavor }}.tar.gz - - name: Upload hermes osx artifacts - uses: actions/upload-artifact@v4.3.4 - with: - name: hermes-osx-bin-${{ matrix.flavor }} - path: /tmp/hermes/osx-bin/${{ matrix.flavor }} - - name: Upload Hermes Artifacts - uses: actions/cache/save@v4 - if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} # To avoid that the cache explode. - with: - key: v4-hermes-artifacts-${{ matrix.flavor }}-${{ matrix.hermes-version }}-${{ matrix.react-native-version }}-${{ hashFiles('./packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }} - path: | - /tmp/hermes/osx-bin/${{ matrix.flavor }} - /tmp/hermes/dSYM/${{ matrix.flavor }} - /tmp/hermes/hermes-runtime-darwin/hermes-ios-${{ matrix.flavor }}.tar.gz diff --git a/.github/workflows/build-hermesc-apple.yml b/.github/workflows/build-hermesc-apple.yml deleted file mode 100644 index 030f9eae22c..00000000000 --- a/.github/workflows/build-hermesc-apple.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: build-hermesc-apple - -on: - workflow_call - -jobs: - build-hermesc-apple: - runs-on: macos-14 - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup xcode - uses: ./.github/actions/setup-xcode - - name: Build HermesC Apple - shell: bash - run: | - source ./utils/build-apple-framework-rn.sh - build_host_hermesc_if_needed - - name: Upload HermesC Artifact - uses: actions/upload-artifact@v4.3.4 - with: - name: hermesc-apple - path: ./build_host_hermesc diff --git a/.github/workflows/build-hermesc-linux.yml b/.github/workflows/build-hermesc-linux.yml deleted file mode 100644 index 697faa61cfc..00000000000 --- a/.github/workflows/build-hermesc-linux.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: build-hermesc-linux - -on: - workflow_call - -jobs: - build-hermesc-linux: - runs-on: ubuntu-latest - env: - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Install dependencies - shell: bash - run: | - sudo apt update - sudo apt install -y git openssh-client build-essential \ - libreadline-dev libicu-dev jq zip python3 - - sudo mkdir -p /usr/local/cmake - sudo wget -qO- https://github.com/Kitware/CMake/releases/download/v3.31.6/cmake-3.31.6-linux-x86_64.tar.gz \ - | sudo tar --strip-components=1 -xz -C /usr/local/cmake - sudo cp /usr/local/cmake/bin/* /usr/local/bin/ - export PATH=/usr/local/bin:$PATH - cmake --version - - - name: Set up workspace - shell: bash - run: | - mkdir -p /tmp/hermes/linux64-bin - - name: Build HermesC for Linux - shell: bash - run: | - cmake -S . -B build -DHERMES_STATIC_LINK=ON -DCMAKE_BUILD_TYPE=Release -DHERMES_ENABLE_TEST_SUITE=OFF \ - -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DCMAKE_CXX_FLAGS=-s -DCMAKE_C_FLAGS=-s \ - -DCMAKE_EXE_LINKER_FLAGS="-Wl,--whole-archive -lpthread -Wl,--no-whole-archive" - cmake --build build --target hermesc -j 4 - cp build/bin/hermesc /tmp/hermes/linux64-bin/. - - name: Upload linux artifacts - uses: actions/upload-artifact@v4.3.4 - with: - name: hermes-linux-bin - path: /tmp/hermes/linux64-bin diff --git a/.github/workflows/build-hermesc-windows.yml b/.github/workflows/build-hermesc-windows.yml deleted file mode 100644 index 12355df95a0..00000000000 --- a/.github/workflows/build-hermesc-windows.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: build-hermesc-windows - -on: - workflow_call - -jobs: - build-hermesc-windows: - runs-on: windows-2025 - env: - HERMES_WS_DIR: 'C:\tmp\hermes' - HERMES_TARBALL_ARTIFACTS_DIR: 'C:\tmp\hermes\hermes-runtime-darwin' - HERMES_OSXBIN_ARTIFACTS_DIR: 'C:\tmp\hermes\osx-bin' - ICU_URL: "https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-Win64-MSVC2017.zip" - MSBUILD_DIR: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin' - CMAKE_DIR: 'C:\Program Files\CMake\bin' - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up workspace - shell: powershell - run: | - mkdir -p C:\tmp\hermes\osx-bin - - name: setup-msbuild - uses: microsoft/setup-msbuild@v1.3.2 - - name: Set up workspace - shell: powershell - run: | - New-Item -ItemType Directory -ErrorAction SilentlyContinue $Env:HERMES_WS_DIR\icu - New-Item -ItemType Directory -ErrorAction SilentlyContinue $Env:HERMES_WS_DIR\deps - New-Item -ItemType Directory -ErrorAction SilentlyContinue $Env:HERMES_WS_DIR\win64-bin - - name: Downgrade CMake - shell: powershell - run: choco install cmake --version 3.31.6 --force - - name: Build HermesC for Windows - shell: powershell - run: | - cd $Env:HERMES_WS_DIR\icu - # If Invoke-WebRequest shows a progress bar, it will fail with - # Win32 internal error "Access is denied" 0x5 occurred [...] - $progressPreference = 'silentlyContinue' - Invoke-WebRequest -Uri "$Env:ICU_URL" -OutFile "icu.zip" - Expand-Archive -Path "icu.zip" -DestinationPath "." - - cd $Env:HERMES_WS_DIR - Copy-Item -Path "icu\bin64\icu*.dll" -Destination "deps" - # Include MSVC++ 2015 redistributables - Copy-Item -Path "c:\windows\system32\msvcp140.dll" -Destination "deps" - Copy-Item -Path "c:\windows\system32\vcruntime140.dll" -Destination "deps" - Copy-Item -Path "c:\windows\system32\vcruntime140_1.dll" -Destination "deps" - - $Env:PATH += ";$Env:CMAKE_DIR;$Env:MSBUILD_DIR" - $Env:ICU_ROOT = "$Env:HERMES_WS_DIR\icu" - - cd $Env:GITHUB_WORKSPACE - cmake -S . -B build_release -G 'Visual Studio 17 2022' -Ax64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DHERMES_ENABLE_WIN10_ICU_FALLBACK=OFF - if (-not $?) { throw "Failed to configure Hermes" } - echo "Running windows build..." - cd build_release - cmake --build . --target hermesc --config Release - if (-not $?) { throw "Failed to build Hermes" } - - echo "Copying hermesc.exe to win64-bin" - cd $Env:GITHUB_WORKSPACE - Copy-Item -Path "build_release\bin\Release\hermesc.exe" -Destination "$Env:HERMES_WS_DIR\win64-bin" - # Include Windows runtime dependencies - Copy-Item -Path "$Env:HERMES_WS_DIR\deps\*" -Destination "$Env:HERMES_WS_DIR\win64-bin" - - name: Upload windows artifacts - uses: actions/upload-artifact@v4.3.4 - with: - name: hermes-win64-bin - path: C:\tmp\hermes\win64-bin\ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7aab3c1f31d..43f4a7ae0cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,549 +5,18 @@ on: branches: - main jobs: - android: - runs-on: ubuntu-22.04 - env: - HERMES_WS_DIR: ${{ github.workspace }} - steps: - - name: Set up workspace and install dependencies - run: |- - yes | sdkmanager "cmake;3.22.1" & - sudo apt update && sudo apt install -y libicu-dev - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Build Hermes Compiler - run: |- - cmake -S hermes -B build - # Build the Hermes compiler so that the cross compiler build can - # access it to build the VM - cmake --build ./build --target hermesc -j 4 - - name: Build Hermes for Android - run: |- - cd hermes/android - ./gradlew githubRelease - - name: Copy artifacts - run: |- - mkdir output - cp build_android/distributions/hermes-runtime-android-*.tar.gz output - - name: Checksum artifacts - run: |- - cd output - for file in * - do - sha256sum "$file" > "$file.sha256" - done - - uses: actions/upload-artifact@v4.3.1 - with: - name: android-hermes - path: output - linux: - runs-on: ubuntu-22.04 - steps: - - name: Install dependencies - run: |- - sudo apt update - sudo apt install -y git openssh-client cmake build-essential \ - libreadline-dev libicu-dev zip python3 - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Build linux CLI - run: |- - cmake -S hermes -B build_hdb -DHERMES_STATIC_LINK=ON -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_CXX_FLAGS=-s -DCMAKE_C_FLAGS=-s \ - -DCMAKE_EXE_LINKER_FLAGS="-Wl,--whole-archive -lpthread -Wl,--no-whole-archive" - cmake -S hermes -B build -DHERMES_STATIC_LINK=ON -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_CXX_FLAGS=-s -DCMAKE_C_FLAGS=-s \ - -DCMAKE_EXE_LINKER_FLAGS="-Wl,--whole-archive -lpthread -Wl,--no-whole-archive" \ - -DHERMES_ENABLE_DEBUGGER=False - cmake --build build_hdb --target hdb - cmake --build build --target check-hermes hermes hvm hbcdump hermesc - - name: Create CLI tarball - run: |- - mkdir output staging - cp build/bin/hermes build/bin/hvm build/bin/hbcdump \ - build/bin/hermesc build_hdb/bin/hdb staging - tar -C staging -czvf output/${TAR_NAME} . - shasum -a 256 output/${TAR_NAME} > output/${TAR_NAME}.sha256 - env: - TAR_NAME: hermes-cli-linux.tar.gz - - uses: actions/upload-artifact@v4.3.1 - with: - name: linux-hermes - path: output - macos: - runs-on: macos-14 - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: 16.2 - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Install dependencies - run: brew install cmake ninja - - name: Build macOS CLI - run: |- - cmake -S hermes -B build -G Ninja ${RELEASE_FLAGS} -DHERMES_ENABLE_DEBUGGER=False - cmake --build ./build --target hermes hvm hbcdump hermesc check-hermes - cmake -S hermes -B build_hdb -G Ninja ${RELEASE_FLAGS} - cmake --build ./build_hdb --target hdb check-hermes - env: - RELEASE_FLAGS: "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DCMAKE_OSX_ARCHITECTURES=x86_64;arm64 \\ -DBUILD_SHARED_LIBS=OFF -DHERMES_BUILD_SHARED_JSI=OFF" - - name: Create CLI tarball - run: |- - mkdir output staging - cp build/bin/hermes build/bin/hvm build/bin/hbcdump \ - build/bin/hermesc build_hdb/bin/hdb staging - tar -C staging -czvf output/${TAR_NAME} . - shasum -a 256 output/${TAR_NAME} > output/${TAR_NAME}.sha256 - env: - TAR_NAME: hermes-cli-darwin.tar.gz - - uses: actions/upload-artifact@v4.3.1 - with: - name: macos-hermes - path: output - build-apple-runtime: - runs-on: macos-14 - env: - TERM: dumb - HERMES_WS_DIR: "/tmp/hermes" - HOMEBREW_NO_AUTO_UPDATE: 1 - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: 16.2 - - uses: actions/checkout@v4.1.0 - - name: Cache setup - uses: actions/cache@v4 - with: - key: v4-repo-${{ github.sha }} - path: |- - build_iphoneos - build_catalyst - build_iphonesimulator - build_macosx - destroot - - name: Set up workspace - run: mkdir -p /tmp/hermes/output - - name: Install dependencies - run: |- - brew install cmake ninja - sudo gem install cocoapods - - name: Build the iOS frameworks - run: "./utils/build-ios-framework.sh" - - name: Build the Mac frameworks - run: "./utils/build-mac-framework.sh" - test-macos: - runs-on: macos-14 - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: 16.2 - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Install dependencies - run: brew install cmake - - name: Run MacOS regression tests in debug mode - run: |- - cmake -S hermes -B build -GXcode - cmake --build ./build - cmake --build ./build --target check-hermes - test-apple-runtime: - runs-on: macos-14 - needs: build-apple-runtime - env: - TERM: dumb - HERMES_WS_DIR: "/tmp/hermes" - HOMEBREW_NO_AUTO_UPDATE: 1 - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: 16.2 - - uses: actions/checkout@v4.1.0 - - name: Cache setup - uses: actions/cache@v4 - with: - key: v4-repo-${{ github.sha }} - path: |- - build_iphoneos - build_catalyst - build_iphonesimulator - build_macosx - destroot - - name: Install dependencies - run: brew install cmake ninja && xcodebuild -downloadPlatform visionOS && xcodebuild -downloadPlatform tvOS - - name: Build the test application - run: pod install - working-directory: test/ApplePlatformsIntegrationTestApp - - name: Test MacOS application - run: |- - xcodebuild test \ - -workspace ApplePlatformsIntegrationTests.xcworkspace \ - -configuration Debug \ - -destination 'platform=macOS' \ - -scheme ApplePlatformsIntegrationMacTests - working-directory: test/ApplePlatformsIntegrationTestApp - - name: Test iPhone application - run: |- - # macos-14 installs simulators for iPhone 15/16 - # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md - xcodebuild test \ - -workspace ApplePlatformsIntegrationTests.xcworkspace \ - -configuration Debug \ - -destination 'platform=iOS Simulator,name=iPhone 16' \ - -scheme ApplePlatformsIntegrationMobileTests - working-directory: test/ApplePlatformsIntegrationTestApp - - name: Test Apple Vision application - run: |- - xcodebuild test \ - -workspace ApplePlatformsIntegrationTests.xcworkspace \ - -configuration Debug \ - -destination 'platform=visionOS Simulator,name=Apple Vision Pro' \ - -scheme ApplePlatformsIntegrationVisionOSTests - working-directory: test/ApplePlatformsIntegrationTestApp - - name: Test Apple TV application - run: |- - xcodebuild test \ - -workspace ApplePlatformsIntegrationTests.xcworkspace \ - -configuration Debug \ - -destination 'platform=tvOS Simulator,name=Apple TV' \ - -scheme ApplePlatformsIntegrationTVOSTests - working-directory: test/ApplePlatformsIntegrationTestApp - package-apple-runtime: - runs-on: macos-14 - needs: - - test-macos - - test-apple-runtime - env: - TERM: dumb - HERMES_WS_DIR: "/tmp/hermes" - HOMEBREW_NO_AUTO_UPDATE: 1 - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: 16.2 - - uses: actions/checkout@v4.1.0 - - name: Cache setup - uses: actions/cache@v4 - with: - key: v4-repo-${{ github.sha }} - path: |- - build_iphoneos - build_catalyst - build_iphonesimulator - build_macosx - destroot - - name: Set up workspace - run: mkdir -p /tmp/hermes/output - - name: Install dependencies - run: |- - brew install cmake ninja - sudo gem install cocoapods - - name: Package the framework - run: |- - . ./utils/build-apple-framework.sh - mkdir -p /tmp/cocoapods-package-root/destroot - cp -R ./destroot /tmp/cocoapods-package-root - cp hermes-engine.podspec LICENSE /tmp/cocoapods-package-root - tar -C /tmp/cocoapods-package-root/ -czvf /tmp/hermes/output/hermes-runtime-darwin-v$(get_release_version).tar.gz . - - name: Checksum artifacts - run: |- - cd /tmp/hermes/output - for file in * - do - shasum -a 256 "$file" > "$file.sha256" - done - - uses: actions/upload-artifact@v4.3.1 - with: - name: apple-runtime - path: /tmp/hermes/output/ - windows: - runs-on: windows-2025 - env: - HERMES_WS_DIR: C:\tmp\hermes - ICU_URL: https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-Win64-MSVC2017.zip - MSBUILD_DIR: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin - CMAKE_DIR: C:\Program Files\CMake\bin - RELEASE_FLAGS: "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DHERMES_ENABLE_WIN10_ICU_FALLBACK=OFF" - TAR_NAME: hermes-cli-windows.tar.gz - steps: - - uses: actions/checkout@v4.1.0 - - name: Set up workspace - run: |- - New-Item -ItemType Directory $Env:HERMES_WS_DIR - New-Item -ItemType Directory $Env:HERMES_WS_DIR\icu - New-Item -ItemType Directory $Env:HERMES_WS_DIR\staging - New-Item -ItemType Directory $Env:HERMES_WS_DIR\output - New-Item -ItemType SymbolicLink -Target $Env:GITHUB_WORKSPACE -Path $Env:HERMES_WS_DIR -Name hermes - - name: Download ICU - run: |- - cd $Env:HERMES_WS_DIR\icu - # If Invoke-WebRequest shows a progress bar, it will fail with - # Win32 internal error "Access is denied" 0x5 occurred [...] - $progressPreference = 'silentlyContinue' - Invoke-WebRequest -Uri "$Env:ICU_URL" -OutFile "icu.zip" - Expand-Archive -Path "icu.zip" -DestinationPath "." - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2.0.0 - with: - cmake-version: 3.21.7 - - name: Setup python - uses: actions/setup-python@v5.0.0 - with: - python-version: 3.12.1 - - name: Assemble Windows runtime dependencies - run: |- - cd $Env:HERMES_WS_DIR - Copy-Item -Path "icu\bin64\icu*.dll" -Destination "staging" - # Include MSVC++ 2015 redistributables - Copy-Item -Path "c:\windows\system32\msvcp140.dll" -Destination "staging" - Copy-Item -Path "c:\windows\system32\vcruntime140.dll" -Destination "staging" - Copy-Item -Path "c:\windows\system32\vcruntime140_1.dll" -Destination "staging" - - name: Build Windows CLI - run: |- - $Env:PATH += ";$Env:MSBUILD_DIR" - $Env:ICU_ROOT = "$Env:HERMES_WS_DIR\icu" - cd $Env:HERMES_WS_DIR - cmake -S hermes -B build -G 'Visual Studio 17 2022' -Ax64 -DHERMES_ENABLE_DEBUGGER=False $Env:RELEASE_FLAGS - if (-not $?) { throw "Failed to configure Hermes" } - cmake -S hermes -B build_hdb -G 'Visual Studio 17 2022' -Ax64 $Env:RELEASE_FLAGS - if (-not $?) { throw "Failed to configure Hermes" } - cmake --build ./build --config Release -- -m /p:UseMultiToolTask=true -m /p:EnforceProcessCountAcrossBuilds=true - if (-not $?) { throw "Failed to build Hermes" } - cmake --build ./build_hdb --config Release --target hdb -- -m /p:UseMultiToolTask=true -m /p:EnforceProcessCountAcrossBuilds=true - if (-not $?) { throw "Failed to build Hermes" } - - name: Create CLI tarball - run: |- - cd $Env:HERMES_WS_DIR - Copy-Item -Path "build\bin\Release\hermes.exe" -Destination "staging" - Copy-Item -Path "build\bin\Release\hvm.exe" -Destination "staging" - Copy-Item -Path "build\bin\Release\hbcdump.exe" -Destination "staging" - Copy-Item -Path "build\bin\Release\hermesc.exe" -Destination "staging" - Copy-Item -Path "build_hdb\bin\Release\hdb.exe" -Destination "staging" - cd staging - cmake -E tar zcf ..\output\$Env:TAR_NAME . - - name: Checksum artifacts - run: |- - cd $Env:HERMES_WS_DIR\output - $hash = Get-FileHash -Path $Env:TAR_NAME -Algorithm SHA256 - Write-Output ($hash.Hash + " " + $Env:TAR_NAME) | - Out-File -Encoding ASCII -FilePath ($Env:TAR_NAME +".sha256") - - uses: actions/upload-artifact@v4.3.1 - with: - name: windows-hermes - path: c:\tmp\hermes\output - npm: - runs-on: ubuntu-22.04 - needs: - - android - - linux - - package-apple-runtime - - windows - - macos - env: - YARN: yarnpkg - TERM: dumb - DEBIAN_FRONTEND: noninteractive - steps: - - uses: actions/setup-node@v4.0.2 - - name: Print versions - run: |- - node --version - yarn --version - - name: Install dependencies and set up - run: mkdir -p /tmp/hermes/output - - uses: actions/checkout@v4.1.0 - - uses: actions/download-artifact@v4.1.3 - - name: Build NPM - run: |- - ls -lR - cd npm - cp ../macos-hermes/* . - cp ../windows-hermes/* . - cp ../android-hermes/* . - cp ../apple-runtime/* . - cp ../emscripten-hermes/* . - cp ../linux-hermes/* . - yarn install - yarn unpack-builds - yarn create-npms - - name: Copy artifacts - run: |- - cd npm - cp *.tgz /tmp/hermes/output - - name: Checksum artifacts - run: |- - cd /tmp/hermes/output - for file in * - do - sha256sum "$file" > "$file.sha256" - done - - uses: actions/upload-artifact@v4.3.1 - with: - name: npm-hermes - path: /tmp/hermes/output - emscripten: - runs-on: ubuntu-22.04 - container: - image: emscripten/emsdk:3.1.17 - steps: - - name: Install dependencies - run: |- - apt update - apt install -y libicu-dev libreadline-dev - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Build Hermes Compiler - run: |- - cmake -S hermes -B build_host_hermesc - cmake --build ./build_host_hermesc --target hermesc -j 4 - - name: Build Hermes with Emscripten for Website Playground - run: |- - echo LINKER_FLAGS: $LINKER_FLAGS - cmake -S hermes -B playground \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_EXE_LINKER_FLAGS="$LINKER_FLAGS" \ - -DCMAKE_TOOLCHAIN_FILE="$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" \ - -DIMPORT_HOST_COMPILERS="$PWD/build_host_hermesc/ImportHostCompilers.cmake" - cmake --build ./playground --target hermes -j 4 - cmake --build ./playground --target hermesc -j 4 - cmake --build ./playground --target emhermesc -j 4 - EMHERMESC="$PWD/playground/bin/emhermesc.js" node ./hermes/tools/emhermesc/test.js - env: - LINKER_FLAGS: "-s WASM=1 -s ALLOW_MEMORY_GROWTH=0 -s TOTAL_MEMORY=33554432 -s MODULARIZE=1 -s EXPORT_NAME=createHermes -s INVOKE_RUN=0 -s EXIT_RUNTIME=1 -s NODERAWFS=0 -s EXTRA_EXPORTED_RUNTIME_METHODS=[callMain,FS] -s EXPORTED_FUNCTIONS=[_malloc,_free]" - - name: Create Playground tarball - run: |- - mkdir output staging - cp ./playground/bin/hermes.js ./playground/bin/hermes.wasm staging - tar -C staging -czvf output/${TAR_NAME} . - shasum -a 256 output/${TAR_NAME} > output/${TAR_NAME}.sha256 - env: - TAR_NAME: hermes-cli-emscripten.tar.gz - - uses: actions/upload-artifact@v4.3.1 - with: - name: emscripten-hermes - path: output - sandbox: - runs-on: ubuntu-22.04 - container: - image: emscripten/emsdk:3.1.39 - env: - DEBIAN_FRONTEND: noninteractive - steps: - - name: Install dependencies - run: |- - apt update - apt install -y libicu-dev tzdata - wget https://github.com/WebAssembly/wabt/releases/download/1.0.33/wabt-1.0.33-ubuntu.tar.gz - tar -xvf ./wabt-1.0.33-ubuntu.tar.gz - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Build Hermes with Emscripten - run: |- - # Generate the host compiler. - cmake -S hermes -B build_host - cmake --build ./build_host --target hermesc -j 4 - # Generate and build the debug artefact. - cmake -S hermes -B build_wasm_dbg \ - -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ - -DIMPORT_HOST_COMPILERS=build_host/ImportHostCompilers.cmake \ - -DCMAKE_BUILD_TYPE=Debug -DHERMES_UNICODE_LITE=ON \ - -DCMAKE_CXX_FLAGS=-O2 -DCMAKE_C_FLAGS=-O2 \ - -DCMAKE_EXE_LINKER_FLAGS="-sALLOW_MEMORY_GROWTH=1 -sSTACK_SIZE=256KB" \ - -DHERMES_ENABLE_DEBUGGER=OFF -DHERMES_SLOW_DEBUG=OFF - cmake --build build_wasm_dbg --target hermesSandboxImpl -j 4 - ./wabt-1.0.33/bin/wasm2c build_wasm_dbg/API/hermes_sandbox/hermesSandboxImpl.wasm -n hermes \ - -o hermes/API/hermes_sandbox/external/hermes_sandbox_impl_dbg_compiled.c --num-outputs 8 - # Generate and build the release artefact. - cmake -S hermes -B build_wasm_opt \ - -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ - -DIMPORT_HOST_COMPILERS=build_host/ImportHostCompilers.cmake \ - -DCMAKE_BUILD_TYPE=Release -DHERMES_UNICODE_LITE=ON \ - -DCMAKE_EXE_LINKER_FLAGS="-sALLOW_MEMORY_GROWTH=1 -sSTACK_SIZE=256KB -g2" \ - -DHERMES_ENABLE_DEBUGGER=OFF - cmake --build build_wasm_opt --target hermesSandboxImpl -j 4 - ./wabt-1.0.33/bin/wasm2c build_wasm_opt/API/hermes_sandbox/hermesSandboxImpl.wasm -n hermes \ - -o hermes/API/hermes_sandbox/external/hermes_sandbox_impl_opt_compiled.c --num-outputs 8 - - name: Build and test with the newly generated sandbox - run: |- - cmake -S hermes -B build_dbg -DCMAKE_BUILD_TYPE=Debug - cmake --build build_dbg -j 4 - cmake --build build_dbg --target check-hermes -j 4 - cmake -S hermes -B build_opt -DCMAKE_BUILD_TYPE=Release - cmake --build build_opt -j 4 - cmake --build build_opt --target check-hermes -j 4 - test-linux: - runs-on: ubuntu-22.04 - steps: - - name: Install dependencies - run: |- - sudo apt update - sudo apt install -y git openssh-client cmake build-essential \ - libicu-dev zip python3 - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Run Hermes regression tests - run: |- - cmake -S hermes -B build - cmake --build build --target check-hermes all -j 4 - test-windows: - runs-on: windows-2025 - steps: - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Run Hermes regression tests - run: |- - cmake -S hermes -B build -G 'Visual Studio 17 2022' - cmake --build build --target check-hermes -- -m /p:UseMultiToolTask=true -m /p:EnforceProcessCountAcrossBuilds=true - test-e2e: - runs-on: ubuntu-22.04 - env: - ANDROID_NDK: /usr/local/lib/android/sdk/ndk/27.1.12297006 - HERMES_WS_DIR: /home/runner/work/hermes - REACT_NATIVE_OVERRIDE_HERMES_DIR: /home/runner/work/hermes/hermes - steps: - - name: Install Node - uses: actions/setup-node@v4.0.2 - with: - node-version: 24 - - name: Install JDK - uses: actions/setup-java@v3 - with: - distribution: "temurin" - java-version: "17" - - name: Checkout Hermes - uses: actions/checkout@v4.1.0 - - name: Checkout React Native - run: |- - cd "$HERMES_WS_DIR" - git clone --depth=1 https://github.com/facebook/react-native - cd react-native - yarn install - echo "console.log('Using Hermes: ' + (global.HermesInternal != null));" >> packages/rn-tester/js/RNTesterApp.android.js - - name: Run RNTester - uses: ReactiveCircus/android-emulator-runner@v2.30.1 - with: - api-level: 29 - ndk: 27.1.12297006 - cmake: 3.22.1 - script: | - cd ../react-native && ./gradlew -PreactNativeArchitectures=x86 :packages:rn-tester:android:app:installRelease - adb shell am start com.facebook.react.uiapp/.RNTesterActivity - timeout 30s adb logcat -e "Using Hermes: true" -m 1 test-e2e-intl: runs-on: ubuntu-22.04 + timeout-minutes: 25 env: HERMES_WS_DIR: /home/runner/work/hermes ANDROID_NDK: /usr/local/lib/android/sdk/ndk/27.1.12297006 steps: + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'oracle' - name: Checkout Hermes uses: actions/checkout@v4.1.0 - name: Checkout Test262 @@ -556,6 +25,32 @@ jobs: git clone https://github.com/tc39/test262 cd test262 git checkout 62626e083bd506124aac6c799464d76c2c42851b + - name: Overwrite failing test + run: | + cat < ../test262/test/intl402/Intl/getCanonicalLocales/returned-object-is-mutable.js + var locales = ['en-US', 'fr']; + var result = Intl.getCanonicalLocales(locales); + + result["length"] = Math.pow(2, 31) + 15; + EOF + - name: Remove first throw + run: | + node -e " + function replaceLast(str, search, replacement) { + const lastIndex = str.lastIndexOf(search); + if (lastIndex === -1) return str; + + return ( + str.substring(0, lastIndex) + + replacement + + str.substring(lastIndex + search.length) + ); + } + const fs = require('fs'); + const path = '../test262/harness/propertyHelper.js'; + const file = fs.readFileSync(path, { encoding: 'utf-8' }); + fs.writeFileSync(path, replaceLast(file, 'throw new Test262Error(\"Expected TypeError, got \" + e);', '')); + " - name: Build Hermes Compiler run: |- cd "$HERMES_WS_DIR" @@ -566,49 +61,15 @@ jobs: with: api-level: 29 emulator-options: -timezone Europe/Paris -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - script: cd android && ./gradlew :intltest:prepareTests && ./gradlew -Pabis=x86 :intltest:connectedAndroidTest - test-macos-test262: - runs-on: macos-14 - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: 16.2 - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Setup dependencies - run: |- - brew install cmake ninja - # Check out test262 at a pinned revision to reduce flakiness - git clone https://github.com/tc39/test262 - cd test262 - git checkout 62626e083bd506124aac6c799464d76c2c42851b - - name: Run Hermes tests and test262 with Intl - run: |- - cmake -S hermes -B build -GNinja -DHERMES_ENABLE_INTL=ON - cmake --build ./build - cmake --build ./build --target check-hermes - python3 hermes/utils/testsuite/run_testsuite.py --test-intl test262/test -b build/bin - test-linux-test262: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Setup dependencies - run: |- - sudo apt update - sudo apt install -y git openssh-client cmake build-essential \ - libreadline-dev libicu-dev zip python3 - # Check out test262 at a pinned revision to reduce flakiness - git clone https://github.com/tc39/test262 - cd test262 - git checkout 62626e083bd506124aac6c799464d76c2c42851b - - name: Run test262 with Intl - run: |- - cmake -S hermes -B build -DHERMES_ENABLE_INTL=ON -DCMAKE_CXX_FLAGS=-O2 -DCMAKE_C_FLAGS=-O2 - cmake --build ./build -j 4 - # Not running Hermes test until more of Intl is built out: - # toLocaleLowerCase and toLocaleUpperCase are the two main ones. - # cmake --build ./build --target check-hermes -j 4 - python3 hermes/utils/testsuite/run_testsuite.py --test-intl test262/test -b build/bin + script: | + adb logcat -c + touch ./emulator.log + chmod 777 ./emulator.log + adb logcat >> ./emulator.log & + cd android && ./gradlew :intltest:prepareTests && ./gradlew -Pabis=x86 :intltest:connectedAndroidTest + - name: Upload emulator log + if: always() + uses: actions/upload-artifact@v4.3.4 + with: + name: emulator.log + path: emulator.log diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml deleted file mode 100644 index 62c1bd1d724..00000000000 --- a/.github/workflows/create-tag.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Publish Tag -on: - workflow_dispatch: - inputs: - rnVersion: - description: "The React Native version that will use this tag" - required: true - targetSha: - description: "The SHA you want to tag. If not specified it will tag the HEAD of the selected branch" - required: false - -jobs: - publish: - runs-on: [ubuntu-latest] - - steps: - - name: Get current date - id: date - run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT - - - name: Get the target SHA - id: targetSha - run: echo "targetSha=$(if [ -z "$TARGET_SHA" ]; then echo $GITHUB_SHA; else echo $TARGET_SHA; fi)" >> $GITHUB_OUTPUT - env: - TARGET_SHA: ${{ github.event.inputs.targetSha }} - - - name: Create tag - uses: actions/github-script@v5 - with: - script: | - github.rest.git.createRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: 'refs/tags/hermes-${{ steps.date.outputs.date }}-RNv${{ github.event.inputs.rnVersion }}-${{ steps.targetSha.outputs.targetSha }}', - sha: '${{ steps.targetSha.outputs.targetSha }}' - }) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index b0c746e8830..00000000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: publish - -on: - workflow_call: - inputs: - release-type: - required: true - description: The type of release we are building. It could be commitly, release or dry-run - type: string - -jobs: - publish: - runs-on: 8-core-ubuntu - container: - image: reactnativecommunity/react-native-android:latest - env: - TERM: "dumb" - GRADLE_OPTS: "-Dorg.gradle.daemon=false" - env: - HERMES_WS_DIR: /tmp/hermes - ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }} - ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }} - ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }} - ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup git safe folders - shell: bash - run: git config --global --add safe.directory '*' - - name: Create /tmp/hermes/osx-bin directory - shell: bash - run: mkdir -p /tmp/hermes/osx-bin - - name: Download osx-bin release artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-osx-bin-Release - path: /tmp/hermes/osx-bin/Release - - name: Download osx-bin debug artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-osx-bin-Debug - path: /tmp/hermes/osx-bin/Debug - - name: Download darwin-bin release artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-darwin-bin-Release - path: /tmp/hermes/hermes-runtime-darwin - - name: Download darwin-bin debug artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-darwin-bin-Debug - path: /tmp/hermes/hermes-runtime-darwin - - name: Download hermes dSYM debug artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-dSYM-Debug - path: /tmp/hermes/dSYM/Debug - - name: Download hermes dSYM release vartifacts - uses: actions/download-artifact@v4 - with: - name: hermes-dSYM-Release - path: /tmp/hermes/dSYM/Release - - name: Download windows-bin artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-win64-bin - path: /tmp/hermes/win64-bin - - name: Download linux-bin artifacts - uses: actions/download-artifact@v4 - with: - name: hermes-linux-bin - path: /tmp/hermes/linux64-bin - - name: Show /tmp/hermes directory - shell: bash - run: ls -lR /tmp/hermes - - name: Copy Hermes binaries - shell: bash - run: | - mkdir -p ./android/ios-artifacts/artifacts/ - cp $HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Debug.tar.gz ./android/ios-artifacts/artifacts/hermes-ios-debug.tar.gz - cp $HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Release.tar.gz ./android/ios-artifacts/artifacts/hermes-ios-release.tar.gz - cp $HERMES_WS_DIR/dSYM/Debug/hermes.framework.dSYM ./android/ios-artifacts/artifacts/hermes-framework-dSYM-debug.tar.gz - cp $HERMES_WS_DIR/dSYM/Release/hermes.framework.dSYM ./android/ios-artifacts/artifacts/hermes-framework-dSYM-release.tar.gz - - name: Print Artifacts Directory - shell: bash - run: ls -lR ./android/ios-artifacts/artifacts/ - - name: Setup node.js - uses: ./.github/actions/setup-node - - name: Install dependencies - uses: ./.github/actions/yarn-install - - name: Publish artifacts - shell: bash - run: | - node ./utils/scripts/hermes/publish-artifacts.js -t ${{ inputs.release-type }} diff --git a/.github/workflows/rn-build-hermes.yml b/.github/workflows/rn-build-hermes.yml deleted file mode 100644 index 8ad4c260872..00000000000 --- a/.github/workflows/rn-build-hermes.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: RN Build Hermes - -on: - workflow_dispatch: - inputs: - release-type: - description: 'Release type (release, commitly, dry-run)' - required: false - default: 'dry-run' - pull_request: - push: - branches: - - main - tags: - - "v0.*.*" # This should match v0.X.Y - -jobs: - set_release_type: - runs-on: ubuntu-latest - if: github.repository == 'facebook/hermes' - outputs: - RELEASE_TYPE: ${{ steps.set_release_type.outputs.RELEASE_TYPE }} - env: - EVENT_NAME: ${{ github.event_name }} - REF: ${{ github.ref }} - steps: - - id: set_release_type - run: | - if [[ $EVENT_NAME == "push" && $REF == refs/tags/v* ]]; then - echo "Setting release type to release" - echo "RELEASE_TYPE=release" >> $GITHUB_OUTPUT - elif [[ $EVENT_NAME == "push" && $REF == refs/heads/main ]]; then - echo "Setting release type to commitly" - echo "RELEASE_TYPE=commitly" >> $GITHUB_OUTPUT - elif [[ $EVENT_NAME == "workflow_dispatch" ]]; then - echo "Setting release type to ${{ github.event.inputs.release-type }}" - echo "RELEASE_TYPE=${{ github.event.inputs.release-type }}" >> $GITHUB_OUTPUT - else - echo "Setting release type to dry-run" - echo "RELEASE_TYPE=dry-run" >> $GITHUB_OUTPUT - fi - build_hermesc_apple: - uses: ./.github/workflows/build-hermesc-apple.yml - build_apple_slices_hermes: - uses: ./.github/workflows/build-apple-slices-hermes.yml - needs: build_hermesc_apple - build_hermes_macos: - uses: ./.github/workflows/build-hermes-macos.yml - needs: build_apple_slices_hermes - build_hermesc_linux: - uses: ./.github/workflows/build-hermesc-linux.yml - build_hermesc_windows: - uses: ./.github/workflows/build-hermesc-windows.yml - build_android: - uses: ./.github/workflows/build-android.yml - needs: set_release_type - secrets: inherit - with: - release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }} - build_emscripten: - uses: ./.github/workflows/build-emscripten.yml - test-apple-runtime: - needs: build_hermes_macos - uses: ./.github/workflows/test-apple-runtime.yml - run-tests: - uses: ./.github/workflows/run-tests.yml - publish: - uses: ./.github/workflows/publish.yml - needs: - [ - set_release_type, - build_hermes_macos, - build_hermesc_linux, - build_hermesc_windows, - build_android, - ] - with: - release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }} diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml deleted file mode 100644 index 6d401e27efe..00000000000 --- a/.github/workflows/run-tests.yml +++ /dev/null @@ -1,219 +0,0 @@ -name: run-tests - -on: - workflow_call - -jobs: - test-macos: - runs-on: macos-14 - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: 16.2 - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Install dependencies - run: brew install cmake - - name: Run MacOS regression tests in debug mode - run: |- - cmake -S hermes -B build -GXcode - cmake --build ./build - cmake --build ./build --target check-hermes - test-linux: - runs-on: ubuntu-22.04 - steps: - - name: Install dependencies - run: |- - sudo apt update - sudo apt install -y git openssh-client cmake build-essential \ - libicu-dev zip python3 - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Run Hermes regression tests - run: |- - cmake -S hermes -B build - cmake --build build --target check-hermes all -j 4 - test-windows: - runs-on: windows-2025 - steps: - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Run Hermes regression tests - run: |- - cmake -S hermes -B build -G 'Visual Studio 17 2022' - cmake --build build --target check-hermes -- -m /p:UseMultiToolTask=true -m /p:EnforceProcessCountAcrossBuilds=true - test-e2e: - runs-on: ubuntu-22.04 - env: - ANDROID_NDK: /usr/local/lib/android/sdk/ndk/27.1.12297006 - HERMES_WS_DIR: /home/runner/work/hermes - REACT_NATIVE_OVERRIDE_HERMES_DIR: /home/runner/work/hermes/hermes - steps: - - name: Install Node - uses: actions/setup-node@v4.0.2 - with: - node-version: 24 - - name: Install JDK - uses: actions/setup-java@v3 - with: - distribution: "temurin" - java-version: "17" - - name: Checkout Hermes - uses: actions/checkout@v4.1.0 - - name: Checkout React Native - run: |- - cd "$HERMES_WS_DIR" - git clone --depth=1 https://github.com/facebook/react-native - cd react-native - yarn install - echo "console.log('Using Hermes: ' + (global.HermesInternal != null));" >> packages/rn-tester/js/RNTesterApp.android.js - - name: Run RNTester - uses: ReactiveCircus/android-emulator-runner@v2.30.1 - with: - api-level: 29 - ndk: 27.1.12297006 - cmake: 3.22.1 - script: | - cd ../react-native && ./gradlew -PreactNativeArchitectures=x86 :packages:rn-tester:android:app:installRelease - adb shell am start com.facebook.react.uiapp/.RNTesterActivity - timeout 30s adb logcat -e "Using Hermes: true" -m 1 - test-e2e-intl: - runs-on: ubuntu-22.04 - env: - HERMES_WS_DIR: /home/runner/work/hermes - ANDROID_NDK: /usr/local/lib/android/sdk/ndk/27.1.12297006 - steps: - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'zulu' - - name: Checkout Hermes - uses: actions/checkout@v4.1.0 - - name: Checkout Test262 - run: |- - cd "$HERMES_WS_DIR" - git clone https://github.com/tc39/test262 - cd test262 - git checkout 62626e083bd506124aac6c799464d76c2c42851b - - name: Build Hermes Compiler - run: |- - cd "$HERMES_WS_DIR" - cmake -S hermes -B ./build -DCMAKE_BUILD_TYPE=Release - cmake --build ./build -j 4 --target hermesc - - name: Run android tests - id: tests - uses: ReactiveCircus/android-emulator-runner@v2.30.1 - with: - api-level: 29 - emulator-options: -timezone Europe/Paris -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - script: | - adb logcat -c - touch ./emulator.log - chmod 777 ./emulator.log - adb logcat >> ./emulator.log & - cd android && ./gradlew :intltest:prepareTests && ./gradlew -Pabis=x86 :intltest:connectedAndroidTest - - name: Upload emulator log - if: always() - uses: actions/upload-artifact@v4.3.4 - with: - name: emulator.log - path: emulator.log - test-macos-test262: - runs-on: macos-14 - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: 16.2 - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Setup dependencies - run: |- - brew install cmake ninja - # Check out test262 at a pinned revision to reduce flakiness - git clone https://github.com/tc39/test262 - cd test262 - git checkout 62626e083bd506124aac6c799464d76c2c42851b - - name: Run Hermes tests and test262 with Intl - run: |- - cmake -S hermes -B build -GNinja -DHERMES_ENABLE_INTL=ON - cmake --build ./build - cmake --build ./build --target check-hermes - python3 hermes/utils/testsuite/run_testsuite.py --test-intl test262/test -b build/bin - test-linux-test262: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Setup dependencies - run: |- - sudo apt update - sudo apt install -y git openssh-client cmake build-essential \ - libreadline-dev libicu-dev zip python3 - # Check out test262 at a pinned revision to reduce flakiness - git clone https://github.com/tc39/test262 - cd test262 - git checkout 62626e083bd506124aac6c799464d76c2c42851b - - name: Run test262 with Intl - run: |- - cmake -S hermes -B build -DHERMES_ENABLE_INTL=ON -DCMAKE_CXX_FLAGS=-O2 -DCMAKE_C_FLAGS=-O2 - cmake --build ./build -j 4 - # Not running Hermes test until more of Intl is built out: - # toLocaleLowerCase and toLocaleUpperCase are the two main ones. - # cmake --build ./build --target check-hermes -j 4 - python3 hermes/utils/testsuite/run_testsuite.py --test-intl test262/test -b build/bin - sandbox: - runs-on: ubuntu-22.04 - container: - image: emscripten/emsdk:3.1.39 - env: - DEBIAN_FRONTEND: noninteractive - steps: - - name: Install dependencies - run: |- - apt update - apt install -y libicu-dev tzdata - wget https://github.com/WebAssembly/wabt/releases/download/1.0.33/wabt-1.0.33-ubuntu.tar.gz - tar -xvf ./wabt-1.0.33-ubuntu.tar.gz - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Build Hermes with Emscripten - run: |- - # Generate the host compiler. - cmake -S hermes -B build_host - cmake --build ./build_host --target hermesc -j 4 - # Generate and build the debug artefact. - cmake -S hermes -B build_wasm_dbg \ - -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ - -DIMPORT_HOST_COMPILERS=build_host/ImportHostCompilers.cmake \ - -DCMAKE_BUILD_TYPE=Debug -DHERMES_UNICODE_LITE=ON \ - -DCMAKE_CXX_FLAGS=-O2 -DCMAKE_C_FLAGS=-O2 \ - -DCMAKE_EXE_LINKER_FLAGS="-sALLOW_MEMORY_GROWTH=1 -sSTACK_SIZE=256KB" \ - -DHERMES_ENABLE_DEBUGGER=OFF -DHERMES_SLOW_DEBUG=OFF - cmake --build build_wasm_dbg --target hermesSandboxImpl -j 4 - ./wabt-1.0.33/bin/wasm2c build_wasm_dbg/API/hermes_sandbox/hermesSandboxImpl.wasm -n hermes \ - -o hermes/API/hermes_sandbox/external/hermes_sandbox_impl_dbg_compiled.c --num-outputs 8 - # Generate and build the release artefact. - cmake -S hermes -B build_wasm_opt \ - -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ - -DIMPORT_HOST_COMPILERS=build_host/ImportHostCompilers.cmake \ - -DCMAKE_BUILD_TYPE=Release -DHERMES_UNICODE_LITE=ON \ - -DCMAKE_EXE_LINKER_FLAGS="-sALLOW_MEMORY_GROWTH=1 -sSTACK_SIZE=256KB -g2" \ - -DHERMES_ENABLE_DEBUGGER=OFF - cmake --build build_wasm_opt --target hermesSandboxImpl -j 4 - ./wabt-1.0.33/bin/wasm2c build_wasm_opt/API/hermes_sandbox/hermesSandboxImpl.wasm -n hermes \ - -o hermes/API/hermes_sandbox/external/hermes_sandbox_impl_opt_compiled.c --num-outputs 8 - - name: Build and test with the newly generated sandbox - run: |- - cmake -S hermes -B build_dbg -DCMAKE_BUILD_TYPE=Debug - cmake --build build_dbg -j 4 - cmake --build build_dbg --target check-hermes -j 4 - cmake -S hermes -B build_opt -DCMAKE_BUILD_TYPE=Release - cmake --build build_opt -j 4 - cmake --build build_opt --target check-hermes -j 4 diff --git a/.github/workflows/test-apple-runtime.yml b/.github/workflows/test-apple-runtime.yml deleted file mode 100644 index e1664c38c74..00000000000 --- a/.github/workflows/test-apple-runtime.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: test-apple-runtime - -on: - workflow_call - -jobs: - test-apple-runtime: - runs-on: macos-14 - env: - TERM: dumb - HERMES_WS_DIR: "/tmp/hermes" - HOMEBREW_NO_AUTO_UPDATE: 1 - strategy: - matrix: - include: - - destination: platform=macOS - scheme: ApplePlatformsIntegrationMacTests - name: Test MacOS application - - destination: platform=iOS Simulator,name=iPhone 16 - scheme: ApplePlatformsIntegrationMobileTests - name: Test iPhone application - - destination: platform=visionOS Simulator,name=Apple Vision Pro - scheme: ApplePlatformsIntegrationVisionOSTests - name: Test Apple Vision application - - destination: platform=tvOS Simulator,name=Apple TV - scheme: ApplePlatformsIntegrationTVOSTests - name: Test Apple TV application - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup xcode - uses: ./.github/actions/setup-xcode - - name: Install dependencies - shell: bash - run: brew install cmake ninja - - name: Download visionOS SDK - shell: bash - if: ${{ matrix.scheme == 'ApplePlatformsIntegrationVisionOSTests' }} - run: xcodebuild -downloadPlatform visionOS - - name: Download tvOS SDK - shell: bash - if: ${{ matrix.scheme == 'ApplePlatformsIntegrationTVOSTests' }} - run: xcodebuild -downloadPlatform tvOS - - name: Use built artifacts - uses: actions/download-artifact@v4 - with: - path: . - name: hermes-darwin-bin-Debug - - name: Unzip artifacts - shell: bash - run: | - ls -l . - tar -xzv -f hermes-ios-Debug.tar.gz - - name: Run pod install on ApplePlatformsIntegrationTestApp - shell: bash - run: pod install - working-directory: test/ApplePlatformsIntegrationTestApp - - name: ${{ matrix.name }} - shell: bash - run: |- - xcodebuild test \ - -workspace ApplePlatformsIntegrationTests.xcworkspace \ - -configuration Debug \ - -destination '${{ matrix.destination }}' \ - -scheme ${{ matrix.scheme }} - working-directory: test/ApplePlatformsIntegrationTestApp diff --git a/android/intltest/java/com/facebook/hermes/test/HermesIntlTest262.java b/android/intltest/java/com/facebook/hermes/test/HermesIntlTest262.java index f0d2c98ce04..f3b533e468f 100644 --- a/android/intltest/java/com/facebook/hermes/test/HermesIntlTest262.java +++ b/android/intltest/java/com/facebook/hermes/test/HermesIntlTest262.java @@ -65,7 +65,7 @@ protected void evaluateCommonScriptsFromAsset(JSRuntime rt) throws IOException { public void test262Intl() throws IOException { Set skipList = getSkipList(); Stack testFiles = new Stack<>(); - testFiles.push("test262/test"); + testFiles.push("test262/test/intl402/Intl/getCanonicalLocales/returned-object-is-mutable.js"); AssetManager assets = InstrumentationRegistry.getInstrumentation().getTargetContext().getAssets(); ArrayList ranTests = new ArrayList<>(); @@ -92,6 +92,7 @@ public void test262Intl() throws IOException { ranTests.add(path); } catch (com.facebook.jni.CppException ex) { failedTests.put(path, ex.getMessage()); + ex.printStackTrace(); } } } diff --git a/lib/VM/JSArray.cpp b/lib/VM/JSArray.cpp index dbd0e222e56..54d442bb973 100644 --- a/lib/VM/JSArray.cpp +++ b/lib/VM/JSArray.cpp @@ -620,7 +620,7 @@ CallResult JSArray::setLength( double d; if (LLVM_LIKELY(newLength->isNumber())) { d = newLength->getNumber(); - ulen = truncateToUInt32(d); + ulen = (uint32_t)d; } else { // According to the spec, toNumber() has to be called twice. // https://tc39.es/ecma262/multipage/ordinary-and-exotic-objects-behaviours.html#sec-arraysetlength @@ -632,7 +632,7 @@ CallResult JSArray::setLength( if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) return ExecutionStatus::EXCEPTION; d = res->getNumber(); - ulen = truncateToUInt32(d); + ulen = (uint32_t)d; // If it is a string, no need to convert again, since it is pretty // expensive. Other types are not so important, since their conversions are // either fast (bool) or slow (object). @@ -647,8 +647,19 @@ CallResult JSArray::setLength( } } - if (ulen != d) + if (d > 2147483648) { + char* string; + int truncated = (int)d; + if(0 > asprintf(&string, "Invalid array length: %u %f %d\n", ulen, d, truncated)) { + return runtime.raiseRangeError("Invalid array length"); + } else { + return runtime.raiseRangeError(string); + } + } + + if (ulen != d) { return runtime.raiseRangeError("Invalid array length"); + } return setLength(selfHandle, runtime, ulen, opFlags); } From 776cd5c53cdefb8af26d22f9a5fa1f4cd0b57cb1 Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Wed, 20 Aug 2025 09:36:46 +0200 Subject: [PATCH 2/3] Add test --- .../hermes/test/HermesIntlAndroidTest.java | 16 ++++++++++++++++ lib/VM/JSArray.cpp | 13 +------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/android/intltest/java/com/facebook/hermes/test/HermesIntlAndroidTest.java b/android/intltest/java/com/facebook/hermes/test/HermesIntlAndroidTest.java index 8b1a89bc0ae..478724510b0 100644 --- a/android/intltest/java/com/facebook/hermes/test/HermesIntlAndroidTest.java +++ b/android/intltest/java/com/facebook/hermes/test/HermesIntlAndroidTest.java @@ -24,6 +24,22 @@ @RunWith(AndroidJUnit4.class) public class HermesIntlAndroidTest { + @Test + public void testTruncation() throws IOException { + try (JSRuntime rt = JSRuntime.makeHermesRuntime()) { + rt.evaluateJavaScript( + new StringBuilder() + .append("var locales = ['en-US', 'fr'];\n") + .append("var result = Intl.getCanonicalLocales(locales);\n") + .append("result[\"length\"] = Math.pow(2, 32) - 1;\n") + .append("var newLength = String(result.length);\n") + .toString()); + + String result = rt.getGlobalStringProperty("newLength"); + assertThat(result).isEqualTo("4294967295"); + } + } + @Test public void testIntlFromAsset() throws IOException { AssetManager assets = diff --git a/lib/VM/JSArray.cpp b/lib/VM/JSArray.cpp index 54d442bb973..489ce9431d3 100644 --- a/lib/VM/JSArray.cpp +++ b/lib/VM/JSArray.cpp @@ -647,19 +647,8 @@ CallResult JSArray::setLength( } } - if (d > 2147483648) { - char* string; - int truncated = (int)d; - if(0 > asprintf(&string, "Invalid array length: %u %f %d\n", ulen, d, truncated)) { - return runtime.raiseRangeError("Invalid array length"); - } else { - return runtime.raiseRangeError(string); - } - } - - if (ulen != d) { + if (ulen != d) return runtime.raiseRangeError("Invalid array length"); - } return setLength(selfHandle, runtime, ulen, opFlags); } From 272ad4f15a318e3798859aeae0a7e3e227611008 Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Mon, 25 Aug 2025 08:25:33 +0200 Subject: [PATCH 3/3] Update emulator --- .github/workflows/build.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 43f4a7ae0cb..961ed6e7d14 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ on: jobs: test-e2e-intl: runs-on: ubuntu-22.04 - timeout-minutes: 25 + timeout-minutes: 35 env: HERMES_WS_DIR: /home/runner/work/hermes ANDROID_NDK: /usr/local/lib/android/sdk/ndk/27.1.12297006 @@ -59,14 +59,15 @@ jobs: - name: Run android tests uses: ReactiveCircus/android-emulator-runner@v2.30.1 with: - api-level: 29 + api-level: 35 + arch: x86_64 emulator-options: -timezone Europe/Paris -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none script: | adb logcat -c touch ./emulator.log chmod 777 ./emulator.log adb logcat >> ./emulator.log & - cd android && ./gradlew :intltest:prepareTests && ./gradlew -Pabis=x86 :intltest:connectedAndroidTest + cd android && ./gradlew :intltest:prepareTests && ./gradlew -Pabis=x86_64 :intltest:connectedAndroidTest - name: Upload emulator log if: always() uses: actions/upload-artifact@v4.3.4