Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 10 additions & 61 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,54 +108,12 @@ jobs:
path: apps/${{ matrix.app }}/android/app/build/outputs/apk/debug/app-debug.apk
key: apk-${{ matrix.app }}

- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
ls /dev/kvm

- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-35-2

- name: List AVDs
run: |
$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager list device -c

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 35
arch: x86_64
profile: pixel_6
disk-size: 1G
heap-size: 1G
force-avd-creation: false
avd-name: Pixel_8_API_35
disable-animations: true
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: echo "Generated AVD snapshot for caching."

- name: Run E2E tests
uses: reactivecircus/android-emulator-runner@v2
- name: Run React Native Harness
uses: ./actions/android
with:
working-directory: apps/${{ matrix.app }}/android
api-level: 35
arch: x86_64
force-avd-creation: false
avd-name: Pixel_8_API_35
disable-animations: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: |
adb install -r "./app/build/outputs/apk/debug/app-debug.apk"
pnpm nx run @react-native-harness/${{ matrix.app }}:start --args="--harnessRunner android"
app: android/app/build/outputs/apk/debug/app-debug.apk
runner: android
projectRoot: apps/${{ matrix.app }}

e2e-ios:
name: E2E iOS - ${{ matrix.app }}
Expand Down Expand Up @@ -238,21 +196,12 @@ jobs:
path: ./apps/${{ matrix.app }}/ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
key: ios-app-${{ matrix.app }}

- uses: futureware-tech/simulator-action@v4
- name: Run React Native Harness
uses: ./actions/ios
with:
model: 'iPhone 16 Pro'
os: iOS
os_version: 18.6
wait_for_boot: true
erase_before_boot: false

- name: Install app
run: |
xcrun simctl install booted ./apps/${{ matrix.app }}/ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app

- name: Run E2E tests
run: |
HARNESS_DEBUG=true pnpm nx run @react-native-harness/${{ matrix.app }}:start --args="--harnessRunner ios"
app: ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
runner: ios
projectRoot: apps/${{ matrix.app }}

- name: Take screenshot after E2E tests
if: failure()
Expand Down
114 changes: 114 additions & 0 deletions actions/android/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: React Native Harness for Android
description: Run React Native Harness tests on Android
inputs:
app:
description: The path to the Android app (.apk)
required: true
runner:
description: The runner to use
required: true
type: string
projectRoot:
description: The project root directory
required: false
type: string
runs:
using: 'composite'
steps:
- name: Load React Native Harness configuration
id: load-config
shell: bash
env:
INPUT_RUNNER: ${{ inputs.runner }}
INPUT_PROJECTROOT: ${{ inputs.projectRoot }}
run: |
node ${{ github.action_path }}/../shared/index.cjs
- name: Verify Android config
shell: bash
run: |
CONFIG='${{ steps.load-config.outputs.config }}'
if [ -z "$CONFIG.config.device.avd" ] || [ "$CONFIG.config.device.avd" = "null" ]; then
echo "Error: AVD config is required for Android emulators"
echo "Please define the 'avd' property in the runner config"
exit 1
fi
- name: Get architecture of the runner
id: arch
shell: bash
run: |
case "${{ runner.arch }}" in
X64)
echo "arch=x86_64" >> $GITHUB_OUTPUT
;;
ARM64)
echo "arch=arm64-v8a" >> $GITHUB_OUTPUT
;;
ARM32)
echo "arch=armeabi-v7a" >> $GITHUB_OUTPUT
;;
*)
echo "arch=x86_64" >> $GITHUB_OUTPUT
;;
esac
- name: Enable KVM group perms
shell: bash
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
ls /dev/kvm
- name: Compute AVD cache key
id: avd-key
shell: bash
run: |
CONFIG='${{ steps.load-config.outputs.config }}'
AVD_CONFIG=$(echo "$CONFIG" | jq -c '.config.device.avd')
AVD_CONFIG_HASH=$(echo "$AVD_CONFIG" | sha256sum | cut -d' ' -f1)
ARCH="${{ steps.arch.outputs.arch }}"
CACHE_KEY="avd-$ARCH-$AVD_CONFIG_HASH"
echo "key=$CACHE_KEY" >> $GITHUB_OUTPUT
- name: Restore AVD cache
uses: actions/cache/restore@v4
id: avd-cache
with:
path: |
~/.android/avd
~/.android/adb*
key: ${{ steps.avd-key.outputs.key }}
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.apiLevel }}
arch: ${{ steps.arch.outputs.arch }}
profile: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.profile }}
disk-size: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.diskSize }}
heap-size: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.heapSize }}
force-avd-creation: false
avd-name: ${{ fromJson(steps.load-config.outputs.config).config.device.name }}
disable-animations: true
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: echo "Generated AVD snapshot for caching."
- name: Save AVD cache
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
~/.android/avd
~/.android/adb*
key: ${{ steps.avd-key.outputs.key }}
- name: Run E2E tests
id: run-tests
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: ${{ inputs.projectRoot }}
api-level: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.apiLevel }}
arch: ${{ steps.arch.outputs.arch }}
force-avd-creation: false
avd-name: ${{ fromJson(steps.load-config.outputs.config).config.device.name }}
disable-animations: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: |
echo $(pwd)
adb install -r ${{ inputs.app }}
pnpm react-native-harness --harnessRunner ${{ inputs.runner }}
1 change: 1 addition & 0 deletions actions/android/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"use strict";
42 changes: 42 additions & 0 deletions actions/ios/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: React Native Harness for iOS
description: Run React Native Harness tests on iOS
inputs:
app:
description: The path to the iOS app (.app)
required: true
runner:
description: The runner to use
required: true
type: string
projectRoot:
description: The project root directory
required: false
type: string
runs:
using: 'composite'
steps:
- name: Load React Native Harness configuration
id: load-config
shell: bash
env:
INPUT_RUNNER: ${{ inputs.runner }}
INPUT_PROJECTROOT: ${{ inputs.projectRoot }}
run: |
node ${{ github.action_path }}/../shared/index.cjs
- uses: futureware-tech/simulator-action@v4
with:
model: ${{ fromJson(steps.load-config.outputs.config).config.device.name }}
os: iOS
os_version: ${{ fromJson(steps.load-config.outputs.config).config.device.systemVersion }}
wait_for_boot: true
erase_before_boot: false
- name: Install app
shell: bash
working-directory: ${{ inputs.projectRoot }}
run: |
xcrun simctl install booted ${{ inputs.app }}
- name: Run E2E tests
shell: bash
working-directory: ${{ inputs.projectRoot }}
run: |
pnpm react-native-harness --harnessRunner ${{ inputs.runner }}
1 change: 1 addition & 0 deletions actions/ios/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"use strict";
Loading