You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nowinandroid/.github/workflows/Build.yaml

81 lines
2.8 KiB

name: Benchmark on Emulator
on:
push:
branches: [testNIA]
jobs:
benchmark-android:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
cache: 'gradle'
# 1. CRITICAL: Free up disk space.
# API 30+ emulators need ~10GB. Standard runners are often too full.
- name: Free Disk Space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
# 2. CRITICAL: Enable KVM group permissions
# This ensures the emulator can actually use the CPU's virtualization features.
- name: Enable KVM
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: Build Benchmark APKs
run: |
./gradlew :app:assembleDemoBenchmark :benchmarks:assembleDemoBenchmark
- name: Run Benchmarks & Record Video
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 31 # API 31 is lighter and boots faster than 33/35
target: google_apis
arch: x86_64
force-avd-creation: true # Resetting AVD to ensure no corrupted cache
# Added -accel on and -memory to ensure it has enough power to boot
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -accel on -memory 3072
disable-animations: true
script: |
# 1. Wait for boot to be REALLY finished
adb wait-for-device
# 2. Start recording
echo "Starting video recording..."
adb shell screenrecord --time-limit 180 /sdcard/benchmark_video.mp4 &
# 3. Run the tests
echo "Running Macrobenchmarks..."
./gradlew :benchmarks:connectedDemoBenchmarkAndroidTest \
-Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.suppressErrors=EMULATOR
# 4. Finalize
echo "Pulling video..."
sleep 2
adb shell pkill -2 screenrecord || true
sleep 5
adb pull /sdcard/benchmark_video.mp4 benchmark_video.mp4
- name: Upload Artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: |
benchmark_video.mp4
benchmarks/build/outputs/connected_android_test_additional_output/