Skip to content

feat: add E2E tests #11

feat: add E2E tests

feat: add E2E tests #11

Workflow file for this run

name: Test React Native Video
permissions:
contents: read
actions: write
on:
push:
branches: [v7]
paths:
- ".github/workflows/tests.yml"
- "example/android/**"
- "**/nitrogen/generated/shared/**"
- "**/nitrogen/generated/android/**"
- "**/nitrogen/generated/ios/**"
- "packages/react-native-video/android/**"
- "packages/react-native-video/ios/**"
- "packages/react-native-video/src/**"
- "**/bun.lock"
- "**/react-native.config.js"
- "**/nitro.json"
- "example/src/tests/**"
- "example/rn-harness.config.mjs"
pull_request:
branches: [v7]
paths:
- ".github/workflows/tests.yml"
- "example/android/**"
- "**/nitrogen/generated/shared/**"
- "**/nitrogen/generated/android/**"
- "**/nitrogen/generated/ios/**"
- "packages/react-native-video/android/**"
- "packages/react-native-video/ios/**"
- "packages/react-native-video/src/**"
- "**/bun.lock"
- "**/react-native.config.js"
- "**/nitro.json"
- "example/src/tests/**"
- "example/rn-harness.config.mjs"
workflow_dispatch:
inputs:
platform:
description: 'Platform to test'
required: false
default: 'all'
type: choice
options:
- all
- android
- ios
jobs:
test-android:
name: Test Android
runs-on: ubuntu-latest
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'android' || github.event.inputs.platform == null }}
steps:
# Step 1: Setup node environment
- uses: actions/checkout@v5
- uses: oven-sh/setup-bun@v2
- name: Install npm dependencies (bun)
run: bun install
# Step 2: Set up JDK
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# Step 3: Build optimization with caching
- name: Restore APK from cache
id: cache-apk-restore
uses: actions/cache/restore@v4
with:
path: example/android/app/build/outputs/apk/debug/app-debug.apk
key: android-app-${{ hashFiles('example/android/**/*.gradle*', 'example/android/**/gradle-wrapper.properties') }}
- name: Build Android app
if: steps.cache-apk-restore.outputs.cache-hit != 'true'
run: |
cd example/android && ./gradlew assembleDebug
- name: Save APK to cache
if: steps.cache-apk-restore.outputs.cache-hit != 'true' && success()
uses: actions/cache/save@v4
with:
path: example/android/app/build/outputs/apk/debug/app-debug.apk
key: android-app-${{ hashFiles('example/android/**/*.gradle*', 'example/android/**/gradle-wrapper.properties') }}
# Step 4: Android Emulator setup with caching
- 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: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-35-2
- 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_7
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."
# Step 5: Run Harness E2E tests
- name: Run Harness E2E tests
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: example/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"
bun test:android
test-ios:
name: Test iOS
runs-on: macos-26
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'ios' || github.event.inputs.platform == null }}
env:
DEVELOPER_DIR: /Applications/Xcode_16.4.0.app/Contents/Developer
steps:
# Step 1: Setup node environment
- uses: actions/checkout@v5
- uses: oven-sh/setup-bun@v2
- name: Install npm dependencies (bun)
run: bun install
- name: Install Watchman
run: brew install watchman
# Step 2: iOS build optimization with caching
- name: Restore app from cache
id: cache-app-restore
uses: actions/cache/restore@v4
with:
path: example/ios/build/Build/Products/Debug-iphonesimulator/VideoExample.app
key: ios-app-${{ hashFiles('example/ios/Podfile.lock', 'example/ios/**/*.pbxproj') }}
- name: CocoaPods cache
if: steps.cache-app-restore.outputs.cache-hit != 'true'
uses: actions/cache@v4
with:
path: |
./example/ios/Pods
~/Library/Caches/CocoaPods
~/.cocoapods
key: pods-${{ runner.os }}-${{ hashFiles('./example/ios/Podfile.lock') }}
- name: Install CocoaPods
if: steps.cache-app-restore.outputs.cache-hit != 'true'
working-directory: example/ios
run: pod install
- name: Install xcpretty
run: gem install xcpretty
- name: Build iOS app
if: steps.cache-app-restore.outputs.cache-hit != 'true'
working-directory: example/ios
run: "set -o pipefail && xcodebuild \
CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \
-derivedDataPath build -UseModernBuildSystem=YES \
-workspace VideoExample.xcworkspace \
-scheme VideoExample \
-sdk iphonesimulator \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 16 Pro,OS=18.6' \
build \
CODE_SIGNING_ALLOWED=NO \
| xcpretty"
- name: Save app to cache
if: steps.cache-app-restore.outputs.cache-hit != 'true' && success()
uses: actions/cache/save@v4
with:
path: example/ios/build/Build/Products/Debug-iphonesimulator/VideoExample.app
key: ios-app-${{ hashFiles('example/ios/Podfile.lock', 'example/ios/**/*.pbxproj') }}
# Step 3: iOS Simulator setup
- name: Set up iOS Simulator
uses: futureware-tech/simulator-action@v4
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 example/ios/build/Build/Products/Debug-iphonesimulator/VideoExample.app
# Step 4: Run Harness tests
- name: Run Harness E2E tests
run: |
bun example test:ios