Skip to content

Commit 52faabc

Browse files
committed
chore
1 parent 40a21af commit 52faabc

File tree

36 files changed

+25603
-209
lines changed

36 files changed

+25603
-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: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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: Get architecture of the runner
24+
id: arch
25+
shell: bash
26+
run: |
27+
case "${{ runner.arch }}" in
28+
X64)
29+
echo "arch=x86_64" >> $GITHUB_OUTPUT
30+
;;
31+
ARM64)
32+
echo "arch=arm64-v8a" >> $GITHUB_OUTPUT
33+
;;
34+
ARM32)
35+
echo "arch=armeabi-v7a" >> $GITHUB_OUTPUT
36+
;;
37+
*)
38+
echo "arch=x86_64" >> $GITHUB_OUTPUT
39+
;;
40+
esac
41+
- name: Enable KVM group perms
42+
shell: bash
43+
run: |
44+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
45+
sudo udevadm control --reload-rules
46+
sudo udevadm trigger --name-match=kvm
47+
ls /dev/kvm
48+
- name: Compute AVD cache key
49+
id: avd-key
50+
shell: bash
51+
run: |
52+
CONFIG='${{ steps.load-config.outputs.config }}'
53+
AVD_CONFIG=$(echo "$CONFIG" | jq -c '.config.device.avd')
54+
AVD_CONFIG_HASH=$(echo "$AVD_CONFIG" | sha256sum | cut -d' ' -f1)
55+
ARCH="${{ steps.arch.outputs.arch }}"
56+
CACHE_KEY="avd-$ARCH-$AVD_CONFIG_HASH"
57+
echo "key=$CACHE_KEY" >> $GITHUB_OUTPUT
58+
- name: Restore AVD cache
59+
uses: actions/cache/restore@v4
60+
id: avd-cache
61+
with:
62+
path: |
63+
~/.android/avd
64+
~/.android/adb*
65+
key: ${{ steps.avd-key.outputs.key }}
66+
- name: Create AVD and generate snapshot for caching
67+
if: steps.avd-cache.outputs.cache-hit != 'true'
68+
uses: reactivecircus/android-emulator-runner@v2
69+
with:
70+
api-level: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.apiLevel }}
71+
arch: ${{ steps.arch.outputs.arch }}
72+
profile: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.profile }}
73+
disk-size: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.diskSize }}
74+
heap-size: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.heapSize }}
75+
force-avd-creation: false
76+
avd-name: ${{ fromJson(steps.load-config.outputs.config).config.device.name }}
77+
disable-animations: true
78+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
79+
script: echo "Generated AVD snapshot for caching."
80+
- name: Save AVD cache
81+
if: steps.avd-cache.outputs.cache-hit != 'true'
82+
uses: actions/cache/save@v4
83+
with:
84+
path: |
85+
~/.android/avd
86+
~/.android/adb*
87+
key: ${{ steps.avd-key.outputs.key }}
88+
- name: Run E2E tests
89+
id: run-tests
90+
uses: reactivecircus/android-emulator-runner@v2
91+
with:
92+
working-directory: ${{ inputs.projectRoot }}
93+
api-level: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.apiLevel }}
94+
arch: ${{ steps.arch.outputs.arch }}
95+
force-avd-creation: false
96+
avd-name: ${{ fromJson(steps.load-config.outputs.config).config.device.name }}
97+
disable-animations: true
98+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
99+
script: |
100+
echo $(pwd)
101+
adb install -r ${{ inputs.app }}
102+
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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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: ${{ inputs.runner.device.name }}
26+
os: iOS
27+
os_version: ${{ inputs.runner.device.systemVersion }}
28+
wait_for_boot: true
29+
erase_before_boot: false
30+
- name: Install app
31+
working-directory: ${{ inputs.projectRoot }}
32+
run: |
33+
xcrun simctl install booted ${{ inputs.app }}
34+
- name: Run E2E tests
35+
working-directory: ${{ inputs.projectRoot }}
36+
run: |
37+
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)