Skip to content

Commit 09dddf3

Browse files
committed
Extend GHA workflow to run test app
1 parent a24c872 commit 09dddf3

File tree

1 file changed

+94
-6
lines changed

1 file changed

+94
-6
lines changed

.github/workflows/check.yml

Lines changed: 94 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Check
22

3+
env:
4+
# Version here should match the one in React Native template and packages/cmake-rn/src/cli.ts
5+
NDK_VERSION: 27.1.12297006
6+
37
on:
48
push:
59
branches:
@@ -25,8 +29,29 @@ jobs:
2529
strategy:
2630
fail-fast: false
2731
matrix:
28-
runner: [ubuntu-latest, windows-latest, macos-latest]
29-
name: Test (${{ matrix.runner }})
32+
runner:
33+
- ubuntu-latest
34+
- windows-latest
35+
- macos-latest
36+
variant:
37+
- unit-tests
38+
- android-tests
39+
- ios-tests
40+
exclude:
41+
# iOS tests are only supported on macOS runners
42+
- runner: ubuntu-latest
43+
variant: ios-tests
44+
- runner: windows-latest
45+
variant: ios-tests
46+
# The reactivecircus/android-emulator-runner action does not support Windows runners
47+
# See https://github.com/marketplace/actions/android-emulator-runner#github-action---android-emulator-runner
48+
- runner: windows-latest
49+
variant: android-tests
50+
# MacOS is slow and expensive at running Android emulators
51+
- runner: macos-latest
52+
variant: android-tests
53+
54+
name: Test (${{ matrix.variant }} on ${{ matrix.runner }})
3055
runs-on: ${{ matrix.runner }}
3156
steps:
3257
- uses: actions/checkout@v4
@@ -40,9 +65,72 @@ jobs:
4065
distribution: "temurin"
4166
- name: Setup Android SDK
4267
uses: android-actions/setup-android@v3
43-
# Version here should match the one in React Native template and packages/cmake-rn/src/cli.ts
44-
- run: sdkmanager --install "ndk;27.1.12297006"
45-
- run: rustup target add x86_64-linux-android aarch64-linux-android aarch64-apple-ios-sim
68+
with:
69+
packages: tools platform-tools ndk;${{ env.NDK_VERSION }}
70+
- run: rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi i686-linux-android aarch64-apple-ios-sim
4671
- run: npm ci
4772
- run: npm run bootstrap
48-
- run: npm test
73+
# Unit tests
74+
- if: matrix.variant == 'unit-tests'
75+
name: Run tests (Unit)
76+
run: npm test
77+
# Integration tests (iOS)
78+
- if: matrix.variant == 'ios-tests'
79+
run: npm run pod-install
80+
working-directory: apps/test-app
81+
- if: matrix.variant == 'ios-tests'
82+
name: Run tests (iOS)
83+
run: npm run test:ios
84+
working-directory: apps/test-app
85+
# Integration tests (Android)
86+
- name: Clone patched Hermes version
87+
if: matrix.variant == 'android-tests'
88+
shell: bash
89+
run: |
90+
REACT_NATIVE_OVERRIDE_HERMES_DIR=$(npx react-native-node-api vendor-hermes --silent)
91+
echo "REACT_NATIVE_OVERRIDE_HERMES_DIR=$REACT_NATIVE_OVERRIDE_HERMES_DIR" >> $GITHUB_ENV
92+
working-directory: apps/test-app
93+
- name: Setup Android Emulator cache
94+
if: matrix.variant == 'android-tests'
95+
uses: actions/cache@v4
96+
id: avd-cache
97+
with:
98+
path: |
99+
~/.android/avd/*
100+
~/.android/adb*
101+
key: ${{ runner.os }}-avd-29
102+
# See https://github.com/marketplace/actions/android-emulator-runner#running-hardware-accelerated-emulators-on-linux-runners
103+
- name: Enable KVM group perms
104+
if: matrix.runner == 'ubuntu-latest' && matrix.variant == 'android-tests'
105+
run: |
106+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
107+
sudo udevadm control --reload-rules
108+
sudo udevadm trigger --name-match=kvm
109+
- name: Build weak-node-api for all architectures
110+
if: matrix.variant == 'android-tests'
111+
run: npm run build-weak-node-api -- --android
112+
working-directory: packages/host
113+
- name: Build ferric-example for all architectures
114+
if: matrix.variant == 'android-tests'
115+
run: npm run build -- --android
116+
working-directory: packages/ferric-example
117+
- name: Run tests (Android)
118+
if: matrix.variant == 'android-tests'
119+
timeout-minutes: 75
120+
uses: reactivecircus/android-emulator-runner@v2
121+
with:
122+
api-level: 29
123+
force-avd-creation: false
124+
emulator-options: -no-snapshot-save -no-metrics -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
125+
disable-animations: true
126+
arch: ${{ runner.os == 'macOS' && 'arm64-v8a' || 'x86' }}
127+
ndk: ${{ env.NDK_VERSION }}
128+
cmake: 3.22.1
129+
working-directory: apps/test-app
130+
script: |
131+
# Setup port forwarding to Mocha Remote
132+
adb reverse tcp:8090 tcp:8090
133+
# Uninstall the app if already in the snapshot (unlikely but could result in a signature mismatch failure)
134+
adb uninstall com.microsoft.reacttestapp || true
135+
# Build, install and run the app
136+
npm run test:android

0 commit comments

Comments
 (0)