Skip to content

Commit c973699

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

File tree

1 file changed

+90
-5
lines changed

1 file changed

+90
-5
lines changed

.github/workflows/check.yml

Lines changed: 90 additions & 5 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,69 @@ 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"
68+
with:
69+
packages: tools platform-tools ndk;${{ env.NDK_VERSION }}
4570
- run: rustup target add x86_64-linux-android aarch64-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 "Cloned custom Hermes into $REACT_NATIVE_OVERRIDE_HERMES_DIR"
92+
echo "REACT_NATIVE_OVERRIDE_HERMES_DIR=$REACT_NATIVE_OVERRIDE_HERMES_DIR" >> $GITHUB_ENV
93+
working-directory: apps/test-app
94+
- name: Setup Android Emulator cache
95+
if: matrix.variant == 'android-tests'
96+
uses: actions/cache@v4
97+
id: avd-cache
98+
with:
99+
path: |
100+
~/.android/avd/*
101+
~/.android/adb*
102+
key: ${{ runner.os }}-avd-29
103+
# See https://github.com/marketplace/actions/android-emulator-runner#running-hardware-accelerated-emulators-on-linux-runners
104+
- name: Enable KVM group perms
105+
if: matrix.runner == 'ubuntu-latest' && matrix.variant == 'android-tests'
106+
run: |
107+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
108+
sudo udevadm control --reload-rules
109+
sudo udevadm trigger --name-match=kvm
110+
- name: Build weak-node-api for all architectures
111+
if: matrix.variant == 'android-tests'
112+
run: npm run build-weak-node-api -- --android
113+
working-directory: packages/host
114+
- name: Run tests (Android)
115+
if: matrix.variant == 'android-tests'
116+
timeout-minutes: 75
117+
uses: reactivecircus/android-emulator-runner@v2
118+
with:
119+
api-level: 29
120+
force-avd-creation: false
121+
emulator-options: -no-snapshot-save -no-metrics -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
122+
disable-animations: true
123+
arch: ${{ runner.os == 'macOS' && 'arm64-v8a' || 'x86' }}
124+
ndk: ${{ env.NDK_VERSION }}
125+
cmake: 3.22.1
126+
working-directory: apps/test-app
127+
script: |
128+
# Setup port forwarding to Mocha Remote
129+
adb reverse tcp:8090 tcp:8090
130+
# Uninstall the app if already in the snapshot (unlikely but could result in a signature mismatch failure)
131+
adb uninstall com.microsoft.reacttestapp || true
132+
# Build, install and run the app
133+
npm run test:android

0 commit comments

Comments
 (0)