Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: allow google_apis_ps16k and google_apis_playstore_ps16k as valid…
… targets

Fixes #403

Co-authored-by: Yang <[email protected]>
  • Loading branch information
mikehardy and ychescale9 committed Jul 1, 2025
commit fddfc032bb363bbe0511bcfea79847bef870e7cd
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**. |
| `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). |
| `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). |
Expand Down
12 changes: 12 additions & 0 deletions __tests__/input-validator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ describe('target validator tests', () => {
expect(func).toThrowError(`Value for input.target 'some-target' is unknown. Supported options: ${validator.VALID_TARGETS}`);
});

it('Validates successfully with playstore target shorthands', () => {
const func1 = () => {
validator.checkTarget('playstore');
};
expect(func1).not.toThrow();
const func2 = () => {
validator.checkTarget('playstore_ps16k');
};
expect(func2).not.toThrow();
});
});

describe('arch validator tests', () => {
it('Throws if arch is unknown', () => {
const func = () => {
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
required: false
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'
arch:
description: 'CPU architecture of the system image - x86, x86_64 or arm64-v8a'
Expand Down
16 changes: 14 additions & 2 deletions lib/input-validator.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"use strict";
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.checkTarget = exports.playstoreTargetSubstitution = exports.MAX_PORT = exports.MIN_PORT = exports.VALID_CHANNELS = exports.VALID_ARCHS = exports.VALID_TARGETS = exports.MIN_API_LEVEL = void 0;
exports.MIN_API_LEVEL = 15;
exports.VALID_TARGETS = [
'default',
'google_apis',
'google_apis_ps16k',
'aosp_atd',
'google_atd',
'google_apis_playstore',
'google_apis_playstore_ps16k',
'android-wear',
'android-wear-cn',
'android-tv',
Expand All @@ -20,8 +22,18 @@ exports.VALID_ARCHS = ['x86', 'x86_64', 'arm64-v8a'];
exports.VALID_CHANNELS = ['stable', 'beta', 'dev', 'canary'];
exports.MIN_PORT = 5554;
exports.MAX_PORT = 5584;
function playstoreTargetSubstitution(target) {
// "playstore" is an allowed shorthand for "google_apis_playstore" images
// 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.playstoreTargetSubstitution = playstoreTargetSubstitution;
function checkTarget(target) {
if (!exports.VALID_TARGETS.includes(target)) {
if (!exports.VALID_TARGETS.includes(playstoreTargetSubstitution(target))) {
throw new Error(`Value for input.target '${target}' is unknown. Supported options: ${exports.VALID_TARGETS}.`);
}
}
Expand Down
3 changes: 1 addition & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ function run() {
}
console.log(`System image API level: ${systemImageApiLevel}`);
// target of the system image
const targetInput = core.getInput('target');
const target = targetInput == 'playstore' ? 'google_apis_playstore' : targetInput;
const target = (0, input_validator_1.playstoreTargetSubstitution)(core.getInput('target'));
(0, input_validator_1.checkTarget)(target);
console.log(`target: ${target}`);
// CPU architecture of the system image
Expand Down
12 changes: 11 additions & 1 deletion src/input-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ export const MIN_API_LEVEL = 15;
export const VALID_TARGETS: Array<string> = [
'default',
'google_apis',
'google_apis_ps16k',
'aosp_atd',
'google_atd',
'google_apis_playstore',
'google_apis_playstore_ps16k',
'android-wear',
'android-wear-cn',
'android-tv',
Expand All @@ -18,8 +20,16 @@ export const VALID_CHANNELS: Array<string> = ['stable', 'beta', 'dev', 'canary']
export const MIN_PORT = 5554;
export const MAX_PORT = 5584;

export function playstoreTargetSubstitution(target: string): string {
// "playstore" is an allowed shorthand for "google_apis_playstore" images
// 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 checkTarget(target: string): void {
if (!VALID_TARGETS.includes(target)) {
if (!VALID_TARGETS.includes(playstoreTargetSubstitution(target))) {
throw new Error(`Value for input.target '${target}' is unknown. Supported options: ${VALID_TARGETS}.`);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
checkEnableHardwareKeyboard,
checkDiskSize,
checkPort,
playstoreTargetSubstitution,
MIN_PORT,
} from './input-validator';
import { createAvd, launchEmulator, killEmulator } from './emulator-manager';
Expand Down Expand Up @@ -52,8 +53,7 @@ async function run() {
console.log(`System image API level: ${systemImageApiLevel}`);

// target of the system image
const targetInput = core.getInput('target');
const target = targetInput == 'playstore' ? 'google_apis_playstore' : targetInput;
const target = playstoreTargetSubstitution(core.getInput('target'));
checkTarget(target);
console.log(`target: ${target}`);

Expand Down