mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-08-31 17:49:33 +00:00
66 lines
3.2 KiB
JavaScript
66 lines
3.2 KiB
JavaScript
"use strict";
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
result["default"] = mod;
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const core = __importStar(require("@actions/core"));
|
|
const sdk_installer_1 = require("./sdk-installer");
|
|
const input_validator_1 = require("./input-validator");
|
|
const emulator_launcher_1 = require("./emulator-launcher");
|
|
function run() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
try {
|
|
// only support running on macOS
|
|
if (process.platform !== 'darwin') {
|
|
throw new Error('This action is expected to be run within a macOS virtual machine to enable hardware acceleration.');
|
|
}
|
|
// API level of the platform and system image
|
|
const apiLevelInput = core.getInput('api-level', { required: true });
|
|
input_validator_1.checkApiLevel(apiLevelInput);
|
|
const apiLevel = Number(apiLevelInput);
|
|
console.log(`API level: ${apiLevel}`);
|
|
// target of the system image
|
|
const target = core.getInput('target');
|
|
input_validator_1.checkTarget(target);
|
|
console.log(`target: ${target}`);
|
|
// CPU / ABI of the system image
|
|
const abi = core.getInput('abi');
|
|
input_validator_1.checkAbi(abi);
|
|
console.log(`cpu/abi: ${abi}`);
|
|
// headless mode
|
|
const headlessInput = core.getInput('headless');
|
|
input_validator_1.checkHeadless(headlessInput);
|
|
const headless = headlessInput === 'true';
|
|
console.log(`headless mode: ${headless}`);
|
|
// disable animations
|
|
const disableAnimationsInput = core.getInput('disable-animations');
|
|
input_validator_1.checkDisableAnimations(disableAnimationsInput);
|
|
const disableAnimations = disableAnimationsInput === 'true';
|
|
console.log(`disable animations: ${disableAnimations}`);
|
|
// install SDK
|
|
yield sdk_installer_1.installAndroidSdk(apiLevel, target, abi);
|
|
// launch emulator
|
|
// TODO get from input (source list of all profiles)
|
|
const device = 'Nexus 6P';
|
|
yield emulator_launcher_1.launchEmulator(apiLevel, target, abi, device, headless, disableAnimations);
|
|
// TODO start emulator
|
|
}
|
|
catch (error) {
|
|
core.setFailed(error.message);
|
|
}
|
|
});
|
|
}
|
|
run();
|