mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-08-31 17:49:33 +00:00
Add eslint and prettier.
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"node": true,
|
||||||
|
"jest": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"prettier/@typescript-eslint",
|
||||||
|
"plugin:prettier/recommended"
|
||||||
|
],
|
||||||
|
"globals": {
|
||||||
|
"Atomics": "readonly",
|
||||||
|
"SharedArrayBuffer": "readonly"
|
||||||
|
},
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2018,
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint",
|
||||||
|
"prettier"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"prettier/prettier": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"printWidth": 200
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@typescript-eslint/explicit-function-return-type": "off"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,10 +18,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: build and test
|
- name: build, test and lint
|
||||||
run: |
|
run: |
|
||||||
npm install
|
npm install
|
||||||
npm run build
|
npm run build
|
||||||
|
npm run lint
|
||||||
npm test
|
npm test
|
||||||
|
|
||||||
- name: run action
|
- name: run action
|
||||||
|
|||||||
@@ -2,70 +2,98 @@ import * as validator from '../src/input-validator';
|
|||||||
|
|
||||||
describe('api-level validator tests', () => {
|
describe('api-level validator tests', () => {
|
||||||
it('Throws if api-level is not a number', () => {
|
it('Throws if api-level is not a number', () => {
|
||||||
const func = function() { validator.checkApiLevel('api'); }
|
const func = () => {
|
||||||
|
validator.checkApiLevel('api');
|
||||||
|
};
|
||||||
expect(func).toThrowError(`Unexpected API level: 'api'.`);
|
expect(func).toThrowError(`Unexpected API level: 'api'.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Throws if api-level is not an integer', () => {
|
it('Throws if api-level is not an integer', () => {
|
||||||
const func = function() { validator.checkApiLevel('29.1'); }
|
const func = () => {
|
||||||
|
validator.checkApiLevel('29.1');
|
||||||
|
};
|
||||||
expect(func).toThrowError(`Unexpected API level: '29.1'.`);
|
expect(func).toThrowError(`Unexpected API level: '29.1'.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Throws if api-level is lower than min API supported', () => {
|
it('Throws if api-level is lower than min API supported', () => {
|
||||||
const func = function() { validator.checkApiLevel('20'); }
|
const func = () => {
|
||||||
|
validator.checkApiLevel('20');
|
||||||
|
};
|
||||||
expect(func).toThrowError(`Minimum API level supported is ${validator.MIN_API_LEVEL}.`);
|
expect(func).toThrowError(`Minimum API level supported is ${validator.MIN_API_LEVEL}.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Validates successfully with valid api-level', () => {
|
it('Validates successfully with valid api-level', () => {
|
||||||
const func1 = function() { validator.checkApiLevel('21'); }
|
const func1 = () => {
|
||||||
|
validator.checkApiLevel('21');
|
||||||
|
};
|
||||||
expect(func1).not.toThrow();
|
expect(func1).not.toThrow();
|
||||||
|
|
||||||
const func2 = function() { validator.checkApiLevel('29'); }
|
const func2 = () => {
|
||||||
|
validator.checkApiLevel('29');
|
||||||
|
};
|
||||||
expect(func2).not.toThrow();
|
expect(func2).not.toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('target validator tests', () => {
|
describe('target validator tests', () => {
|
||||||
it('Throws if target is unknown', () => {
|
it('Throws if target is unknown', () => {
|
||||||
const func = function() { validator.checkTarget('some-target'); }
|
const func = () => {
|
||||||
|
validator.checkTarget('some-target');
|
||||||
|
};
|
||||||
expect(func).toThrowError(`Value for input.target 'some-target' is unknown. Supported options: ${validator.VALID_TARGETS}`);
|
expect(func).toThrowError(`Value for input.target 'some-target' is unknown. Supported options: ${validator.VALID_TARGETS}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Validates successfully with valid target', () => {
|
it('Validates successfully with valid target', () => {
|
||||||
const func1 = function() { validator.checkTarget('default'); }
|
const func1 = () => {
|
||||||
|
validator.checkTarget('default');
|
||||||
|
};
|
||||||
expect(func1).not.toThrow();
|
expect(func1).not.toThrow();
|
||||||
|
|
||||||
const func2 = function() { validator.checkTarget('google_apis'); }
|
const func2 = () => {
|
||||||
|
validator.checkTarget('google_apis');
|
||||||
|
};
|
||||||
expect(func2).not.toThrow();
|
expect(func2).not.toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('abi validator tests', () => {
|
describe('abi validator tests', () => {
|
||||||
it('Throws if abi is unknown', () => {
|
it('Throws if abi is unknown', () => {
|
||||||
const func = function() { validator.checkAbi('some-abi'); }
|
const func = () => {
|
||||||
|
validator.checkAbi('some-abi');
|
||||||
|
};
|
||||||
expect(func).toThrowError(`Value for input.abi 'some-abi' is unknown. Supported options: ${validator.VALID_ABIS}`);
|
expect(func).toThrowError(`Value for input.abi 'some-abi' is unknown. Supported options: ${validator.VALID_ABIS}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Validates successfully with valid abi', () => {
|
it('Validates successfully with valid abi', () => {
|
||||||
const func1 = function() { validator.checkAbi('x86'); }
|
const func1 = () => {
|
||||||
|
validator.checkAbi('x86');
|
||||||
|
};
|
||||||
expect(func1).not.toThrow();
|
expect(func1).not.toThrow();
|
||||||
|
|
||||||
const func2 = function() { validator.checkAbi('x86_64'); }
|
const func2 = () => {
|
||||||
|
validator.checkAbi('x86_64');
|
||||||
|
};
|
||||||
expect(func2).not.toThrow();
|
expect(func2).not.toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('headless validator tests', () => {
|
describe('headless validator tests', () => {
|
||||||
it('Throws if headless is not a boolean', () => {
|
it('Throws if headless is not a boolean', () => {
|
||||||
const func = function() { validator.checkHeadless('yes'); }
|
const func = () => {
|
||||||
|
validator.checkHeadless('yes');
|
||||||
|
};
|
||||||
expect(func).toThrowError(`Input for input.headless should be either 'true' or 'false'.`);
|
expect(func).toThrowError(`Input for input.headless should be either 'true' or 'false'.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Validates successfully if headless is either true or false', () => {
|
it('Validates successfully if headless is either true or false', () => {
|
||||||
const func1 = function() { validator.checkHeadless('true'); }
|
const func1 = () => {
|
||||||
|
validator.checkHeadless('true');
|
||||||
|
};
|
||||||
expect(func1).not.toThrow();
|
expect(func1).not.toThrow();
|
||||||
|
|
||||||
const func2 = function() { validator.checkHeadless('false'); }
|
const func2 = () => {
|
||||||
|
validator.checkHeadless('false');
|
||||||
|
};
|
||||||
expect(func2).not.toThrow();
|
expect(func2).not.toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Generated
+904
File diff suppressed because it is too large
Load Diff
+9
-1
@@ -6,7 +6,8 @@
|
|||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"test": "jest"
|
"test": "tsc --noEmit && jest",
|
||||||
|
"lint": "eslint . --ext .ts"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -27,8 +28,15 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^24.0.13",
|
"@types/jest": "^24.0.13",
|
||||||
"@types/node": "^12.0.4",
|
"@types/node": "^12.0.4",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^2.6.1",
|
||||||
|
"@typescript-eslint/parser": "^2.6.1",
|
||||||
|
"eslint": "^6.6.0",
|
||||||
|
"eslint-config-prettier": "^6.5.0",
|
||||||
|
"eslint-plugin-import": "^2.18.2",
|
||||||
|
"eslint-plugin-prettier": "^3.1.1",
|
||||||
"jest": "^24.8.0",
|
"jest": "^24.8.0",
|
||||||
"jest-circus": "^24.7.1",
|
"jest-circus": "^24.7.1",
|
||||||
|
"prettier": "^1.18.2",
|
||||||
"ts-jest": "^24.0.2",
|
"ts-jest": "^24.0.2",
|
||||||
"typescript": "^3.5.1"
|
"typescript": "^3.5.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Creates and launches a new AVD instance with the specified configurations.
|
* Creates and launches a new AVD instance with the specified configurations.
|
||||||
*/
|
*/
|
||||||
export async function startEmulator(
|
export async function startEmulator(): Promise<void> {
|
||||||
|
|
||||||
): Promise<void> {
|
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { isNumber } from "util";
|
|
||||||
|
|
||||||
export const MIN_API_LEVEL = 21;
|
export const MIN_API_LEVEL = 21;
|
||||||
export const VALID_TARGETS: Array<string> = ['default', 'google_apis'];
|
export const VALID_TARGETS: Array<string> = ['default', 'google_apis'];
|
||||||
export const VALID_ABIS: Array<string> = ['x86', 'x86_64'];
|
export const VALID_ABIS: Array<string> = ['x86', 'x86_64'];
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import { InputOptions } from "@actions/core/lib/core";
|
import { InputOptions } from '@actions/core/lib/core';
|
||||||
import { installAndroidSdk } from './sdk-installer';
|
import { installAndroidSdk } from './sdk-installer';
|
||||||
import { checkApiLevel, checkTarget, checkAbi, checkHeadless } from './input-validator';
|
import { checkApiLevel, checkTarget, checkAbi, checkHeadless } from './input-validator';
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ async function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// API level of the platform and system image
|
// API level of the platform and system image
|
||||||
const apiLevel = core.getInput('api-level', <InputOptions>{required: true});
|
const apiLevel = core.getInput('api-level', { required: true } as InputOptions);
|
||||||
checkApiLevel(apiLevel);
|
checkApiLevel(apiLevel);
|
||||||
console.log(`API level: ${apiLevel}`);
|
console.log(`API level: ${apiLevel}`);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user