Skip to content

Commit eaf4c24

Browse files
committed
Merge branch 'main' into release/v2
* main: Prepare for release 2.30.0. Node 20. (#369) Add another user: robolectric/robolectric (#352) Promote using ubuntu runner with KVM. (#366)
2 parents 99a4aac + 426fbd2 commit eaf4c24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1445
-1278
lines changed

.github/workflows/main.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,34 @@ jobs:
1818
timeout-minutes: 15
1919
strategy:
2020
matrix:
21-
os: [macos-latest, ubuntu-latest]
21+
os: [ubuntu-latest]
2222
api-level: [23, 29]
2323
target: [default, google_apis]
2424
arch: [x86]
2525
exclude:
26-
- os: ubuntu-latest
27-
api-level: 23
28-
- os: ubuntu-latest
29-
api-level: 29
3026
- target: google_apis
3127
api-level: 16
3228
- target: google_apis
3329
api-level: 23
3430
- target: google_apis
3531
api-level: 29
3632
include:
37-
- os: macos-latest
33+
- os: ubuntu-latest
3834
api-level: 24
3935
target: playstore
4036
arch: x86
41-
- os: macos-latest
37+
- os: ubuntu-latest
4238
api-level: 30
4339
target: aosp_atd
4440
arch: x86
45-
- os: macos-11
41+
- os: macos-latest
4642
api-level: 31
4743
target: google_apis
4844
arch: x86_64
45+
- os: ubuntu-latest
46+
api-level: 34
47+
target: aosp_atd
48+
arch: x86_64
4949

5050
steps:
5151
- name: checkout
@@ -64,7 +64,7 @@ jobs:
6464
- uses: actions/setup-java@v3
6565
with:
6666
distribution: 'zulu'
67-
java-version: 19
67+
java-version: 21
6868

6969
- uses: actions/cache@v3
7070
id: avd-cache
@@ -81,6 +81,13 @@ jobs:
8181
build-root-directory: test-fixture
8282
arguments: assembleAndroidTest
8383

84+
- name: enable KVM for linux runners
85+
if: runner.os == 'Linux'
86+
run: |
87+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
88+
sudo udevadm control --reload-rules
89+
sudo udevadm trigger --name-match=kvm
90+
8491
- name: run emulator to generate snapshot for caching
8592
if: steps.avd-cache.outputs.cache-hit != 'true'
8693
uses: ./

.github/workflows/manually.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
os:
66
description: 'OS'
77
required: true
8-
default: 'macos-latest'
8+
default: 'ubuntu-latest'
99
api-level:
1010
description: 'API level of the platform and system image'
1111
required: true
@@ -54,12 +54,19 @@ jobs:
5454
- uses: actions/setup-java@v3
5555
with:
5656
distribution: 'zulu'
57-
java-version: 19
57+
java-version: 21
5858

5959
- uses: gradle/gradle-build-action@v2
6060
with:
6161
gradle-home-cache-cleanup: true
6262

63+
- name: enable KVM for linux runners
64+
if: runner.os == 'Linux'
65+
run: |
66+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
67+
sudo udevadm control --reload-rules
68+
sudo udevadm trigger --name-match=kvm
69+
6370
- name: run action
6471
uses: ./
6572
with:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## v2.30.0
4+
5+
* Update to Node 20. - [#369](https://github.com/ReactiveCircus/android-emulator-runner/pull/369)
6+
37
## v2.29.0
48

59
* Fixed emulator download URL. - [#343](https://github.com/ReactiveCircus/android-emulator-runner/pull/343)

README.md

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,24 @@
44
<a href="https://github.com/ReactiveCircus/android-emulator-runner"><img alt="GitHub Actions status" src="https://github.com/ReactiveCircus/android-emulator-runner/workflows/Main%20workflow/badge.svg"></a>
55
</p>
66

7-
A GitHub Action for installing, configuring and running hardware-accelerated Android Emulators on macOS virtual machines.
7+
A GitHub Action for installing, configuring and running hardware-accelerated Android Emulators on Linux and macOS virtual machines.
88

99
The old ARM-based emulators were slow and are no longer supported by Google. The modern Intel Atom (x86 and x86_64) emulators can be fast, but rely on two forms of hardware acceleration to reach their peak potential: [Graphics Acceleration](https://developer.android.com/studio/run/emulator-acceleration#accel-graphics), e.g. `emulator -gpu host` and [Virtual Machine(VM) Acceleration](https://developer.android.com/studio/run/emulator-acceleration#accel-vm), e.g. `emulator -accel on`. **Note:** GPU and VM Acceleration are two different and non-mutually exclusive forms of Hardware Acceleration.
1010

1111
This presents a challenge when running emulators on CI especially when running emulators within a docker container, because **Nested Virtualization** must be supported by the host VM which isn't the case for most cloud-based CI providers due to infrastructural limits. If you want to learn more about Emulators on CI, here's an article [Yang](https://github.com/ychescale9) wrote: [Running Android Instrumented Tests on CI](https://dev.to/ychescale9/running-android-emulators-on-ci-from-bitrise-io-to-github-actions-3j76).
1212

13+
## Running hardware accelerated emulators on Linux runners
14+
15+
GitHub's [larger Linux runners support running hardware accelerated emulators](https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/) which is [free for public GitHub repos](https://github.blog/2024-01-17-github-hosted-runners-double-the-power-for-open-source/). It is now recommended to use the **Ubuntu** (`ubuntu-latest`) runners which are 2-3 times faster than the **macOS** ones which are also a lot more expensive. Remember to enable KVM in your workflow before running this action:
16+
17+
```
18+
- name: Enable KVM group perms
19+
run: |
20+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
21+
sudo udevadm control --reload-rules
22+
sudo udevadm trigger --name-match=kvm
23+
```
24+
1325
## A note on VM Acceleration and why we don't need HAXM anymore
1426

1527
According to [this documentation](https://developer.android.com/studio/run/emulator-acceleration#vm-mac), "on Mac OS X v10.10 Yosemite and higher, the Android Emulator uses the built-in [Hypervisor.Framework](https://developer.apple.com/documentation/hypervisor) by default, and falls back to using Intel HAXM if Hypervisor.Framework fails to initialize." This means that **HAXM is only needed to achieve VM Acceleration if this default Hypervisor is not available on macOS machines.**
@@ -34,11 +46,17 @@ A workflow that uses **android-emulator-runner** to run your instrumented tests
3446
```yml
3547
jobs:
3648
test:
37-
runs-on: macos-latest
49+
runs-on: ubuntu-latest
3850
steps:
3951
- name: checkout
4052
uses: actions/checkout@v3
4153

54+
- name: Enable KVM
55+
run: |
56+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
57+
sudo udevadm control --reload-rules
58+
sudo udevadm trigger --name-match=kvm
59+
4260
- name: run tests
4361
uses: reactivecircus/android-emulator-runner@v2
4462
with:
@@ -51,7 +69,7 @@ We can also leverage GitHub Actions's build matrix to test across multiple confi
5169
```yml
5270
jobs:
5371
test:
54-
runs-on: macos-latest
72+
runs-on: ubuntu-latest
5573
strategy:
5674
matrix:
5775
api-level: [21, 23, 29]
@@ -60,6 +78,12 @@ jobs:
6078
- name: checkout
6179
uses: actions/checkout@v3
6280

81+
- name: Enable KVM
82+
run: |
83+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
84+
sudo udevadm control --reload-rules
85+
sudo udevadm trigger --name-match=kvm
86+
6387
- name: run tests
6488
uses: reactivecircus/android-emulator-runner@v2
6589
with:
@@ -75,11 +99,17 @@ If you need specific versions of **NDK** and **CMake** installed:
7599
```yml
76100
jobs:
77101
test:
78-
runs-on: macos-latest
102+
runs-on: ubuntu-latest
79103
steps:
80104
- name: checkout
81105
uses: actions/checkout@v3
82106

107+
- name: Enable KVM
108+
run: |
109+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
110+
sudo udevadm control --reload-rules
111+
sudo udevadm trigger --name-match=kvm
112+
83113
- name: run tests
84114
uses: reactivecircus/android-emulator-runner@v2
85115
with:
@@ -99,14 +129,20 @@ We can significantly reduce emulator startup time by setting up AVD snapshot cac
99129
```yml
100130
jobs:
101131
test:
102-
runs-on: macos-latest
132+
runs-on: ubuntu-latest
103133
strategy:
104134
matrix:
105135
api-level: [21, 23, 29]
106136
steps:
107137
- name: checkout
108138
uses: actions/checkout@v3
109139
140+
- name: Enable KVM
141+
run: |
142+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
143+
sudo udevadm control --reload-rules
144+
sudo udevadm trigger --name-match=kvm
145+
110146
- name: Gradle cache
111147
uses: gradle/gradle-build-action@v2
112148
@@ -170,12 +206,6 @@ jobs:
170206

171207
Default `emulator-options`: `-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim`.
172208

173-
## Can I use this action on Github Hosted Linux VMs?
174-
175-
The short answer is yes but on Github-hosted Linux runners it's expected to be a much worse experience (on some newer API levels it might not work at all) than running it on macOS, because of the current lack of hardware acceleration support. You can get it running much faster on self-hosted Linux runners but only if the underlying instances support KVM (which most don't). Things might be better on the newer Larger runners but they are still in Beta. It is possible to use this Action with hardware accelerated Linux VMs hosted by a third-party runner provider.
176-
177-
For a longer answer please refer to [this issue](https://github.com/ReactiveCircus/android-emulator-runner/issues/46).
178-
179209
## Who is using Android Emulator Runner?
180210

181211
These are some of the open-source projects using (or used) **Android Emulator Runner**:
@@ -211,5 +241,6 @@ These are some of the open-source projects using (or used) **Android Emulator Ru
211241
- [hzi-braunschweig/SORMAS-Project](https://github.com/hzi-braunschweig/SORMAS-Project/blob/development/.github/workflows/sormas_app_ci.yml)
212242
- [ACRA/acra](https://github.com/ACRA/acra/blob/master/.github/workflows/test.yml)
213243
- [bitfireAT/davx5-ose](https://github.com/bitfireAT/davx5-ose/blob/dev-ose/.github/workflows/test-dev.yml)
244+
- [robolectric/robolectric](https://github.com/robolectric/robolectric/blob/master/.github/workflows/tests.yml)
214245

215246
If you are using **Android Emulator Runner** and want your project included in the list, please feel free to open a pull request.

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'Android Emulator Runner'
2-
description: 'Installs, configures and starts an Android Emulator directly on macOS virtual machines.'
2+
description: 'Installs, configures and starts an Android Emulator directly on hardware-accelerated runners.'
33
author: 'Reactive Circus'
44
branding:
55
icon: 'smartphone'

lib/emulator-manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function launchEmulator(apiLevel, target, arch, profile, cores, ramSize, heapSiz
6565
if (diskSize) {
6666
yield exec.exec(`sh -c \\"printf 'disk.dataPartition.size=${diskSize}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
6767
}
68-
//turn off hardware acceleration on Linux
68+
// turn off hardware acceleration on Linux
6969
if (process.platform === 'linux' && disableLinuxHardwareAcceleration) {
7070
console.log('Disabling Linux hardware acceleration.');
7171
emulatorOptions += ' -accel off';

node_modules/.package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/http-client/lib/auth.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/http-client/lib/index.d.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/http-client/lib/index.js

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/http-client/lib/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/http-client/lib/proxy.js

Lines changed: 23 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)