Skip to content

Commit 2cc7738

Browse files
authored
Convert React Native pipeline to GH (#26052)
Convert React Native pipeline to Github Actions. The new place use ARM64 machines instead of x86 machines to run the tests.
1 parent a7ae9ae commit 2cc7738

File tree

7 files changed

+362
-146
lines changed

7 files changed

+362
-146
lines changed

.github/workflows/react_native.yml

Lines changed: 333 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,333 @@
1+
name: React Native CI Pipeline
2+
3+
on:
4+
push:
5+
branches: [main, 'rel-*']
6+
pull_request:
7+
branches: [main, 'rel-*']
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build_android_packages:
16+
name: Build Android AAR Packages
17+
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
18+
timeout-minutes: 120
19+
outputs:
20+
aar_path: ${{ runner.temp }}/.artifacts
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v5
24+
with:
25+
submodules: false
26+
27+
- name: Set version number variables
28+
id: set_versions
29+
run: |
30+
echo "OnnxRuntimeVersion=$(head -1 VERSION_NUMBER)" >> $GITHUB_ENV
31+
echo "OnnxRuntimeGitCommitHash=$(git rev-parse HEAD)" >> $GITHUB_ENV
32+
echo "OnnxRuntimeGitCommitHashShort=$(git rev-parse --short=8 HEAD)" >> $GITHUB_ENV
33+
34+
- name: Setup Android NDK
35+
uses: ./.github/actions/setup-android-ndk
36+
with:
37+
ndk-version: 28.0.13004108
38+
39+
- uses: microsoft/onnxruntime-github-actions/[email protected]
40+
with:
41+
vcpkg-version: '2025.06.13'
42+
vcpkg-hash: '735923258c5187966698f98ce0f1393b8adc6f84d44fd8829dda7db52828639331764ecf41f50c8e881e497b569f463dbd02dcb027ee9d9ede0711102de256cc'
43+
cmake-version: '3.31.6'
44+
cmake-hash: '42395e20b10a8e9ef3e33014f9a4eed08d46ab952e02d2c1bbc8f6133eca0d7719fb75680f9bbff6552f20fcd1b73d86860f7f39388d631f98fb6f622b37cf04'
45+
add-cmake-to-path: 'true'
46+
disable-terrapin: 'true'
47+
48+
- name: Build Android AAR Packages
49+
run: |
50+
set -e -x
51+
mkdir -p ${{ runner.temp }}/.build_settings
52+
mkdir -p ${{ runner.temp }}/artifacts
53+
cp tools/ci_build/github/js/react_native_e2e_full_aar_build_settings.json ${{ runner.temp }}/.build_settings/build_settings.json
54+
55+
python3 -m pip install --user -r ${{ github.workspace }}/tools/ci_build/requirements/pybind/requirements.txt
56+
57+
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
58+
59+
# Copy the built artifacts to give folder for publishing
60+
BASE_PATH=${{ runner.temp }}/aar_out/Release/com/microsoft/onnxruntime/onnxruntime-android/${OnnxRuntimeVersion}
61+
cp ${BASE_PATH}/*.jar ${{ runner.temp }}/artifacts
62+
cp ${BASE_PATH}/*.aar ${{ runner.temp }}/artifacts
63+
cp ${BASE_PATH}/*.pom ${{ runner.temp }}/artifacts
64+
65+
- name: Upload Android AAR Artifact
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: onnxruntime-android-full-aar
69+
path: ${{ runner.temp }}/artifacts
70+
71+
react_native_ci_android:
72+
name: React Native CI Android
73+
needs: build_android_packages
74+
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
75+
timeout-minutes: 90
76+
steps:
77+
- name: Set ANDROID_AVD_HOME environment variable
78+
run: echo "ANDROID_AVD_HOME=${{ runner.temp }}/android-avd" >> $GITHUB_ENV
79+
80+
- name: Checkout repository
81+
uses: actions/checkout@v5
82+
83+
- name: Use Python 3.12
84+
uses: actions/setup-python@v6
85+
with:
86+
python-version: "3.12"
87+
architecture: "x64"
88+
89+
- name: Use Java 17 (Temurin)
90+
uses: actions/setup-java@v5
91+
with:
92+
distribution: 'temurin'
93+
java-version: '17'
94+
architecture: x64
95+
96+
- name: Use Node.js 22.x
97+
uses: actions/setup-node@v5
98+
with:
99+
node-version: '22.x'
100+
101+
- name: Install ninja
102+
run: sudo apt-get update && sudo apt-get install -y ninja-build
103+
104+
- name: Download Android AAR artifacts
105+
uses: actions/download-artifact@v4
106+
with:
107+
name: onnxruntime-android-full-aar
108+
path: ${{ runner.temp }}/android-full-aar
109+
110+
- name: Copy AAR to React Native and E2E directories
111+
run: |
112+
mkdir -p ${{ github.workspace }}/js/react_native/android/libs
113+
cp ${{ runner.temp }}/android-full-aar/*.aar ${{ github.workspace }}/js/react_native/android/libs
114+
mkdir -p ${{ github.workspace }}/js/react_native/e2e/android/app/libs
115+
cp ${{ runner.temp }}/android-full-aar/*.aar ${{ github.workspace }}/js/react_native/e2e/android/app/libs
116+
117+
- name: Install dependencies and bootstrap
118+
run: |
119+
npm install -g detox-cli
120+
npm ci
121+
working-directory: ${{ github.workspace }}/js
122+
- run: npm ci
123+
working-directory: ${{ github.workspace }}/js/common
124+
- run: |
125+
npm ci
126+
npm run bootstrap-no-pods
127+
working-directory: ${{ github.workspace }}/js/react_native
128+
129+
- name: Generate a debug keystore
130+
run: |
131+
keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -storepass android \
132+
-keypass android -keyalg RSA -keysize 2048 -validity 999999 -dname "CN=Android Debug,O=Android,C=US"
133+
working-directory: ${{ github.workspace }}/js/react_native/e2e/android
134+
135+
- name: Build React Native Detox Android e2e Tests
136+
run: detox build --configuration android.emu.release
137+
working-directory: ${{ github.workspace }}/js/react_native/e2e
138+
139+
- name: Setup Android Emulator
140+
uses: ./.github/actions/setup-android-ndk
141+
with:
142+
ndk-version: 28.0.13004108
143+
144+
- name: Run React Native Android Instrumented Tests
145+
run: ./gradlew connectedDebugAndroidTest --stacktrace
146+
working-directory: ${{ github.workspace }}/js/react_native/android
147+
148+
- name: Run React Native Detox Android e2e Tests
149+
run: |
150+
JEST_JUNIT_OUTPUT_FILE=${{ github.workspace }}/js/react_native/e2e/android-test-results.xml \
151+
detox test --record-logs all \
152+
--configuration android.emu.release \
153+
--loglevel trace \
154+
--take-screenshots failing
155+
working-directory: ${{ github.workspace }}/js/react_native/e2e
156+
157+
- name: Install psutil and Stop Android Emulator
158+
if: always()
159+
run: |
160+
python3 -m pip install psutil
161+
if test -f ./emulator.pid; then
162+
echo "Emulator PID: $(cat ./emulator.pid)"
163+
python3 tools/python/run_android_emulator.py \
164+
--android-sdk-root "${ANDROID_SDK_ROOT}" \
165+
--stop \
166+
--emulator-pid-file ./emulator.pid
167+
rm ./emulator.pid
168+
else
169+
echo "Emulator PID file was expected to exist but does not."
170+
fi
171+
172+
react_native_ci_ios_build:
173+
name: React Native CI iOS Build
174+
runs-on: macos-14
175+
timeout-minutes: 120
176+
steps:
177+
- name: Checkout repository
178+
uses: actions/checkout@v5
179+
180+
- name: Use Xcode 15.3.0
181+
run: sudo xcode-select --switch /Applications/Xcode_15.3.0.app/Contents/Developer
182+
183+
- name: Use Python 3.12
184+
uses: actions/setup-python@v6
185+
with:
186+
python-version: "3.12"
187+
architecture: "x64"
188+
189+
- name: Install Python requirements
190+
run: pip install -r tools/ci_build/github/apple/ios_packaging/requirements.txt
191+
192+
- uses: microsoft/onnxruntime-github-actions/[email protected]
193+
with:
194+
vcpkg-version: '2025.06.13'
195+
vcpkg-hash: 735923258c5187966698f98ce0f1393b8adc6f84d44fd8829dda7db52828639331764ecf41f50c8e881e497b569f463dbd02dcb027ee9d9ede0711102de256cc
196+
cmake-version: '3.31.8'
197+
cmake-hash: 99cc9c63ae49f21253efb5921de2ba84ce136018abf08632c92c060ba91d552e0f6acc214e9ba8123dee0cf6d1cf089ca389e321879fd9d719a60d975bcffcc8
198+
add-cmake-to-path: 'true'
199+
disable-terrapin: 'true'
200+
201+
- name: Build iOS package and assemble pods
202+
run: |
203+
python ${{ github.workspace }}/tools/ci_build/github/apple/build_and_assemble_apple_pods.py \
204+
--build-dir "${{ runner.temp }}/ios_framework_full" \
205+
--staging-dir "${{ runner.temp }}/ios_pod" \
206+
--build-settings-file ${{ github.workspace }}/tools/ci_build/github/js/react_native_e2e_full_ios_framework_build_settings_arm64.json
207+
208+
- name: Upload iOS Pod Artifact
209+
uses: actions/upload-artifact@v4
210+
with:
211+
name: ios_pod
212+
path: ${{ runner.temp }}/ios_pod
213+
214+
react_native_ci_ios_unit_tests:
215+
name: React Native CI iOS Unit Tests
216+
needs: react_native_ci_ios_build
217+
runs-on: macos-14
218+
timeout-minutes: 90
219+
steps:
220+
- name: Checkout repository
221+
uses: actions/checkout@v5
222+
223+
- name: Download iOS pod artifact
224+
uses: actions/download-artifact@v4
225+
with:
226+
name: ios_pod
227+
path: ${{ runner.temp }}/ios_pod
228+
229+
- name: Use Xcode 15.3.0
230+
run: sudo xcode-select --switch /Applications/Xcode_15.3.0.app/Contents/Developer
231+
232+
- name: Use Node.js 22.x
233+
uses: actions/setup-node@v5
234+
with:
235+
node-version: '22.x'
236+
237+
- uses: microsoft/onnxruntime-github-actions/[email protected]
238+
with:
239+
vcpkg-version: '2025.06.13'
240+
vcpkg-hash: 735923258c5187966698f98ce0f1393b8adc6f84d44fd8829dda7db52828639331764ecf41f50c8e881e497b569f463dbd02dcb027ee9d9ede0711102de256cc
241+
cmake-version: '3.31.8'
242+
cmake-hash: 99cc9c63ae49f21253efb5921de2ba84ce136018abf08632c92c060ba91d552e0f6acc214e9ba8123dee0cf6d1cf089ca389e321879fd9d719a60d975bcffcc8
243+
add-cmake-to-path: 'true'
244+
disable-terrapin: 'true'
245+
246+
- name: Install dependencies and bootstrap
247+
run: |
248+
npm ci
249+
working-directory: ${{ github.workspace }}/js
250+
- run: npm ci
251+
working-directory: ${{ github.workspace }}/js/common
252+
- run: |
253+
set -e -x
254+
npm ci
255+
npm run bootstrap-no-pods
256+
working-directory: ${{ github.workspace }}/js/react_native
257+
258+
- name: Pod install
259+
run: |
260+
set -e -x
261+
ls ${{ runner.temp }}/ios_pod/onnxruntime-c
262+
ORT_C_LOCAL_POD_PATH=${{ runner.temp }}/ios_pod/onnxruntime-c pod install --verbose
263+
working-directory: ${{ github.workspace }}/js/react_native/ios
264+
265+
- name: Run React Native iOS Instrumented Tests
266+
run: |
267+
/usr/bin/xcodebuild -sdk iphonesimulator -configuration Debug -workspace ${{ github.workspace }}/js/react_native/ios/OnnxruntimeModule.xcworkspace -scheme OnnxruntimeModuleTest -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4' test CODE_SIGNING_ALLOWED=NO
268+
working-directory: ${{ github.workspace }}/js/react_native/ios
269+
270+
react_native_ci_ios_e2e_tests:
271+
name: React Native CI iOS E2E Tests
272+
needs: react_native_ci_ios_build
273+
runs-on: macos-14
274+
timeout-minutes: 90
275+
steps:
276+
- name: Checkout repository
277+
uses: actions/checkout@v5
278+
279+
- name: Download iOS pod artifact
280+
uses: actions/download-artifact@v4
281+
with:
282+
name: ios_pod
283+
path: ${{ runner.temp }}/ios_pod
284+
285+
- name: Use Xcode 15.3.0
286+
run: sudo xcode-select --switch /Applications/Xcode_15.3.0.app/Contents/Developer
287+
288+
- name: Use Node.js 22.x
289+
uses: actions/setup-node@v5
290+
with:
291+
node-version: '22.x'
292+
293+
- uses: microsoft/onnxruntime-github-actions/[email protected]
294+
with:
295+
vcpkg-version: '2025.06.13'
296+
vcpkg-hash: 735923258c5187966698f98ce0f1393b8adc6f84d44fd8829dda7db52828639331764ecf41f50c8e881e497b569f463dbd02dcb027ee9d9ede0711102de256cc
297+
cmake-version: '3.31.8'
298+
cmake-hash: 99cc9c63ae49f21253efb5921de2ba84ce136018abf08632c92c060ba91d552e0f6acc214e9ba8123dee0cf6d1cf089ca389e321879fd9d719a60d975bcffcc8
299+
add-cmake-to-path: 'true'
300+
disable-terrapin: 'true'
301+
302+
- name: Install dependencies and bootstrap
303+
run: |
304+
set -e -x
305+
npm install -g detox-cli
306+
brew tap wix/brew
307+
brew install applesimutils
308+
npm ci
309+
working-directory: ${{ github.workspace }}/js
310+
- run: npm ci
311+
working-directory: ${{ github.workspace }}/js/common
312+
- run: |
313+
set -e -x
314+
npm ci
315+
npm run bootstrap-no-pods
316+
working-directory: ${{ github.workspace }}/js/react_native
317+
318+
- name: Pod install for e2e tests
319+
run: |
320+
set -e -x
321+
ls ${{ runner.temp }}/ios_pod/onnxruntime-c
322+
ORT_C_LOCAL_POD_PATH=${{ runner.temp }}/ios_pod/onnxruntime-c pod install --verbose
323+
working-directory: ${{ github.workspace }}/js/react_native/e2e/ios
324+
325+
- name: Build and Run Detox iOS e2e Tests
326+
run: |
327+
detox build --configuration ios.sim.release
328+
JEST_JUNIT_OUTPUT_FILE=${{ github.workspace }}/js/react_native/e2e/ios-test-results.xml \
329+
detox test --record-logs all \
330+
--configuration ios.sim.release \
331+
--loglevel verbose \
332+
--take-screenshots failing
333+
working-directory: ${{ github.workspace }}/js/react_native/e2e

js/react_native/e2e/.detoxrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ module.exports = {
1414
type: 'ios.app',
1515
binaryPath: 'ios/build/Build/Products/Debug-iphonesimulator/OnnxruntimeModuleExample.app',
1616
build:
17-
'xcodebuild ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO -workspace ios/OnnxruntimeModuleExample.xcworkspace -scheme OnnxruntimeModuleExample -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build',
17+
'xcodebuild ARCHS=arm64 ONLY_ACTIVE_ARCH=NO -workspace ios/OnnxruntimeModuleExample.xcworkspace -scheme OnnxruntimeModuleExample -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build',
1818
},
1919
'ios.release': {
2020
type: 'ios.app',
2121
binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/OnnxruntimeModuleExample.app',
2222
build:
23-
'xcodebuild ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO -workspace ios/OnnxruntimeModuleExample.xcworkspace -scheme OnnxruntimeModuleExample -configuration Release -sdk iphonesimulator -derivedDataPath ios/build',
23+
'xcodebuild ARCHS=arm64 ONLY_ACTIVE_ARCH=NO -workspace ios/OnnxruntimeModuleExample.xcworkspace -scheme OnnxruntimeModuleExample -configuration Release -sdk iphonesimulator -derivedDataPath ios/build',
2424
},
2525
'android.debug': {
2626
type: 'android.apk',

js/react_native/e2e/ios/OnnxruntimeModuleExample.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@
666666
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
667667
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
668668
CODE_SIGN_STYLE = Automatic;
669+
CODE_SIGN_IDENTITY = "";
669670
CURRENT_PROJECT_VERSION = 1;
670671
DEBUG_INFORMATION_FORMAT = dwarf;
671672
GCC_C_LANGUAGE_STANDARD = gnu11;
@@ -693,6 +694,7 @@
693694
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
694695
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
695696
CODE_SIGN_STYLE = Automatic;
697+
CODE_SIGN_IDENTITY = "";
696698
COPY_PHASE_STRIP = NO;
697699
CURRENT_PROJECT_VERSION = 1;
698700
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";

0 commit comments

Comments
 (0)