From eb6b0c052404a18440e55481bcadedd0f109955d Mon Sep 17 00:00:00 2001 From: Yang Date: Sat, 14 May 2022 17:17:56 +1000 Subject: [PATCH 1/6] SDK command-line tools 7.0. --- lib/sdk-installer.js | 4 ++-- src/sdk-installer.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/sdk-installer.js b/lib/sdk-installer.js index c9c8145c5..6fca04e3e 100644 --- a/lib/sdk-installer.js +++ b/lib/sdk-installer.js @@ -35,8 +35,8 @@ const io = __importStar(require("@actions/io")); const tc = __importStar(require("@actions/tool-cache")); const fs = __importStar(require("fs")); const BUILD_TOOLS_VERSION = '32.0.0'; -const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-8092744_latest.zip'; -const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip'; +const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-8512546_latest.zip'; +const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip'; /** * Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator, * and the system image for the chosen API level, CPU arch, and target. diff --git a/src/sdk-installer.ts b/src/sdk-installer.ts index 8778829ef..39e52b894 100644 --- a/src/sdk-installer.ts +++ b/src/sdk-installer.ts @@ -5,8 +5,8 @@ import * as tc from '@actions/tool-cache'; import * as fs from 'fs'; const BUILD_TOOLS_VERSION = '32.0.0'; -const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-8092744_latest.zip'; -const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip'; +const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-8512546_latest.zip'; +const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip'; /** * Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator, From f1d9765a2a369a0b380aadd3311cb75c9bb81e83 Mon Sep 17 00:00:00 2001 From: Yang Date: Thu, 26 May 2022 11:29:00 +1000 Subject: [PATCH 2/6] Update Kotlin and AGP in test-fixture. --- test-fixture/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-fixture/build.gradle b/test-fixture/build.gradle index 8422a812b..dacf921a1 100644 --- a/test-fixture/build.gradle +++ b/test-fixture/build.gradle @@ -1,13 +1,13 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.6.21' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:7.1.2' + classpath 'com.android.tools.build:gradle:7.2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong From a9c993651c47447472b89ec9b66b8c74a2f42b28 Mon Sep 17 00:00:00 2001 From: Yang Date: Fri, 17 Jun 2022 23:54:56 +1000 Subject: [PATCH 3/6] Build tools 33.0.0. Update test fixture dependencies. --- src/sdk-installer.ts | 2 +- test-fixture/app/build.gradle | 6 +++--- test-fixture/build.gradle | 6 +++--- test-fixture/gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sdk-installer.ts b/src/sdk-installer.ts index 39e52b894..29526d7e1 100644 --- a/src/sdk-installer.ts +++ b/src/sdk-installer.ts @@ -4,7 +4,7 @@ import * as io from '@actions/io'; import * as tc from '@actions/tool-cache'; import * as fs from 'fs'; -const BUILD_TOOLS_VERSION = '32.0.0'; +const BUILD_TOOLS_VERSION = '33.0.0'; const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-8512546_latest.zip'; const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip'; diff --git a/test-fixture/app/build.gradle b/test-fixture/app/build.gradle index bde6caed9..82b4d4f50 100644 --- a/test-fixture/app/build.gradle +++ b/test-fixture/app/build.gradle @@ -2,13 +2,13 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { - compileSdkVersion 32 - buildToolsVersion "32.0.0" + compileSdkVersion 33 + buildToolsVersion "33.0.0" defaultConfig { applicationId "com.example.testapp" minSdkVersion 15 - targetSdkVersion 32 + targetSdkVersion 33 versionCode 1 versionName "1.0" diff --git a/test-fixture/build.gradle b/test-fixture/build.gradle index dacf921a1..346ab7a88 100644 --- a/test-fixture/build.gradle +++ b/test-fixture/build.gradle @@ -1,10 +1,10 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.6.21' + ext.kotlin_version = '1.7.0' repositories { google() - jcenter() + mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.2.1' @@ -18,7 +18,7 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() } } diff --git a/test-fixture/gradle/wrapper/gradle-wrapper.properties b/test-fixture/gradle/wrapper/gradle-wrapper.properties index ab4bea5b5..5969f534d 100644 --- a/test-fixture/gradle/wrapper/gradle-wrapper.properties +++ b/test-fixture/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip From 7809d88d543e0153ded25daded9f91e915d6aae4 Mon Sep 17 00:00:00 2001 From: notbigdata <59257487+notbigdata@users.noreply.github.com> Date: Tue, 12 Jul 2022 10:32:26 +0200 Subject: [PATCH 4/6] Auto detect hardware acceleration on Linux (#254) --- __tests__/input-validator.test.ts | 9 +++++++-- action.yml | 4 ++-- lib/input-validator.js | 4 ++-- lib/main.js | 15 +++++++++++++-- src/input-validator.ts | 4 ++-- src/main.ts | 18 ++++++++++++++---- 6 files changed, 40 insertions(+), 14 deletions(-) diff --git a/__tests__/input-validator.test.ts b/__tests__/input-validator.test.ts index 5c52a2c53..ba7e20eb4 100644 --- a/__tests__/input-validator.test.ts +++ b/__tests__/input-validator.test.ts @@ -211,10 +211,10 @@ describe('disable-linux-hw-accel validator tests', () => { const func = () => { validator.checkDisableLinuxHardwareAcceleration('yes'); }; - expect(func).toThrowError(`Input for input.disable-linux-hw-accel should be either 'true' or 'false'.`); + expect(func).toThrowError(`Input for input.disable-linux-hw-accel should be either 'true' or 'false' or 'auto'.`); }); - it('Validates successfully if disable-linux-hw-accel is either true or false', () => { + it('Validates successfully if disable-linux-hw-accel is either true or false or auto', () => { const func1 = () => { validator.checkDisableLinuxHardwareAcceleration('true'); }; @@ -224,6 +224,11 @@ describe('disable-linux-hw-accel validator tests', () => { validator.checkDisableLinuxHardwareAcceleration('false'); }; expect(func2).not.toThrow(); + + const func3 = () => { + validator.checkDisableLinuxHardwareAcceleration('auto'); + }; + expect(func3).not.toThrow(); }); }); diff --git a/action.yml b/action.yml index 12ae7a15d..9c5b36d2f 100644 --- a/action.yml +++ b/action.yml @@ -43,8 +43,8 @@ inputs: description: 'whether to disable spellchecker - `true` or `false`' default: 'false' disable-linux-hw-accel: - description: 'whether to disable hardware acceleration on Linux machines - `true` or `false`' - default: 'true' + description: 'whether to disable hardware acceleration on Linux machines - `true` or `false` or `auto`' + default: 'auto' enable-hw-keyboard: description: 'whether to enable hardware keyboard - `true` or `false`.' default: 'false' diff --git a/lib/input-validator.js b/lib/input-validator.js index a7bbabe44..95959a5ad 100644 --- a/lib/input-validator.js +++ b/lib/input-validator.js @@ -51,8 +51,8 @@ function checkDisableSpellchecker(disableSpellchecker) { } exports.checkDisableSpellchecker = checkDisableSpellchecker; function checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAcceleration) { - if (!isValidBoolean(disableLinuxHardwareAcceleration)) { - throw new Error(`Input for input.disable-linux-hw-accel should be either 'true' or 'false'.`); + if (!(isValidBoolean(disableLinuxHardwareAcceleration) || disableLinuxHardwareAcceleration === 'auto')) { + throw new Error(`Input for input.disable-linux-hw-accel should be either 'true' or 'false' or 'auto'.`); } } exports.checkDisableLinuxHardwareAcceleration = checkDisableLinuxHardwareAcceleration; diff --git a/lib/main.js b/lib/main.js index 1ac0a0daa..1ccc06d02 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,14 +35,22 @@ const emulator_manager_1 = require("./emulator-manager"); const exec = __importStar(require("@actions/exec")); const script_parser_1 = require("./script-parser"); const channel_id_mapper_1 = require("./channel-id-mapper"); +const fs_1 = require("fs"); function run() { return __awaiter(this, void 0, void 0, function* () { try { console.log(`::group::Configure emulator`); + let linuxSupportKVM = false; // only support running on macOS or Linux if (process.platform !== 'darwin') { if (process.platform === 'linux') { - 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.`); + try { + fs_1.accessSync('/dev/kvm', fs_1.constants.R_OK | fs_1.constants.W_OK); + linuxSupportKVM = true; + } + catch (_a) { + 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.`); + } } else { throw new Error('Unsupported virtual machine: please use either macos or ubuntu VM.'); @@ -102,8 +110,11 @@ function run() { const disableSpellchecker = disableSpellcheckerInput === 'true'; console.log(`disable spellchecker: ${disableSpellchecker}`); // disable linux hardware acceleration - const disableLinuxHardwareAccelerationInput = core.getInput('disable-linux-hw-accel'); + let disableLinuxHardwareAccelerationInput = core.getInput('disable-linux-hw-accel'); input_validator_1.checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAccelerationInput); + if (disableLinuxHardwareAccelerationInput === 'auto' && process.platform === 'linux') { + disableLinuxHardwareAccelerationInput = linuxSupportKVM ? 'false' : 'true'; + } const disableLinuxHardwareAcceleration = disableLinuxHardwareAccelerationInput === 'true'; console.log(`disable Linux hardware acceleration: ${disableLinuxHardwareAcceleration}`); // enable hardware keyboard diff --git a/src/input-validator.ts b/src/input-validator.ts index cdafa7f19..7cf1e1b04 100644 --- a/src/input-validator.ts +++ b/src/input-validator.ts @@ -49,8 +49,8 @@ export function checkDisableSpellchecker(disableSpellchecker: string): void { } export function checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAcceleration: string): void { - if (!isValidBoolean(disableLinuxHardwareAcceleration)) { - throw new Error(`Input for input.disable-linux-hw-accel should be either 'true' or 'false'.`); + if (!(isValidBoolean(disableLinuxHardwareAcceleration) || disableLinuxHardwareAcceleration === 'auto')) { + throw new Error(`Input for input.disable-linux-hw-accel should be either 'true' or 'false' or 'auto'.`); } } diff --git a/src/main.ts b/src/main.ts index 13fd80281..63d34c6b8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -17,16 +17,23 @@ import { launchEmulator, killEmulator } from './emulator-manager'; import * as exec from '@actions/exec'; import { parseScript } from './script-parser'; import { getChannelId } from './channel-id-mapper'; +import { accessSync, constants } from 'fs'; async function run() { try { console.log(`::group::Configure emulator`); + let linuxSupportKVM = false; // only support running on macOS or Linux if (process.platform !== 'darwin') { if (process.platform === 'linux') { - 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.` - ); + try { + accessSync('/dev/kvm', constants.R_OK | constants.W_OK); + linuxSupportKVM = true; + } catch { + 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.` + ); + } } else { throw new Error('Unsupported virtual machine: please use either macos or ubuntu VM.'); } @@ -100,8 +107,11 @@ async function run() { console.log(`disable spellchecker: ${disableSpellchecker}`); // disable linux hardware acceleration - const disableLinuxHardwareAccelerationInput = core.getInput('disable-linux-hw-accel'); + let disableLinuxHardwareAccelerationInput = core.getInput('disable-linux-hw-accel'); checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAccelerationInput); + if (disableLinuxHardwareAccelerationInput === 'auto' && process.platform === 'linux') { + disableLinuxHardwareAccelerationInput = linuxSupportKVM ? 'false' : 'true'; + } const disableLinuxHardwareAcceleration = disableLinuxHardwareAccelerationInput === 'true'; console.log(`disable Linux hardware acceleration: ${disableLinuxHardwareAcceleration}`); From cd418889470f42b1461a30f7eaf4202672c2c199 Mon Sep 17 00:00:00 2001 From: Yang Date: Tue, 12 Jul 2022 18:38:58 +1000 Subject: [PATCH 5/6] Check in missing compiled js file. --- lib/sdk-installer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sdk-installer.js b/lib/sdk-installer.js index 6fca04e3e..219f9c01c 100644 --- a/lib/sdk-installer.js +++ b/lib/sdk-installer.js @@ -34,7 +34,7 @@ const exec = __importStar(require("@actions/exec")); const io = __importStar(require("@actions/io")); const tc = __importStar(require("@actions/tool-cache")); const fs = __importStar(require("fs")); -const BUILD_TOOLS_VERSION = '32.0.0'; +const BUILD_TOOLS_VERSION = '33.0.0'; const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-8512546_latest.zip'; const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip'; /** From 402c25e52ebb63c1686ea352a1b61308543891f0 Mon Sep 17 00:00:00 2001 From: Yang Date: Tue, 12 Jul 2022 18:43:26 +1000 Subject: [PATCH 6/6] Prepare for release 2.25.0. --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 646a708ff..04aefc0d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## v2.25.0 + +* Auto detect hardware acceleration on Linux. - [#254](https://github.com/ReactiveCircus/android-emulator-runner/pull/254) @notbigdata. +* Update build tools to `33.0.0`. +* Update SDK command-line tools to `7.0`. + ## v2.24.0 * Add option to specify `heap-size` for the AVD. - [#245](https://github.com/ReactiveCircus/android-emulator-runner/pull/245) @timusus.