Skip to content

Commit

Permalink
[ci] use ubuntu runner to launch android emulator (#27450)
Browse files Browse the repository at this point in the history
# Why

since the new github linux runner for open source repo supports nested
virtualization, it's a good time to try out using ubuntu runner to
launch android emulator without blocking macos runners.

# How

- use ubuntu runner to run android emulator.
- setup kvm according to [android-emulator-runner
doc](https://github.com/ReactiveCircus/android-emulator-runner/blob/main/README.md#running-hardware-accelerated-emulators-on-linux-runners)
- clean up more disk space because i've seen running out disk space
sometimes
  • Loading branch information
Kudo committed Mar 6, 2024
1 parent 18c0fb3 commit 9d377aa
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/actions/cleanup-linux-disk-space/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ runs:
run: |
echo 'Disk space before cleanup'
df -aH
sudo apt-get remove -y --purge '^mysql-.*' '^mongodb-.*' '^postgresql-.*' '^aspnetcore-*' '^dotnet-.*' '^php.*-.*' 'mono-complete'
sudo apt-get remove -y --purge '^mysql-.*' '^mongodb-.*' '^mssql-.*' '^postgresql-.*' '^aspnetcore-*' '^dotnet-.*' '^php.*-.*' 'mono-complete' '^llvm-.*' 'powershell' 'google-chrome-*' 'microsoft-edge-*' 'firefox' 'nginx' 'apache2'
sudo apt-get autoremove -y
sudo rm -rf /usr/share/dotnet
echo 'Showing Android SDKs'
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --list
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --uninstall 'ndk;24.0.8215888' 'ndk;25.2.9519653'
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --uninstall 'ndk;24.0.8215888' 'ndk;25.2.9519653' 'ndk;26.2.11394342'
echo 'Removing all Docker images'
docker rmi -f $(docker images -aq)
echo 'Disk space after cleanup'
Expand Down
25 changes: 7 additions & 18 deletions .github/actions/use-android-emulator/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ outputs:
runs:
using: 'composite'
steps:
- name: ⚙️ Enable KVM for Android virtualization
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
# NOTE: When updating any emulator settings, please make sure all the settings are also updated in each retry step.
# Sorry that we can't use a loop here, because GitHub Actions doesn't support it yet.
- name: '💿 Setup Android Emulator #1'
Expand All @@ -37,13 +44,7 @@ runs:
avd-name: ${{ inputs.avd-name }}
arch: x86_64
target: google_apis
emulator-build: 9536276
emulator-options: -no-snapshot -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none
emulator-boot-timeout: 900
profile: pixel_6
ram-size: 8192MB
disk-size: 8192MB
heap-size: 2048MB
script: |
# Wait for emulator to fully ready
sleep 20
Expand All @@ -67,13 +68,7 @@ runs:
avd-name: ${{ inputs.avd-name }}
arch: x86_64
target: google_apis
emulator-build: 9536276
emulator-options: -no-snapshot -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none
emulator-boot-timeout: 900
profile: pixel_6
ram-size: 8192MB
disk-size: 8192MB
heap-size: 2048MB
script: |
# Wait for emulator to fully ready
sleep 20
Expand All @@ -97,13 +92,7 @@ runs:
avd-name: ${{ inputs.avd-name }}
arch: x86_64
target: google_apis
emulator-build: 9536276
emulator-options: -no-snapshot -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none
emulator-boot-timeout: 900
profile: pixel_6
ram-size: 8192MB
disk-size: 8192MB
heap-size: 2048MB
script: |
# Wait for emulator to fully ready
sleep 20
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/android-instrumentation-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ concurrency:

jobs:
test:
runs-on: macos-13
runs-on: ubuntu-22.04
timeout-minutes: 150
env:
ORG_GRADLE_PROJECT_reactNativeArchitectures: x86_64
Expand All @@ -53,6 +53,8 @@ jobs:
uses: actions/checkout@v4
with:
submodules: true
- name: 🧹 Cleanup GitHub Linux runner disk space
uses: ./.github/actions/cleanup-linux-disk-space
- name: 🔨 Use JDK 17
uses: actions/setup-java@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/development-client-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ concurrency:

jobs:
detox_e2e:
runs-on: macos-13
runs-on: ubuntu-22.04
strategy:
matrix:
api-level: [33]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/development-client-latest-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:

jobs:
detox_latest_e2e:
runs-on: macos-13
runs-on: ubuntu-22.04
strategy:
matrix:
api-level: [33]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-suite-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ jobs:

android-test:
needs: android-build
runs-on: macos-13
runs-on: ubuntu-22.04
strategy:
matrix:
api-level: [33]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ jobs:

android-test:
needs: android-build
runs-on: macos-13
runs-on: ubuntu-22.04
strategy:
matrix:
api-level: [33]
Expand Down

0 comments on commit 9d377aa

Please sign in to comment.