Skip to content

Commit 8cdebf4

Browse files
committed
chore
1 parent 40a21af commit 8cdebf4

File tree

36 files changed

+25625
-209
lines changed

36 files changed

+25625
-209
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 10 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -108,54 +108,12 @@ jobs:
108108
path: apps/${{ matrix.app }}/android/app/build/outputs/apk/debug/app-debug.apk
109109
key: apk-${{ matrix.app }}
110110

111-
- name: Enable KVM group perms
112-
run: |
113-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
114-
sudo udevadm control --reload-rules
115-
sudo udevadm trigger --name-match=kvm
116-
ls /dev/kvm
117-
118-
- name: AVD cache
119-
uses: actions/cache@v4
120-
id: avd-cache
121-
with:
122-
path: |
123-
~/.android/avd/*
124-
~/.android/adb*
125-
key: avd-35-2
126-
127-
- name: List AVDs
128-
run: |
129-
$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager list device -c
130-
131-
- name: Create AVD and generate snapshot for caching
132-
if: steps.avd-cache.outputs.cache-hit != 'true'
133-
uses: reactivecircus/android-emulator-runner@v2
134-
with:
135-
api-level: 35
136-
arch: x86_64
137-
profile: pixel_6
138-
disk-size: 1G
139-
heap-size: 1G
140-
force-avd-creation: false
141-
avd-name: Pixel_8_API_35
142-
disable-animations: true
143-
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
144-
script: echo "Generated AVD snapshot for caching."
145-
146-
- name: Run E2E tests
147-
uses: reactivecircus/android-emulator-runner@v2
111+
- name: Run React Native Harness
112+
uses: ./packages/github-action/dist/android
148113
with:
149-
working-directory: apps/${{ matrix.app }}/android
150-
api-level: 35
151-
arch: x86_64
152-
force-avd-creation: false
153-
avd-name: Pixel_8_API_35
154-
disable-animations: true
155-
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
156-
script: |
157-
adb install -r "./app/build/outputs/apk/debug/app-debug.apk"
158-
pnpm nx run @react-native-harness/${{ matrix.app }}:start --args="--harnessRunner android"
114+
app: android/app/build/outputs/apk/debug/app-debug.apk
115+
runner: android
116+
projectRoot: apps/${{ matrix.app }}
159117

160118
e2e-ios:
161119
name: E2E iOS - ${{ matrix.app }}
@@ -238,21 +196,12 @@ jobs:
238196
path: ./apps/${{ matrix.app }}/ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
239197
key: ios-app-${{ matrix.app }}
240198

241-
- uses: futureware-tech/simulator-action@v4
199+
- name: Run React Native Harness
200+
uses: ./packages/github-action/dist/ios
242201
with:
243-
model: 'iPhone 16 Pro'
244-
os: iOS
245-
os_version: 18.6
246-
wait_for_boot: true
247-
erase_before_boot: false
248-
249-
- name: Install app
250-
run: |
251-
xcrun simctl install booted ./apps/${{ matrix.app }}/ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
252-
253-
- name: Run E2E tests
254-
run: |
255-
HARNESS_DEBUG=true pnpm nx run @react-native-harness/${{ matrix.app }}:start --args="--harnessRunner ios"
202+
app: ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
203+
runner: ios
204+
projectRoot: apps/${{ matrix.app }}
256205

257206
- name: Take screenshot after E2E tests
258207
if: failure()

apps/playground/project.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
"name": "@react-native-harness/playground",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
24
"targets": {
35
"start": {
46
"executor": "nx:run-commands",

apps/playground/rn-harness.config.mjs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ const config = {
2020
runners: [
2121
androidPlatform({
2222
name: 'android',
23-
device: androidEmulator('Pixel_8_API_35'),
23+
device: androidEmulator('Pixel_8_API_35', {
24+
apiLevel: 35,
25+
profile: 'pixel_6',
26+
diskSize: '1G',
27+
heapSize: '1G',
28+
}),
2429
bundleId: 'com.harnessplayground',
2530
}),
2631
androidPlatform({
@@ -35,8 +40,8 @@ const config = {
3540
}),
3641
applePlatform({
3742
name: 'ios',
38-
device: appleSimulator('iPhone 16 Pro', '18.6'),
39-
bundleId: 'org.reactjs.native.example.Playground',
43+
device: appleSimulator('iPhone 16 Pro', '26.0'),
44+
bundleId: 'com.harnessplayground',
4045
}),
4146
vegaPlatform({
4247
name: 'vega',

packages/github-action/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Needed to use the action in the workflow
2+
!dist
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: React Native Harness for Android
2+
description: Run React Native Harness tests on Android
3+
inputs:
4+
app:
5+
description: The path to the Android app (.apk)
6+
required: true
7+
runner:
8+
description: The runner to use
9+
required: true
10+
type: string
11+
projectRoot:
12+
description: The project root directory
13+
required: false
14+
type: string
15+
runs:
16+
using: 'composite'
17+
steps:
18+
- uses: 'callstackincubator/react-native-harness/packages/github-action/dist/load-config@feat/github-action'
19+
id: load-config
20+
with:
21+
runner: ${{ inputs.runner }}
22+
projectRoot: ${{ inputs.projectRoot }}
23+
- name: Verify Android config
24+
shell: bash
25+
run: |
26+
CONFIG='${{ steps.load-config.outputs.config }}'
27+
if [ -z "$CONFIG.config.device.avd" ] || [ "$CONFIG.config.device.avd" = "null" ]; then
28+
echo "Error: AVD config is required for Android emulators"
29+
echo "Please define the 'avd' property in the runner config"
30+
exit 1
31+
fi
32+
- name: Get architecture of the runner
33+
id: arch
34+
shell: bash
35+
run: |
36+
case "${{ runner.arch }}" in
37+
X64)
38+
echo "arch=x86_64" >> $GITHUB_OUTPUT
39+
;;
40+
ARM64)
41+
echo "arch=arm64-v8a" >> $GITHUB_OUTPUT
42+
;;
43+
ARM32)
44+
echo "arch=armeabi-v7a" >> $GITHUB_OUTPUT
45+
;;
46+
*)
47+
echo "arch=x86_64" >> $GITHUB_OUTPUT
48+
;;
49+
esac
50+
- name: Enable KVM group perms
51+
shell: bash
52+
run: |
53+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
54+
sudo udevadm control --reload-rules
55+
sudo udevadm trigger --name-match=kvm
56+
ls /dev/kvm
57+
- name: Compute AVD cache key
58+
id: avd-key
59+
shell: bash
60+
run: |
61+
CONFIG='${{ steps.load-config.outputs.config }}'
62+
AVD_CONFIG=$(echo "$CONFIG" | jq -c '.config.device.avd')
63+
AVD_CONFIG_HASH=$(echo "$AVD_CONFIG" | sha256sum | cut -d' ' -f1)
64+
ARCH="${{ steps.arch.outputs.arch }}"
65+
CACHE_KEY="avd-$ARCH-$AVD_CONFIG_HASH"
66+
echo "key=$CACHE_KEY" >> $GITHUB_OUTPUT
67+
- name: Restore AVD cache
68+
uses: actions/cache/restore@v4
69+
id: avd-cache
70+
with:
71+
path: |
72+
~/.android/avd
73+
~/.android/adb*
74+
key: ${{ steps.avd-key.outputs.key }}
75+
- name: Create AVD and generate snapshot for caching
76+
if: steps.avd-cache.outputs.cache-hit != 'true'
77+
uses: reactivecircus/android-emulator-runner@v2
78+
with:
79+
api-level: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.apiLevel }}
80+
arch: ${{ steps.arch.outputs.arch }}
81+
profile: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.profile }}
82+
disk-size: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.diskSize }}
83+
heap-size: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.heapSize }}
84+
force-avd-creation: false
85+
avd-name: ${{ fromJson(steps.load-config.outputs.config).config.device.name }}
86+
disable-animations: true
87+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
88+
script: echo "Generated AVD snapshot for caching."
89+
- name: Save AVD cache
90+
if: steps.avd-cache.outputs.cache-hit != 'true'
91+
uses: actions/cache/save@v4
92+
with:
93+
path: |
94+
~/.android/avd
95+
~/.android/adb*
96+
key: ${{ steps.avd-key.outputs.key }}
97+
- name: Run E2E tests
98+
id: run-tests
99+
uses: reactivecircus/android-emulator-runner@v2
100+
with:
101+
working-directory: ${{ inputs.projectRoot }}
102+
api-level: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.apiLevel }}
103+
arch: ${{ steps.arch.outputs.arch }}
104+
force-avd-creation: false
105+
avd-name: ${{ fromJson(steps.load-config.outputs.config).config.device.name }}
106+
disable-animations: true
107+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
108+
script: |
109+
echo $(pwd)
110+
adb install -r ${{ inputs.app }}
111+
pnpm react-native-harness --harnessRunner ${{ inputs.runner }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"use strict";
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: React Native Harness for iOS
2+
description: Run React Native Harness tests on iOS
3+
inputs:
4+
app:
5+
description: The path to the iOS app (.app)
6+
required: true
7+
runner:
8+
description: The runner to use
9+
required: true
10+
type: string
11+
projectRoot:
12+
description: The project root directory
13+
required: false
14+
type: string
15+
runs:
16+
using: 'composite'
17+
steps:
18+
- uses: 'callstackincubator/react-native-harness/packages/github-action/dist/load-config@feat/github-action'
19+
id: load-config
20+
with:
21+
runner: ${{ inputs.runner }}
22+
projectRoot: ${{ inputs.projectRoot }}
23+
- uses: futureware-tech/simulator-action@v4
24+
with:
25+
model: ${{ fromJson(steps.load-config.outputs.config).config.device.name }}
26+
os: iOS
27+
os_version: ${{ fromJson(steps.load-config.outputs.config).config.device.systemVersion }}
28+
wait_for_boot: true
29+
erase_before_boot: false
30+
- name: Install app
31+
shell: bash
32+
working-directory: ${{ inputs.projectRoot }}
33+
run: |
34+
xcrun simctl install booted ${{ inputs.app }}
35+
- name: Run E2E tests
36+
shell: bash
37+
working-directory: ${{ inputs.projectRoot }}
38+
run: |
39+
pnpm react-native-harness --harnessRunner ${{ inputs.runner }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"use strict";
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Load React Native Harness configuration
2+
inputs:
3+
runner:
4+
description: The runner to use
5+
required: true
6+
type: string
7+
projectRoot:
8+
description: The project root directory
9+
required: false
10+
type: string
11+
outputs:
12+
config:
13+
description: The entire React Native Harness configuration as JSON
14+
runs:
15+
using: 'node20'
16+
main: './index.cjs'

0 commit comments

Comments
 (0)