Skip to content
Closed
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
86 changes: 86 additions & 0 deletions .github/actions/android-emulator/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: 'Android Emulator'
description: 'Boot an Android emulator using reactivecircus/android-emulator-runner and run a script while it is active.'
inputs:
api-level:
description: 'Android API level to use.'
required: false
default: '30'
target:
description: 'System image target (for example: default or google_apis).'
required: false
default: 'default'
arch:
description: 'CPU architecture of the system image.'
required: false
default: 'x86_64'
profile:
description: 'Emulator profile to use.'
required: false
default: 'pixel_5'
avd-name:
description: 'Name for the AVD.'
required: false
default: 'ci_avd'
force-avd-creation:
description: 'Force AVD creation even if it already exists.'
required: false
default: 'true'
disable-animations:
description: 'Disable emulator animations to improve test stability.'
required: false
default: 'true'
emulator-options:
description: 'Additional emulator launch options.'
required: false
default: '-no-snapshot -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -memory 4096'
emulator-boot-timeout:
description: 'Timeout in seconds for emulator boot.'
required: false
default: '600'
pre-emulator-launch-script:
description: 'Commands to run before launching the emulator.'
required: false
default: ''
post-emulator-launch-script:
description: 'Commands to run after the emulator has been launched but before the main script.'
required: false
default: 'adb wait-for-device shell "while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;"'
working-directory:
description: 'Working directory for the script.'
required: false
default: '.'
script:
description: 'Shell commands to execute while the emulator is running.'
required: true
runs:
using: 'composite'
steps:
- name: Enable KVM group perms
if: runner.os == 'Linux'
shell: bash
run: |
set -euxo pipefail
if [[ -e /dev/kvm ]]; then
echo 'Configuring KVM permissions for hardware acceleration.'
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
else
echo '::warning::/dev/kvm not found. Emulator will run without hardware acceleration.'
fi
- name: Run commands on Android emulator
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ inputs.api-level }}
target: ${{ inputs.target }}
arch: ${{ inputs.arch }}
profile: ${{ inputs.profile }}
avd-name: ${{ inputs.avd-name }}
force-avd-creation: ${{ inputs.force-avd-creation }}
disable-animations: ${{ inputs.disable-animations }}
emulator-options: ${{ inputs.emulator-options }}
emulator-boot-timeout: ${{ inputs.emulator-boot-timeout }}
pre-emulator-launch-script: ${{ inputs.pre-emulator-launch-script }}
post-emulator-launch-script: ${{ inputs.post-emulator-launch-script }}
working-directory: ${{ inputs.working-directory }}
script: ${{ inputs.script }}
70 changes: 36 additions & 34 deletions .github/workflows/ci-graphite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ jobs:

test-android-graphite:
needs: build-android-graphite
runs-on: macos-latest-large
runs-on: ubuntu-latest
timeout-minutes: 60
env:
TURBO_CACHE_DIR: .turbo/android
Expand All @@ -196,46 +196,48 @@ jobs:
with:
path: apps/example/android/app/build/outputs/apk/debug/app-debug.apk
key: apk-${{ github.sha }}

- name: SKDs - download required images
run: $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "system-images;android-30;default;x86_64"

- name: Emulator - Create
run: $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n Pixel_API_30 --device 'Nexus 5X' --package "system-images;android-30;default;x86_64" --sdcard 512M

- name: Emulator - Boot
run: $ANDROID_HOME/emulator/emulator -memory 4096 -avd Pixel_API_30 -wipe-data -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim &

- name: ADB Wait For Device
run: adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
timeout-minutes: 10

- name: Start Package Manager
working-directory: apps/example/
run: E2E=true yarn start &

- name: Check APK existence
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
with:
files: apps/example/android/app/build/outputs/apk/debug/app-debug.apk
fail: true

- name: Install APK
run: adb install -r apps/example/android/app/build/outputs/apk/debug/app-debug.apk

# - name: Set up environment
# run: echo "PACKAGE_NAME=${{ env.PACKAGE_NAME }}" >> $GITHUB_ENV
- name: Launch APK
env:
PACKAGE_NAME: 'com.microsoft.reacttestapp'
run: adb shell monkey -p ${{ env.PACKAGE_NAME }} 1

# On fabric, the system fonts are slightly different
# so wont run the paragraph tests there for now
- name: Run e2e Tests
working-directory: packages/skia
run: |
CI=true E2E=true yarn test -i Paths --testPathIgnorePatterns Paragraphs
- name: Run Android tests
uses: ./.github/actions/android-emulator
with:
api-level: '30'
target: 'default'
arch: 'x86_64'
profile: 'Nexus 5X'
avd-name: 'Pixel_API_30'
emulator-options: '-no-snapshot -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -memory 4096'
script: |
set -euxo pipefail

PACKAGE_NAME='com.microsoft.reacttestapp'
APK_PATH='apps/example/android/app/build/outputs/apk/debug/app-debug.apk'

test -f "${APK_PATH}"

pushd apps/example
E2E=true yarn start &
METRO_PID=$!
popd

cleanup() {
kill "${METRO_PID}" 2>/dev/null || true
}
trap cleanup EXIT

sleep 25

adb install -r "${APK_PATH}"
adb shell monkey -p "${PACKAGE_NAME}" 1

pushd packages/skia
CI=true E2E=true yarn test -i Paths --testPathIgnorePatterns Paragraphs
popd

- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: failure()
Expand Down
68 changes: 36 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ jobs:

test-android:
needs: build-android
runs-on: macos-latest-large
runs-on: ubuntu-latest
timeout-minutes: 60
env:
TURBO_CACHE_DIR: .turbo/android
Expand All @@ -287,46 +287,50 @@ jobs:
with:
path: apps/example/android/app/build/outputs/apk/debug/app-debug.apk
key: apk-${{ github.sha }}

- name: SKDs - download required images
run: $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "system-images;android-30;default;x86_64"

- name: Emulator - Create
run: $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n Pixel_API_30 --device 'Nexus 5X' --package "system-images;android-30;default;x86_64" --sdcard 512M

- name: Emulator - Boot
run: $ANDROID_HOME/emulator/emulator -memory 4096 -avd Pixel_API_30 -wipe-data -no-window -gpu angle_indirect -no-snapshot -noaudio -no-boot-anim &

- name: ADB Wait For Device
run: adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
timeout-minutes: 10

- name: Start Package Manager
working-directory: apps/example/
run: E2E=true yarn start &

- name: Check APK existence
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
with:
files: apps/example/android/app/build/outputs/apk/debug/app-debug.apk
fail: true

- name: Install APK
run: adb install -r apps/example/android/app/build/outputs/apk/debug/app-debug.apk
- name: Run Android tests
uses: ./.github/actions/android-emulator
with:
api-level: '30'
target: 'default'
arch: 'x86_64'
profile: 'Nexus 5X'
avd-name: 'Pixel_API_30'
emulator-options: '-no-snapshot -no-window -gpu angle_indirect -noaudio -no-boot-anim -memory 4096'
script: |
set -euxo pipefail

# - name: Set up environment
# run: echo "PACKAGE_NAME=${{ env.PACKAGE_NAME }}" >> $GITHUB_ENV
- name: Launch APK
env:
PACKAGE_NAME: 'com.microsoft.reacttestapp'
run: adb shell monkey -p ${{ env.PACKAGE_NAME }} 1
PACKAGE_NAME='com.microsoft.reacttestapp'
APK_PATH='apps/example/android/app/build/outputs/apk/debug/app-debug.apk'

# On fabric, the system fonts are slightly different
# so wont run the paragraph tests there for now
- name: Run e2e Tests
working-directory: packages/skia
run: |
CI=true yarn e2e --testPathIgnorePatterns Paragraphs
test -f "${APK_PATH}"

# Start the Metro bundler for E2E tests.
pushd apps/example
E2E=true yarn start &
METRO_PID=$!
popd

cleanup() {
kill "${METRO_PID}" 2>/dev/null || true
}
trap cleanup EXIT

# Give Metro a moment to start accepting connections.
sleep 25

adb install -r "${APK_PATH}"
adb shell monkey -p "${PACKAGE_NAME}" 1

pushd packages/skia
CI=true yarn e2e --testPathIgnorePatterns Paragraphs
popd

- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: failure()
Expand Down
Loading
Loading