Skip to content

Commit 749c318

Browse files
committed
fix: remove target validation entirely, any valid sdkmanager target will work
no longer requires code changes here to access new targets
1 parent fb4b335 commit 749c318

File tree

5 files changed

+1
-68
lines changed

5 files changed

+1
-68
lines changed

__tests__/input-validator.test.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,6 @@
11
import * as validator from '../src/input-validator';
22
import { MAX_PORT, MIN_PORT } from '../src/input-validator';
33

4-
describe('target validator tests', () => {
5-
it('Throws if target is unknown', () => {
6-
const func = () => {
7-
validator.checkTarget('some-target');
8-
};
9-
expect(func).toThrowError(`Value for input.target 'some-target' is unknown. Supported options: ${validator.VALID_TARGETS}`);
10-
});
11-
12-
it('Validates successfully with playstore target shorthands', () => {
13-
const func1 = () => {
14-
validator.checkTarget('playstore');
15-
};
16-
expect(func1).not.toThrow();
17-
const func2 = () => {
18-
validator.checkTarget('playstore_ps16k');
19-
};
20-
expect(func2).not.toThrow();
21-
});
22-
});
23-
244
describe('arch validator tests', () => {
255
it('Throws if arch is unknown', () => {
266
const func = () => {

lib/input-validator.js

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
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;
3+
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;
44
exports.MIN_API_LEVEL = 15;
5-
exports.VALID_TARGETS = [
6-
'default',
7-
'google_apis',
8-
'google_apis_ps16k',
9-
'aosp_atd',
10-
'google_atd',
11-
'google_apis_playstore',
12-
'google_apis_playstore_ps16k',
13-
'android-wear',
14-
'android-wear-cn',
15-
'android-tv',
16-
'google-tv',
17-
'android-automotive',
18-
'android-automotive-playstore',
19-
'android-desktop',
20-
];
215
exports.VALID_ARCHS = ['x86', 'x86_64', 'arm64-v8a'];
226
exports.VALID_CHANNELS = ['stable', 'beta', 'dev', 'canary'];
237
exports.MIN_PORT = 5554;
@@ -32,12 +16,6 @@ function playstoreTargetSubstitution(target) {
3216
return target;
3317
}
3418
exports.playstoreTargetSubstitution = playstoreTargetSubstitution;
35-
function checkTarget(target) {
36-
if (!exports.VALID_TARGETS.includes(playstoreTargetSubstitution(target))) {
37-
throw new Error(`Value for input.target '${target}' is unknown. Supported options: ${exports.VALID_TARGETS}.`);
38-
}
39-
}
40-
exports.checkTarget = checkTarget;
4119
function checkArch(arch) {
4220
if (!exports.VALID_ARCHS.includes(arch)) {
4321
throw new Error(`Value for input.arch '${arch}' is unknown. Supported options: ${exports.VALID_ARCHS}.`);

lib/main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ function run() {
7171
console.log(`System image API level: ${systemImageApiLevel}`);
7272
// target of the system image
7373
const target = (0, input_validator_1.playstoreTargetSubstitution)(core.getInput('target'));
74-
(0, input_validator_1.checkTarget)(target);
7574
console.log(`target: ${target}`);
7675
// CPU architecture of the system image
7776
const arch = core.getInput('arch');

src/input-validator.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
11
export const MIN_API_LEVEL = 15;
2-
export const VALID_TARGETS: Array<string> = [
3-
'default',
4-
'google_apis',
5-
'google_apis_ps16k',
6-
'aosp_atd',
7-
'google_atd',
8-
'google_apis_playstore',
9-
'google_apis_playstore_ps16k',
10-
'android-wear',
11-
'android-wear-cn',
12-
'android-tv',
13-
'google-tv',
14-
'android-automotive',
15-
'android-automotive-playstore',
16-
'android-desktop',
17-
];
182
export const VALID_ARCHS: Array<string> = ['x86', 'x86_64', 'arm64-v8a'];
193
export const VALID_CHANNELS: Array<string> = ['stable', 'beta', 'dev', 'canary'];
204
export const MIN_PORT = 5554;
@@ -28,12 +12,6 @@ export function playstoreTargetSubstitution(target: string): string {
2812
return target;
2913
}
3014

31-
export function checkTarget(target: string): void {
32-
if (!VALID_TARGETS.includes(playstoreTargetSubstitution(target))) {
33-
throw new Error(`Value for input.target '${target}' is unknown. Supported options: ${VALID_TARGETS}.`);
34-
}
35-
}
36-
3715
export function checkArch(arch: string): void {
3816
if (!VALID_ARCHS.includes(arch)) {
3917
throw new Error(`Value for input.arch '${arch}' is unknown. Supported options: ${VALID_ARCHS}.`);

src/main.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as core from '@actions/core';
22
import { installAndroidSdk } from './sdk-installer';
33
import {
4-
checkTarget,
54
checkArch,
65
checkDisableAnimations,
76
checkEmulatorBuild,
@@ -54,7 +53,6 @@ async function run() {
5453

5554
// target of the system image
5655
const target = playstoreTargetSubstitution(core.getInput('target'));
57-
checkTarget(target);
5856
console.log(`target: ${target}`);
5957

6058
// CPU architecture of the system image

0 commit comments

Comments
 (0)