name: React Native CI Pipeline on: push: branches: [main, 'rel-*'] pull_request: branches: [main, 'rel-*'] workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }} cancel-in-progress: true jobs: build_android_packages: name: Build Android AAR Packages runs-on: [ "self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU", "JobId=react_build_android_packages-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}" ] timeout-minutes: 120 outputs: aar_path: ${{ runner.temp }}/.artifacts steps: - name: Checkout repository uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 with: submodules: false - name: Set version number variables id: set_versions run: | echo "OnnxRuntimeVersion=$(head -1 VERSION_NUMBER)" >> $GITHUB_ENV echo "OnnxRuntimeGitCommitHash=$(git rev-parse HEAD)" >> $GITHUB_ENV echo "OnnxRuntimeGitCommitHashShort=$(git rev-parse --short=8 HEAD)" >> $GITHUB_ENV - name: Setup Android NDK uses: ./.github/actions/setup-android-ndk with: ndk-version: 28.0.13004108 - name: Get vcpkg tool info id: vcpkg-tool-info uses: ./.github/actions/get-vcpkg-tool-info - uses: microsoft/onnxruntime-github-actions/setup-build-tools@d19341fb036c43a947a2c0e4a53ad4d15e10bc5c # v0.0.9 with: vcpkg-version: ${{ steps.vcpkg-tool-info.outputs.release_tag }} vcpkg-hash: ${{ steps.vcpkg-tool-info.outputs.sha512 }} cmake-version: '3.31.6' cmake-hash: '42395e20b10a8e9ef3e33014f9a4eed08d46ab952e02d2c1bbc8f6133eca0d7719fb75680f9bbff6552f20fcd1b73d86860f7f39388d631f98fb6f622b37cf04' add-cmake-to-path: 'true' disable-terrapin: 'true' - name: Build Android AAR Packages run: | set -e -x mkdir -p ${{ runner.temp }}/.build_settings mkdir -p ${{ runner.temp }}/artifacts cp tools/ci_build/github/js/react_native_e2e_full_aar_build_settings.json ${{ runner.temp }}/.build_settings/build_settings.json python3 -m pip install --user -r ${{ github.workspace }}/tools/ci_build/requirements/pybind/requirements.txt python3 ${{ github.workspace }}/tools/ci_build/github/android/build_aar_package.py --build_dir ${{ runner.temp }} --config Release --android_sdk_path $ANDROID_SDK_ROOT --android_ndk_path $ANDROID_NDK_ROOT ${{ runner.temp }}/.build_settings/build_settings.json # Copy the built artifacts to give folder for publishing cp -r ${{ runner.temp }}/aar_out/Release/com ${{ runner.temp }}/artifacts - name: Upload Android AAR Artifact uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: onnxruntime-android-full-aar path: ${{ runner.temp }}/artifacts react_native_ci_android: name: React Native CI Android needs: build_android_packages runs-on: [ "self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU", "JobId=react_native_ci_android-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}" ] timeout-minutes: 90 steps: - name: Set ANDROID_AVD_HOME environment variable run: echo "ANDROID_AVD_HOME=${{ runner.temp }}/android-avd" >> $GITHUB_ENV - name: Checkout repository uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - name: Use Python 3.12 uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version: "3.12" architecture: "x64" - name: Use Java 17 (Temurin) uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1 with: distribution: 'temurin' java-version: '17' architecture: x64 - name: Use Node.js 24.x uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: '24.x' registry-url: 'https://packagefeedproxy.microsoft.io/npm/' - name: Install ninja run: sudo apt-get update && sudo apt-get install -y ninja-build - name: Download Android AAR artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: onnxruntime-android-full-aar path: ${{ runner.temp }}/android-full-aar - name: Copy AAR to React Native and E2E directories run: | mkdir -p ${{ github.workspace }}/js/react_native/e2e/android/app/libs cp -r ${{ runner.temp }}/android-full-aar/com ${{ github.workspace }}/js/react_native/e2e/android/app/libs - name: Install dependencies and bootstrap run: | npm install -g detox-cli npm ci working-directory: ${{ github.workspace }}/js - run: npm ci working-directory: ${{ github.workspace }}/js/common - run: | npm ci npm run bootstrap-no-pods working-directory: ${{ github.workspace }}/js/react_native - name: Generate a debug keystore run: | keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -storepass android \ -keypass android -keyalg RSA -keysize 2048 -validity 999999 -dname "CN=Android Debug,O=Android,C=US" working-directory: ${{ github.workspace }}/js/react_native/e2e/android - name: Build React Native Detox Android e2e Tests run: detox build --configuration android.emu.release working-directory: ${{ github.workspace }}/js/react_native/e2e - name: Setup Android Emulator uses: ./.github/actions/setup-android-ndk with: ndk-version: 28.0.13004108 - name: Run React Native Detox Android e2e Tests run: | JEST_JUNIT_OUTPUT_FILE=${{ github.workspace }}/js/react_native/e2e/android-test-results.xml \ detox test --record-logs all \ --configuration android.emu.release \ --loglevel trace \ --take-screenshots failing working-directory: ${{ github.workspace }}/js/react_native/e2e - name: Install psutil and Stop Android Emulator if: always() run: | python3 -m pip install psutil if test -f ./emulator.pid; then echo "Emulator PID: $(cat ./emulator.pid)" python3 tools/python/run_android_emulator.py \ --android-sdk-root "${ANDROID_SDK_ROOT}" \ --stop \ --emulator-pid-file ./emulator.pid rm ./emulator.pid else echo "Emulator PID file was expected to exist but does not." fi - name: Upload Android Test Results if: always() uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: android-test-results path: | ${{ github.workspace }}/js/react_native/e2e/android-test-results.xml ${{ github.workspace }}/js/react_native/e2e/artifacts react_native_ci_ios_build: name: React Native CI iOS Build runs-on: macos-14 timeout-minutes: 120 steps: - name: Checkout repository uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - name: Use Xcode 15.3.0 run: sudo xcode-select --switch /Applications/Xcode_15.3.0.app/Contents/Developer - name: Use Python 3.12 uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version: "3.12" architecture: "x64" - name: Install Python requirements run: pip install -r tools/ci_build/github/apple/ios_packaging/requirements.txt - name: Get vcpkg tool info id: vcpkg-tool-info uses: ./.github/actions/get-vcpkg-tool-info - uses: microsoft/onnxruntime-github-actions/setup-build-tools@d19341fb036c43a947a2c0e4a53ad4d15e10bc5c # v0.0.9 with: vcpkg-version: ${{ steps.vcpkg-tool-info.outputs.release_tag }} vcpkg-hash: ${{ steps.vcpkg-tool-info.outputs.sha512 }} cmake-version: '3.31.8' cmake-hash: 99cc9c63ae49f21253efb5921de2ba84ce136018abf08632c92c060ba91d552e0f6acc214e9ba8123dee0cf6d1cf089ca389e321879fd9d719a60d975bcffcc8 add-cmake-to-path: 'true' disable-terrapin: 'true' - name: Build iOS package and assemble pods run: | python ${{ github.workspace }}/tools/ci_build/github/apple/build_and_assemble_apple_pods.py \ --build-dir "${{ runner.temp }}/ios_framework_full" \ --staging-dir "${{ runner.temp }}/ios_pod" \ --build-settings-file ${{ github.workspace }}/tools/ci_build/github/js/react_native_e2e_full_ios_framework_build_settings_arm64.json - name: Upload iOS Pod Artifact uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: ios_pod path: ${{ runner.temp }}/ios_pod react_native_ci_ios_e2e_tests: name: React Native CI iOS E2E Tests needs: react_native_ci_ios_build runs-on: macos-14 timeout-minutes: 90 steps: - name: Checkout repository uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - name: Download iOS pod artifact uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: ios_pod path: ${{ runner.temp }}/ios_pod - name: Use Xcode 15.3.0 run: sudo xcode-select --switch /Applications/Xcode_15.3.0.app/Contents/Developer - name: Use Node.js 24.x uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: '24.x' registry-url: 'https://packagefeedproxy.microsoft.io/npm/' - name: Get vcpkg tool info id: vcpkg-tool-info uses: ./.github/actions/get-vcpkg-tool-info - uses: microsoft/onnxruntime-github-actions/setup-build-tools@d19341fb036c43a947a2c0e4a53ad4d15e10bc5c # v0.0.9 with: vcpkg-version: ${{ steps.vcpkg-tool-info.outputs.release_tag }} vcpkg-hash: ${{ steps.vcpkg-tool-info.outputs.sha512 }} cmake-version: '3.31.8' cmake-hash: 99cc9c63ae49f21253efb5921de2ba84ce136018abf08632c92c060ba91d552e0f6acc214e9ba8123dee0cf6d1cf089ca389e321879fd9d719a60d975bcffcc8 add-cmake-to-path: 'true' disable-terrapin: 'true' - name: Install dependencies and bootstrap run: | set -e -x npm install -g detox-cli brew tap wix/brew brew trust wix/brew brew install applesimutils npm ci working-directory: ${{ github.workspace }}/js - run: npm ci working-directory: ${{ github.workspace }}/js/common - run: | set -e -x npm ci npm run bootstrap-no-pods working-directory: ${{ github.workspace }}/js/react_native - name: Pod install for e2e tests run: | set -e -x ls ${{ runner.temp }}/ios_pod/onnxruntime-c ORT_C_LOCAL_POD_PATH=${{ runner.temp }}/ios_pod/onnxruntime-c pod install --verbose working-directory: ${{ github.workspace }}/js/react_native/e2e/ios - name: Build Detox iOS e2e Tests run: detox build --configuration ios.sim.release working-directory: ${{ github.workspace }}/js/react_native/e2e - name: Reset iOS Simulators before Detox run: | set -e -x xcrun simctl shutdown all || true xcrun simctl erase all || true killall Simulator || true killall com.apple.CoreSimulator.CoreSimulatorService || true - name: Run Detox iOS e2e Tests run: | JEST_JUNIT_OUTPUT_FILE=${{ github.workspace }}/js/react_native/e2e/ios-test-results.xml \ detox test --record-logs all \ --configuration ios.sim.release \ --loglevel verbose \ --take-screenshots failing \ --cleanup working-directory: ${{ github.workspace }}/js/react_native/e2e - name: Upload iOS Test Results if: always() uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: ios-test-results path: | ${{ github.workspace }}/js/react_native/e2e/ios-test-results.xml ${{ github.workspace }}/js/react_native/e2e/artifacts