mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-09-06 11:49:32 +00:00
Add emulator-boot-timeout parameter (#326)
* Add emulator-boot-timeout parameter * Update action-types.yml
This commit is contained in:
@@ -35,6 +35,8 @@ inputs:
|
|||||||
type: string
|
type: string
|
||||||
force-avd-creation:
|
force-avd-creation:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
emulator-boot-timeout:
|
||||||
|
type: integer
|
||||||
emulator-options:
|
emulator-options:
|
||||||
type: string
|
type: string
|
||||||
disable-animations:
|
disable-animations:
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ inputs:
|
|||||||
force-avd-creation:
|
force-avd-creation:
|
||||||
description: 'whether to force create the AVD by overwriting an existing AVD with the same name as `avd-name` - `true` or `false`'
|
description: 'whether to force create the AVD by overwriting an existing AVD with the same name as `avd-name` - `true` or `false`'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
|
emulator-boot-timeout:
|
||||||
|
description: 'Emulator boot timeout in seconds. If it takes longer to boot, the action would fail'
|
||||||
|
default: '600'
|
||||||
emulator-options:
|
emulator-options:
|
||||||
description: 'command-line options used when launching the emulator - e.g. `-no-window -no-snapshot -camera-back emulated`'
|
description: 'command-line options used when launching the emulator - e.g. `-no-window -no-snapshot -camera-back emulated`'
|
||||||
default: '-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim'
|
default: '-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim'
|
||||||
|
|||||||
@@ -35,11 +35,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||||||
exports.killEmulator = exports.launchEmulator = void 0;
|
exports.killEmulator = exports.launchEmulator = void 0;
|
||||||
const exec = __importStar(require("@actions/exec"));
|
const exec = __importStar(require("@actions/exec"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const EMULATOR_BOOT_TIMEOUT_SECONDS = 600;
|
|
||||||
/**
|
/**
|
||||||
* Creates and launches a new AVD instance with the specified configurations.
|
* Creates and launches a new AVD instance with the specified configurations.
|
||||||
*/
|
*/
|
||||||
function launchEmulator(apiLevel, target, arch, profile, cores, ramSize, heapSize, sdcardPathOrSize, diskSize, avdName, forceAvdCreation, emulatorOptions, disableAnimations, disableSpellChecker, disableLinuxHardwareAcceleration, enableHardwareKeyboard) {
|
function launchEmulator(apiLevel, target, arch, profile, cores, ramSize, heapSize, sdcardPathOrSize, diskSize, avdName, forceAvdCreation, emulatorBootTimeout, emulatorOptions, disableAnimations, disableSpellChecker, disableLinuxHardwareAcceleration, enableHardwareKeyboard) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
console.log(`::group::Launch Emulator`);
|
console.log(`::group::Launch Emulator`);
|
||||||
@@ -83,7 +82,7 @@ function launchEmulator(apiLevel, target, arch, profile, cores, ramSize, heapSiz
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
// wait for emulator to complete booting
|
// wait for emulator to complete booting
|
||||||
yield waitForDevice();
|
yield waitForDevice(emulatorBootTimeout);
|
||||||
yield exec.exec(`adb shell input keyevent 82`);
|
yield exec.exec(`adb shell input keyevent 82`);
|
||||||
if (disableAnimations) {
|
if (disableAnimations) {
|
||||||
console.log('Disabling animations.');
|
console.log('Disabling animations.');
|
||||||
@@ -125,12 +124,12 @@ exports.killEmulator = killEmulator;
|
|||||||
/**
|
/**
|
||||||
* Wait for emulator to boot.
|
* Wait for emulator to boot.
|
||||||
*/
|
*/
|
||||||
function waitForDevice() {
|
function waitForDevice(emulatorBootTimeout) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let booted = false;
|
let booted = false;
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
const retryInterval = 2; // retry every 2 seconds
|
const retryInterval = 2; // retry every 2 seconds
|
||||||
const maxAttempts = EMULATOR_BOOT_TIMEOUT_SECONDS / 2;
|
const maxAttempts = emulatorBootTimeout / 2;
|
||||||
while (!booted) {
|
while (!booted) {
|
||||||
try {
|
try {
|
||||||
let result = '';
|
let result = '';
|
||||||
|
|||||||
+4
-1
@@ -99,6 +99,9 @@ function run() {
|
|||||||
(0, input_validator_1.checkForceAvdCreation)(forceAvdCreationInput);
|
(0, input_validator_1.checkForceAvdCreation)(forceAvdCreationInput);
|
||||||
const forceAvdCreation = forceAvdCreationInput === 'true';
|
const forceAvdCreation = forceAvdCreationInput === 'true';
|
||||||
console.log(`force avd creation: ${forceAvdCreation}`);
|
console.log(`force avd creation: ${forceAvdCreation}`);
|
||||||
|
// Emulator boot timeout seconds
|
||||||
|
const emulatorBootTimeout = parseInt(core.getInput('emulator-boot-timeout'), 10);
|
||||||
|
console.log(`Emulator boot timeout: ${emulatorBootTimeout}`);
|
||||||
// emulator options
|
// emulator options
|
||||||
const emulatorOptions = core.getInput('emulator-options').trim();
|
const emulatorOptions = core.getInput('emulator-options').trim();
|
||||||
console.log(`emulator options: ${emulatorOptions}`);
|
console.log(`emulator options: ${emulatorOptions}`);
|
||||||
@@ -190,7 +193,7 @@ function run() {
|
|||||||
console.log(`::endgroup::`);
|
console.log(`::endgroup::`);
|
||||||
}
|
}
|
||||||
// launch an emulator
|
// launch an emulator
|
||||||
yield (0, emulator_manager_1.launchEmulator)(apiLevel, target, arch, profile, cores, ramSize, heapSize, sdcardPathOrSize, diskSize, avdName, forceAvdCreation, emulatorOptions, disableAnimations, disableSpellchecker, disableLinuxHardwareAcceleration, enableHardwareKeyboard);
|
yield (0, emulator_manager_1.launchEmulator)(apiLevel, target, arch, profile, cores, ramSize, heapSize, sdcardPathOrSize, diskSize, avdName, forceAvdCreation, emulatorBootTimeout, emulatorOptions, disableAnimations, disableSpellchecker, disableLinuxHardwareAcceleration, enableHardwareKeyboard);
|
||||||
// execute the custom script
|
// execute the custom script
|
||||||
try {
|
try {
|
||||||
// move to custom working directory if set
|
// move to custom working directory if set
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
const EMULATOR_BOOT_TIMEOUT_SECONDS = 600;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and launches a new AVD instance with the specified configurations.
|
* Creates and launches a new AVD instance with the specified configurations.
|
||||||
*/
|
*/
|
||||||
@@ -18,6 +16,7 @@ export async function launchEmulator(
|
|||||||
diskSize: string,
|
diskSize: string,
|
||||||
avdName: string,
|
avdName: string,
|
||||||
forceAvdCreation: boolean,
|
forceAvdCreation: boolean,
|
||||||
|
emulatorBootTimeout: number,
|
||||||
emulatorOptions: string,
|
emulatorOptions: string,
|
||||||
disableAnimations: boolean,
|
disableAnimations: boolean,
|
||||||
disableSpellChecker: boolean,
|
disableSpellChecker: boolean,
|
||||||
@@ -77,7 +76,7 @@ export async function launchEmulator(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// wait for emulator to complete booting
|
// wait for emulator to complete booting
|
||||||
await waitForDevice();
|
await waitForDevice(emulatorBootTimeout);
|
||||||
await exec.exec(`adb shell input keyevent 82`);
|
await exec.exec(`adb shell input keyevent 82`);
|
||||||
|
|
||||||
if (disableAnimations) {
|
if (disableAnimations) {
|
||||||
@@ -114,11 +113,11 @@ export async function killEmulator(): Promise<void> {
|
|||||||
/**
|
/**
|
||||||
* Wait for emulator to boot.
|
* Wait for emulator to boot.
|
||||||
*/
|
*/
|
||||||
async function waitForDevice(): Promise<void> {
|
async function waitForDevice(emulatorBootTimeout: number): Promise<void> {
|
||||||
let booted = false;
|
let booted = false;
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
const retryInterval = 2; // retry every 2 seconds
|
const retryInterval = 2; // retry every 2 seconds
|
||||||
const maxAttempts = EMULATOR_BOOT_TIMEOUT_SECONDS / 2;
|
const maxAttempts = emulatorBootTimeout / 2;
|
||||||
while (!booted) {
|
while (!booted) {
|
||||||
try {
|
try {
|
||||||
let result = '';
|
let result = '';
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ async function run() {
|
|||||||
const forceAvdCreation = forceAvdCreationInput === 'true';
|
const forceAvdCreation = forceAvdCreationInput === 'true';
|
||||||
console.log(`force avd creation: ${forceAvdCreation}`);
|
console.log(`force avd creation: ${forceAvdCreation}`);
|
||||||
|
|
||||||
|
// Emulator boot timeout seconds
|
||||||
|
const emulatorBootTimeout = parseInt(core.getInput('emulator-boot-timeout'), 10);
|
||||||
|
console.log(`Emulator boot timeout: ${emulatorBootTimeout}`);
|
||||||
|
|
||||||
// emulator options
|
// emulator options
|
||||||
const emulatorOptions = core.getInput('emulator-options').trim();
|
const emulatorOptions = core.getInput('emulator-options').trim();
|
||||||
console.log(`emulator options: ${emulatorOptions}`);
|
console.log(`emulator options: ${emulatorOptions}`);
|
||||||
@@ -205,6 +209,7 @@ async function run() {
|
|||||||
diskSize,
|
diskSize,
|
||||||
avdName,
|
avdName,
|
||||||
forceAvdCreation,
|
forceAvdCreation,
|
||||||
|
emulatorBootTimeout,
|
||||||
emulatorOptions,
|
emulatorOptions,
|
||||||
disableAnimations,
|
disableAnimations,
|
||||||
disableSpellchecker,
|
disableSpellchecker,
|
||||||
|
|||||||
Reference in New Issue
Block a user