Skip to content

Commit b390b0e

Browse files
committed
Merge branch 'main' into release/v2
* main: Prepare for release 2.25.0. Check in missing compiled js file. Auto detect hardware acceleration on Linux (#254) Build tools 33.0.0. Update test fixture dependencies. Update Kotlin and AGP in test-fixture. SDK command-line tools 7.0.
2 parents e790971 + 402c25e commit b390b0e

File tree

12 files changed

+60
-28
lines changed

12 files changed

+60
-28
lines changed

CHANGELOG.md

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

3+
## v2.25.0
4+
5+
* Auto detect hardware acceleration on Linux. - [#254](https://github.com/ReactiveCircus/android-emulator-runner/pull/254) @notbigdata.
6+
* Update build tools to `33.0.0`.
7+
* Update SDK command-line tools to `7.0`.
8+
39
## v2.24.0
410

511
* Add option to specify `heap-size` for the AVD. - [#245](https://github.com/ReactiveCircus/android-emulator-runner/pull/245) @timusus.

__tests__/input-validator.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ describe('disable-linux-hw-accel validator tests', () => {
211211
const func = () => {
212212
validator.checkDisableLinuxHardwareAcceleration('yes');
213213
};
214-
expect(func).toThrowError(`Input for input.disable-linux-hw-accel should be either 'true' or 'false'.`);
214+
expect(func).toThrowError(`Input for input.disable-linux-hw-accel should be either 'true' or 'false' or 'auto'.`);
215215
});
216216

217-
it('Validates successfully if disable-linux-hw-accel is either true or false', () => {
217+
it('Validates successfully if disable-linux-hw-accel is either true or false or auto', () => {
218218
const func1 = () => {
219219
validator.checkDisableLinuxHardwareAcceleration('true');
220220
};
@@ -224,6 +224,11 @@ describe('disable-linux-hw-accel validator tests', () => {
224224
validator.checkDisableLinuxHardwareAcceleration('false');
225225
};
226226
expect(func2).not.toThrow();
227+
228+
const func3 = () => {
229+
validator.checkDisableLinuxHardwareAcceleration('auto');
230+
};
231+
expect(func3).not.toThrow();
227232
});
228233
});
229234

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ inputs:
4343
description: 'whether to disable spellchecker - `true` or `false`'
4444
default: 'false'
4545
disable-linux-hw-accel:
46-
description: 'whether to disable hardware acceleration on Linux machines - `true` or `false`'
47-
default: 'true'
46+
description: 'whether to disable hardware acceleration on Linux machines - `true` or `false` or `auto`'
47+
default: 'auto'
4848
enable-hw-keyboard:
4949
description: 'whether to enable hardware keyboard - `true` or `false`.'
5050
default: 'false'

lib/input-validator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ function checkDisableSpellchecker(disableSpellchecker) {
5151
}
5252
exports.checkDisableSpellchecker = checkDisableSpellchecker;
5353
function checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAcceleration) {
54-
if (!isValidBoolean(disableLinuxHardwareAcceleration)) {
55-
throw new Error(`Input for input.disable-linux-hw-accel should be either 'true' or 'false'.`);
54+
if (!(isValidBoolean(disableLinuxHardwareAcceleration) || disableLinuxHardwareAcceleration === 'auto')) {
55+
throw new Error(`Input for input.disable-linux-hw-accel should be either 'true' or 'false' or 'auto'.`);
5656
}
5757
}
5858
exports.checkDisableLinuxHardwareAcceleration = checkDisableLinuxHardwareAcceleration;

lib/main.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,22 @@ const emulator_manager_1 = require("./emulator-manager");
3535
const exec = __importStar(require("@actions/exec"));
3636
const script_parser_1 = require("./script-parser");
3737
const channel_id_mapper_1 = require("./channel-id-mapper");
38+
const fs_1 = require("fs");
3839
function run() {
3940
return __awaiter(this, void 0, void 0, function* () {
4041
try {
4142
console.log(`::group::Configure emulator`);
43+
let linuxSupportKVM = false;
4244
// only support running on macOS or Linux
4345
if (process.platform !== 'darwin') {
4446
if (process.platform === 'linux') {
45-
console.warn(`You're running a Linux VM where hardware acceleration is not available. Please consider using a macOS VM instead to take advantage of native hardware acceleration support provided by HAXM.`);
47+
try {
48+
fs_1.accessSync('/dev/kvm', fs_1.constants.R_OK | fs_1.constants.W_OK);
49+
linuxSupportKVM = true;
50+
}
51+
catch (_a) {
52+
console.warn(`You're running a Linux VM where hardware acceleration is not available. Please consider using a macOS VM instead to take advantage of native hardware acceleration support provided by HAXM.`);
53+
}
4654
}
4755
else {
4856
throw new Error('Unsupported virtual machine: please use either macos or ubuntu VM.');
@@ -102,8 +110,11 @@ function run() {
102110
const disableSpellchecker = disableSpellcheckerInput === 'true';
103111
console.log(`disable spellchecker: ${disableSpellchecker}`);
104112
// disable linux hardware acceleration
105-
const disableLinuxHardwareAccelerationInput = core.getInput('disable-linux-hw-accel');
113+
let disableLinuxHardwareAccelerationInput = core.getInput('disable-linux-hw-accel');
106114
input_validator_1.checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAccelerationInput);
115+
if (disableLinuxHardwareAccelerationInput === 'auto' && process.platform === 'linux') {
116+
disableLinuxHardwareAccelerationInput = linuxSupportKVM ? 'false' : 'true';
117+
}
107118
const disableLinuxHardwareAcceleration = disableLinuxHardwareAccelerationInput === 'true';
108119
console.log(`disable Linux hardware acceleration: ${disableLinuxHardwareAcceleration}`);
109120
// enable hardware keyboard

lib/sdk-installer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ const exec = __importStar(require("@actions/exec"));
3434
const io = __importStar(require("@actions/io"));
3535
const tc = __importStar(require("@actions/tool-cache"));
3636
const fs = __importStar(require("fs"));
37-
const BUILD_TOOLS_VERSION = '32.0.0';
38-
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-8092744_latest.zip';
39-
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip';
37+
const BUILD_TOOLS_VERSION = '33.0.0';
38+
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-8512546_latest.zip';
39+
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip';
4040
/**
4141
* Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator,
4242
* and the system image for the chosen API level, CPU arch, and target.

src/input-validator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export function checkDisableSpellchecker(disableSpellchecker: string): void {
4949
}
5050

5151
export function checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAcceleration: string): void {
52-
if (!isValidBoolean(disableLinuxHardwareAcceleration)) {
53-
throw new Error(`Input for input.disable-linux-hw-accel should be either 'true' or 'false'.`);
52+
if (!(isValidBoolean(disableLinuxHardwareAcceleration) || disableLinuxHardwareAcceleration === 'auto')) {
53+
throw new Error(`Input for input.disable-linux-hw-accel should be either 'true' or 'false' or 'auto'.`);
5454
}
5555
}
5656

src/main.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,23 @@ import { launchEmulator, killEmulator } from './emulator-manager';
1717
import * as exec from '@actions/exec';
1818
import { parseScript } from './script-parser';
1919
import { getChannelId } from './channel-id-mapper';
20+
import { accessSync, constants } from 'fs';
2021

2122
async function run() {
2223
try {
2324
console.log(`::group::Configure emulator`);
25+
let linuxSupportKVM = false;
2426
// only support running on macOS or Linux
2527
if (process.platform !== 'darwin') {
2628
if (process.platform === 'linux') {
27-
console.warn(
28-
`You're running a Linux VM where hardware acceleration is not available. Please consider using a macOS VM instead to take advantage of native hardware acceleration support provided by HAXM.`
29-
);
29+
try {
30+
accessSync('/dev/kvm', constants.R_OK | constants.W_OK);
31+
linuxSupportKVM = true;
32+
} catch {
33+
console.warn(
34+
`You're running a Linux VM where hardware acceleration is not available. Please consider using a macOS VM instead to take advantage of native hardware acceleration support provided by HAXM.`
35+
);
36+
}
3037
} else {
3138
throw new Error('Unsupported virtual machine: please use either macos or ubuntu VM.');
3239
}
@@ -100,8 +107,11 @@ async function run() {
100107
console.log(`disable spellchecker: ${disableSpellchecker}`);
101108

102109
// disable linux hardware acceleration
103-
const disableLinuxHardwareAccelerationInput = core.getInput('disable-linux-hw-accel');
110+
let disableLinuxHardwareAccelerationInput = core.getInput('disable-linux-hw-accel');
104111
checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAccelerationInput);
112+
if (disableLinuxHardwareAccelerationInput === 'auto' && process.platform === 'linux') {
113+
disableLinuxHardwareAccelerationInput = linuxSupportKVM ? 'false' : 'true';
114+
}
105115
const disableLinuxHardwareAcceleration = disableLinuxHardwareAccelerationInput === 'true';
106116
console.log(`disable Linux hardware acceleration: ${disableLinuxHardwareAcceleration}`);
107117

src/sdk-installer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import * as io from '@actions/io';
44
import * as tc from '@actions/tool-cache';
55
import * as fs from 'fs';
66

7-
const BUILD_TOOLS_VERSION = '32.0.0';
8-
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-8092744_latest.zip';
9-
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip';
7+
const BUILD_TOOLS_VERSION = '33.0.0';
8+
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-8512546_latest.zip';
9+
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip';
1010

1111
/**
1212
* Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator,

test-fixture/app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
33

44
android {
5-
compileSdkVersion 32
6-
buildToolsVersion "32.0.0"
5+
compileSdkVersion 33
6+
buildToolsVersion "33.0.0"
77

88
defaultConfig {
99
applicationId "com.example.testapp"
1010
minSdkVersion 15
11-
targetSdkVersion 32
11+
targetSdkVersion 33
1212
versionCode 1
1313
versionName "1.0"
1414

0 commit comments

Comments
 (0)