mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-08-31 17:49:33 +00:00
fix: allow google_apis_ps16k as a valid target (#440)
* test: remove target validator test these appear to have too much maintenance burden as they only ever add more over time * fix: allow google_apis_ps16k and google_apis_playstore_ps16k as valid targets Fixes #403 Co-authored-by: Yang <reactivecircus@gmail.com> * fix: remove target validation entirely, any valid sdkmanager target will work no longer requires code changes here to access new targets --------- Co-authored-by: Yang <reactivecircus@gmail.com>
This commit is contained in:
@@ -206,7 +206,7 @@ jobs:
|
|||||||
|-|-|-|-|
|
|-|-|-|-|
|
||||||
| `api-level` | Required | N/A | API level of the platform and system image - e.g. `23`, `33`, `35-ext15`, `Baklava`. **Minimum API level supported is 15**. |
|
| `api-level` | Required | N/A | API level of the platform and system image - e.g. `23`, `33`, `35-ext15`, `Baklava`. **Minimum API level supported is 15**. |
|
||||||
| `system-image-api-level` | Optional | same as `api-level` | API level of the system image - e.g. `34-ext10`, `35-ext15`. |
|
| `system-image-api-level` | Optional | same as `api-level` | API level of the system image - e.g. `34-ext10`, `35-ext15`. |
|
||||||
| `target` | Optional | `default` | Target of the system image - `default`, `google_apis`, `playstore`, `android-wear`, `android-wear-cn`, `android-tv`, `google-tv`, `aosp_atd`, `google_atd`, `android-automotive`, `android-automotive-playstore` or `android-desktop`. Note that `aosp_atd` and `google_atd` currently require the following: `api-level: 30`, `arch: x86` or `arch: arm64-v8` and `channel: canary`. |
|
| `target` | Optional | `default` | Target of the system image - e.g. `default`, `google_apis`, `google_apis_ps16k`, `google_apis_playstore`, `google_apis_playstore_ps16k`, `android-wear`, `android-wear-cn`, `android-tv`, `google-tv`, `aosp_atd`, `google_atd`, `android-automotive`, `android-automotive-playstore, `android-desktop`. Please run `sdkmanager --list` to see the available targets. |
|
||||||
| `arch` | Optional | `x86` | CPU architecture of the system image - `x86`, `x86_64` or `arm64-v8a`. Note that `x86_64` image is only available for API 21+. `arm64-v8a` images require Android 4.2+ and are limited to fewer API levels (e.g. 30). |
|
| `arch` | Optional | `x86` | CPU architecture of the system image - `x86`, `x86_64` or `arm64-v8a`. Note that `x86_64` image is only available for API 21+. `arm64-v8a` images require Android 4.2+ and are limited to fewer API levels (e.g. 30). |
|
||||||
| `profile` | Optional | N/A | Hardware profile used for creating the AVD - e.g. `Nexus 6`. For a list of all profiles available, run `avdmanager list device`. |
|
| `profile` | Optional | N/A | Hardware profile used for creating the AVD - e.g. `Nexus 6`. For a list of all profiles available, run `avdmanager list device`. |
|
||||||
| `cores` | Optional | 2 | Number of cores to use for the emulator (`hw.cpu.ncore` in config.ini). |
|
| `cores` | Optional | 2 | Number of cores to use for the emulator (`hw.cpu.ncore` in config.ini). |
|
||||||
|
|||||||
@@ -1,77 +1,6 @@
|
|||||||
import * as validator from '../src/input-validator';
|
import * as validator from '../src/input-validator';
|
||||||
import { MAX_PORT, MIN_PORT } from '../src/input-validator';
|
import { MAX_PORT, MIN_PORT } from '../src/input-validator';
|
||||||
|
|
||||||
describe('target validator tests', () => {
|
|
||||||
it('Throws if target is unknown', () => {
|
|
||||||
const func = () => {
|
|
||||||
validator.checkTarget('some-target');
|
|
||||||
};
|
|
||||||
expect(func).toThrowError(`Value for input.target 'some-target' is unknown. Supported options: ${validator.VALID_TARGETS}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Validates successfully with valid target', () => {
|
|
||||||
const func1 = () => {
|
|
||||||
validator.checkTarget('default');
|
|
||||||
};
|
|
||||||
expect(func1).not.toThrow();
|
|
||||||
|
|
||||||
const func2 = () => {
|
|
||||||
validator.checkTarget('google_apis');
|
|
||||||
};
|
|
||||||
expect(func2).not.toThrow();
|
|
||||||
|
|
||||||
const func3 = () => {
|
|
||||||
validator.checkTarget('aosp_atd');
|
|
||||||
};
|
|
||||||
expect(func3).not.toThrow();
|
|
||||||
|
|
||||||
const func4 = () => {
|
|
||||||
validator.checkTarget('google_atd');
|
|
||||||
};
|
|
||||||
expect(func4).not.toThrow();
|
|
||||||
|
|
||||||
const func5 = () => {
|
|
||||||
validator.checkTarget('google_apis_playstore');
|
|
||||||
};
|
|
||||||
expect(func5).not.toThrow();
|
|
||||||
|
|
||||||
const func6 = () => {
|
|
||||||
validator.checkTarget('android-wear');
|
|
||||||
};
|
|
||||||
expect(func6).not.toThrow();
|
|
||||||
|
|
||||||
const func7 = () => {
|
|
||||||
validator.checkTarget('android-wear-cn');
|
|
||||||
};
|
|
||||||
expect(func7).not.toThrow();
|
|
||||||
|
|
||||||
const func8 = () => {
|
|
||||||
validator.checkTarget('android-tv');
|
|
||||||
};
|
|
||||||
expect(func8).not.toThrow();
|
|
||||||
|
|
||||||
const func9 = () => {
|
|
||||||
validator.checkTarget('google-tv');
|
|
||||||
};
|
|
||||||
expect(func9).not.toThrow();
|
|
||||||
|
|
||||||
const func10 = () => {
|
|
||||||
validator.checkTarget('android-automotive');
|
|
||||||
};
|
|
||||||
expect(func10).not.toThrow();
|
|
||||||
|
|
||||||
const func11 = () => {
|
|
||||||
validator.checkTarget('android-automotive-playstore');
|
|
||||||
};
|
|
||||||
expect(func11).not.toThrow();
|
|
||||||
|
|
||||||
const func12 = () => {
|
|
||||||
validator.checkTarget('android-desktop');
|
|
||||||
};
|
|
||||||
expect(func12).not.toThrow();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('arch validator tests', () => {
|
describe('arch validator tests', () => {
|
||||||
it('Throws if arch is unknown', () => {
|
it('Throws if arch is unknown', () => {
|
||||||
const func = () => {
|
const func = () => {
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ inputs:
|
|||||||
description: 'API level of the system image - e.g. 34-ext10, 35-ext15. If not set the `api-level` input will be used.'
|
description: 'API level of the system image - e.g. 34-ext10, 35-ext15. If not set the `api-level` input will be used.'
|
||||||
required: false
|
required: false
|
||||||
target:
|
target:
|
||||||
description: 'target of the system image - default, google_apis, google_apis_playstore, aosp_atd, google_atd, android-wear, android-wear-cn, android-tv, google-tv, android-automotive, android-automotive-playstore or android-desktop'
|
description: 'target of the system image - e.g. default, google_apis, google_apis_ps16k, google_apis_playstore, google_apis_playstore_16k, aosp_atd, google_atd, android-wear, android-wear-cn, android-tv, google-tv, android-automotive, android-automotive-playstore or android-desktop'
|
||||||
default: 'default'
|
default: 'default'
|
||||||
arch:
|
arch:
|
||||||
description: 'CPU architecture of the system image - x86, x86_64 or arm64-v8a'
|
description: 'CPU architecture of the system image - x86, x86_64 or arm64-v8a'
|
||||||
|
|||||||
+10
-20
@@ -1,31 +1,21 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.checkDiskSize = exports.checkEmulatorBuild = exports.checkEnableHardwareKeyboard = exports.checkDisableLinuxHardwareAcceleration = exports.checkDisableSpellchecker = exports.checkDisableAnimations = exports.checkPort = exports.checkForceAvdCreation = exports.checkChannel = exports.checkArch = exports.checkTarget = exports.MAX_PORT = exports.MIN_PORT = exports.VALID_CHANNELS = exports.VALID_ARCHS = exports.VALID_TARGETS = exports.MIN_API_LEVEL = void 0;
|
exports.checkDiskSize = exports.checkEmulatorBuild = exports.checkEnableHardwareKeyboard = exports.checkDisableLinuxHardwareAcceleration = exports.checkDisableSpellchecker = exports.checkDisableAnimations = exports.checkPort = exports.checkForceAvdCreation = exports.checkChannel = exports.checkArch = exports.playstoreTargetSubstitution = exports.MAX_PORT = exports.MIN_PORT = exports.VALID_CHANNELS = exports.VALID_ARCHS = exports.MIN_API_LEVEL = void 0;
|
||||||
exports.MIN_API_LEVEL = 15;
|
exports.MIN_API_LEVEL = 15;
|
||||||
exports.VALID_TARGETS = [
|
|
||||||
'default',
|
|
||||||
'google_apis',
|
|
||||||
'aosp_atd',
|
|
||||||
'google_atd',
|
|
||||||
'google_apis_playstore',
|
|
||||||
'android-wear',
|
|
||||||
'android-wear-cn',
|
|
||||||
'android-tv',
|
|
||||||
'google-tv',
|
|
||||||
'android-automotive',
|
|
||||||
'android-automotive-playstore',
|
|
||||||
'android-desktop',
|
|
||||||
];
|
|
||||||
exports.VALID_ARCHS = ['x86', 'x86_64', 'arm64-v8a'];
|
exports.VALID_ARCHS = ['x86', 'x86_64', 'arm64-v8a'];
|
||||||
exports.VALID_CHANNELS = ['stable', 'beta', 'dev', 'canary'];
|
exports.VALID_CHANNELS = ['stable', 'beta', 'dev', 'canary'];
|
||||||
exports.MIN_PORT = 5554;
|
exports.MIN_PORT = 5554;
|
||||||
exports.MAX_PORT = 5584;
|
exports.MAX_PORT = 5584;
|
||||||
function checkTarget(target) {
|
function playstoreTargetSubstitution(target) {
|
||||||
if (!exports.VALID_TARGETS.includes(target)) {
|
// "playstore" is an allowed shorthand for "google_apis_playstore" images
|
||||||
throw new Error(`Value for input.target '${target}' is unknown. Supported options: ${exports.VALID_TARGETS}.`);
|
// this is idempotent - return same even if run multiple times on same target
|
||||||
}
|
if (target === 'playstore')
|
||||||
|
return 'google_apis_playstore';
|
||||||
|
if (target === 'playstore_ps16k')
|
||||||
|
return 'google_apis_playstore_ps16k';
|
||||||
|
return target;
|
||||||
}
|
}
|
||||||
exports.checkTarget = checkTarget;
|
exports.playstoreTargetSubstitution = playstoreTargetSubstitution;
|
||||||
function checkArch(arch) {
|
function checkArch(arch) {
|
||||||
if (!exports.VALID_ARCHS.includes(arch)) {
|
if (!exports.VALID_ARCHS.includes(arch)) {
|
||||||
throw new Error(`Value for input.arch '${arch}' is unknown. Supported options: ${exports.VALID_ARCHS}.`);
|
throw new Error(`Value for input.arch '${arch}' is unknown. Supported options: ${exports.VALID_ARCHS}.`);
|
||||||
|
|||||||
+1
-3
@@ -70,9 +70,7 @@ function run() {
|
|||||||
}
|
}
|
||||||
console.log(`System image API level: ${systemImageApiLevel}`);
|
console.log(`System image API level: ${systemImageApiLevel}`);
|
||||||
// target of the system image
|
// target of the system image
|
||||||
const targetInput = core.getInput('target');
|
const target = (0, input_validator_1.playstoreTargetSubstitution)(core.getInput('target'));
|
||||||
const target = targetInput == 'playstore' ? 'google_apis_playstore' : targetInput;
|
|
||||||
(0, input_validator_1.checkTarget)(target);
|
|
||||||
console.log(`target: ${target}`);
|
console.log(`target: ${target}`);
|
||||||
// CPU architecture of the system image
|
// CPU architecture of the system image
|
||||||
const arch = core.getInput('arch');
|
const arch = core.getInput('arch');
|
||||||
|
|||||||
+6
-18
@@ -1,27 +1,15 @@
|
|||||||
export const MIN_API_LEVEL = 15;
|
export const MIN_API_LEVEL = 15;
|
||||||
export const VALID_TARGETS: Array<string> = [
|
|
||||||
'default',
|
|
||||||
'google_apis',
|
|
||||||
'aosp_atd',
|
|
||||||
'google_atd',
|
|
||||||
'google_apis_playstore',
|
|
||||||
'android-wear',
|
|
||||||
'android-wear-cn',
|
|
||||||
'android-tv',
|
|
||||||
'google-tv',
|
|
||||||
'android-automotive',
|
|
||||||
'android-automotive-playstore',
|
|
||||||
'android-desktop',
|
|
||||||
];
|
|
||||||
export const VALID_ARCHS: Array<string> = ['x86', 'x86_64', 'arm64-v8a'];
|
export const VALID_ARCHS: Array<string> = ['x86', 'x86_64', 'arm64-v8a'];
|
||||||
export const VALID_CHANNELS: Array<string> = ['stable', 'beta', 'dev', 'canary'];
|
export const VALID_CHANNELS: Array<string> = ['stable', 'beta', 'dev', 'canary'];
|
||||||
export const MIN_PORT = 5554;
|
export const MIN_PORT = 5554;
|
||||||
export const MAX_PORT = 5584;
|
export const MAX_PORT = 5584;
|
||||||
|
|
||||||
export function checkTarget(target: string): void {
|
export function playstoreTargetSubstitution(target: string): string {
|
||||||
if (!VALID_TARGETS.includes(target)) {
|
// "playstore" is an allowed shorthand for "google_apis_playstore" images
|
||||||
throw new Error(`Value for input.target '${target}' is unknown. Supported options: ${VALID_TARGETS}.`);
|
// this is idempotent - return same even if run multiple times on same target
|
||||||
}
|
if (target === 'playstore') return 'google_apis_playstore';
|
||||||
|
if (target === 'playstore_ps16k') return 'google_apis_playstore_ps16k';
|
||||||
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function checkArch(arch: string): void {
|
export function checkArch(arch: string): void {
|
||||||
|
|||||||
+2
-4
@@ -1,7 +1,6 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import { installAndroidSdk } from './sdk-installer';
|
import { installAndroidSdk } from './sdk-installer';
|
||||||
import {
|
import {
|
||||||
checkTarget,
|
|
||||||
checkArch,
|
checkArch,
|
||||||
checkDisableAnimations,
|
checkDisableAnimations,
|
||||||
checkEmulatorBuild,
|
checkEmulatorBuild,
|
||||||
@@ -12,6 +11,7 @@ import {
|
|||||||
checkEnableHardwareKeyboard,
|
checkEnableHardwareKeyboard,
|
||||||
checkDiskSize,
|
checkDiskSize,
|
||||||
checkPort,
|
checkPort,
|
||||||
|
playstoreTargetSubstitution,
|
||||||
MIN_PORT,
|
MIN_PORT,
|
||||||
} from './input-validator';
|
} from './input-validator';
|
||||||
import { createAvd, launchEmulator, killEmulator } from './emulator-manager';
|
import { createAvd, launchEmulator, killEmulator } from './emulator-manager';
|
||||||
@@ -52,9 +52,7 @@ async function run() {
|
|||||||
console.log(`System image API level: ${systemImageApiLevel}`);
|
console.log(`System image API level: ${systemImageApiLevel}`);
|
||||||
|
|
||||||
// target of the system image
|
// target of the system image
|
||||||
const targetInput = core.getInput('target');
|
const target = playstoreTargetSubstitution(core.getInput('target'));
|
||||||
const target = targetInput == 'playstore' ? 'google_apis_playstore' : targetInput;
|
|
||||||
checkTarget(target);
|
|
||||||
console.log(`target: ${target}`);
|
console.log(`target: ${target}`);
|
||||||
|
|
||||||
// CPU architecture of the system image
|
// CPU architecture of the system image
|
||||||
|
|||||||
Reference in New Issue
Block a user