Skip to content
Open
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
55 changes: 55 additions & 0 deletions .github/workflows/test-harness-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Test Harness Android

on:
pull_request:
paths:
- ".github/workflows/test-harness-android.yml"
- "example/android/**"
- "example/src/tests/**"
- "example/__tests__/**"
- "example/rn-harness.config.mjs"
- "example/jest.config.js"
- "package/cpp/**"
- "package/android/**"
- "**/bun.lock"
- "**/react-native.config.js"
- "**/nitro.json"

env:
TARGET_ANDROID_ARCH: x86_64

jobs:
test:
name: Harness Tests (Android)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: oven-sh/setup-bun@v2

- name: Setup JDK 17
uses: actions/setup-java@v5
with:
distribution: "zulu"
java-version: 17

- 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

- name: Install dependencies (bun)
run: bun install

- name: Run react-native-harness on Android
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 35
arch: x86_64
avd-name: Pixel_8_API_35
working-directory: example/android
script: >-
./gradlew :app:installDebug --no-daemon
-PreactNativeArchitectures=${{ env.TARGET_ANDROID_ARCH }}
&& bun run --cwd .. test:harness:android
115 changes: 115 additions & 0 deletions .github/workflows/test-harness-ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Test Harness iOS

on:
pull_request:
paths:
- ".github/workflows/test-harness-ios.yml"
- "example/ios/**"
- "example/src/tests/**"
- "example/__tests__/**"
- "example/rn-harness.config.mjs"
- "example/jest.config.js"
- "package/cpp/**"
- "package/ios/**"
- "**/Podfile.lock"
- "**/*.podspec"
- "**/react-native.config.js"
- "**/nitro.json"
- "**/bun.lock"

jobs:
test:
name: Harness Tests (iOS)
runs-on: macOS-26
env:
IOS_SIMULATOR_NAME: iPhone 17 Pro
IOS_SIMULATOR_OS: "26.2"

steps:
- uses: actions/checkout@v6
- uses: oven-sh/setup-bun@v2

- name: Install dependencies (bun)
run: bun install

- name: Setup Ruby (bundle)
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.0
bundler-cache: true
working-directory: example

- name: Select Xcode 26.2
run: sudo xcode-select -s "/Applications/Xcode_26.2.app/Contents/Developer"

- name: Install Pods
working-directory: example
run: bun pods

- name: Boot iOS Simulator
run: |
set -euo pipefail

IFS=$'\t' read -r SELECTED_SIMULATOR_UDID SELECTED_SIMULATOR_NAME SELECTED_SIMULATOR_OS <<EOF
$(xcrun simctl list devices available --json | ruby -rjson -e '
devices = JSON.parse(STDIN.read).fetch("devices")
preferred_name = ENV.fetch("IOS_SIMULATOR_NAME")
preferred_os = ENV.fetch("IOS_SIMULATOR_OS")

def os_version(runtime)
runtime.split(".").last.sub(/^iOS-/, "").tr("-", ".")
end

candidates = devices.flat_map do |runtime, runtime_devices|
next [] unless runtime.include?("SimRuntime.iOS")

runtime_devices
.select { |device| device["isAvailable"] }
.map { |device| [runtime, device] }
end

match = candidates.find do |runtime, device|
device["name"] == preferred_name && os_version(runtime) == preferred_os
end
match ||= candidates.find { |_runtime, device| device["name"] == preferred_name }
match ||= candidates.find { |_runtime, device| device["name"].start_with?("iPhone") }

abort("No available iOS simulator found") unless match

runtime, device = match
puts [device["udid"], device["name"], os_version(runtime)].join("\t")
')
EOF

echo "Selected simulator: ${SELECTED_SIMULATOR_NAME} (${SELECTED_SIMULATOR_OS})"
echo "IOS_SIMULATOR_UDID=${SELECTED_SIMULATOR_UDID}" >> "$GITHUB_ENV"
echo "IOS_SIMULATOR_NAME=${SELECTED_SIMULATOR_NAME}" >> "$GITHUB_ENV"
echo "IOS_SIMULATOR_OS=${SELECTED_SIMULATOR_OS}" >> "$GITHUB_ENV"

xcrun simctl boot "${SELECTED_SIMULATOR_UDID}" || true
xcrun simctl bootstatus "${SELECTED_SIMULATOR_UDID}" -b

- name: Build and install debug app
working-directory: example/ios
run: |
set -euo pipefail

APP_PATH="build/Build/Products/Debug-iphonesimulator/NitroSQLiteExample.app"

xcodebuild \
CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \
-derivedDataPath build -UseModernBuildSystem=YES \
-workspace NitroSQLiteExample.xcworkspace \
-scheme NitroSQLiteExample \
-sdk iphonesimulator \
-configuration Debug \
-destination "platform=iOS Simulator,id=${IOS_SIMULATOR_UDID}" \
ONLY_ACTIVE_ARCH=YES \
build \
CODE_SIGNING_ALLOWED=NO

xcrun simctl install "${IOS_SIMULATOR_UDID}" "${APP_PATH}"
xcrun simctl appinfo "${IOS_SIMULATOR_UDID}" "com.margelo.rnnitrosqlite.example" > /dev/null

- name: Run react-native-harness on iOS
run: bun run --cwd example test:harness:ios
Loading
Loading