Add support for configuring hardware profile and running custom script.

This commit is contained in:
Yang Chen
2019-11-08 19:51:51 +11:00
parent 34df1eaf0e
commit 0f9b17b151
12 changed files with 150 additions and 81 deletions
+20 -11
View File
@@ -18,7 +18,8 @@ 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");
const emulator_manager_1 = require("./emulator-manager");
const exec = __importStar(require("@actions/exec"));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
@@ -35,10 +36,13 @@ function run() {
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}`);
// CPU architecture of the system image
const arch = core.getInput('arch');
input_validator_1.checkArch(arch);
console.log(`CPI architecture: ${arch}`);
// Hardware profile used for creating the AVD
const profile = core.getInput('profile');
console.log(`Hardware profile: ${profile}`);
// headless mode
const headlessInput = core.getInput('headless');
input_validator_1.checkHeadless(headlessInput);
@@ -49,15 +53,20 @@ function run() {
input_validator_1.checkDisableAnimations(disableAnimationsInput);
const disableAnimations = disableAnimationsInput === 'true';
console.log(`disable animations: ${disableAnimations}`);
// custom scrpt to run
const script = core.getInput('script', { required: true });
// 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
yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch);
// launch an emulator
yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, headless, disableAnimations);
// execute the custom script
yield exec.exec(`${script}`);
// finally kill the emulator
yield emulator_manager_1.killEmulator();
}
catch (error) {
// kill the emulator so the action can exit
yield emulator_manager_1.killEmulator();
core.setFailed(error.message);
}
});