mirror of
https://github.com/game-ci/unity-test-runner.git
synced 2026-02-06 21:29:12 +08:00
Add action logic
This commit is contained in:
35
src/model/input.js
Normal file
35
src/model/input.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import { getInput } from '@actions/core';
|
||||
import { includes } from 'lodash-es';
|
||||
|
||||
class Input {
|
||||
static get testModes() {
|
||||
return ['all', 'playmode', 'editmode'];
|
||||
}
|
||||
|
||||
static getFromUser() {
|
||||
// Input variables specified in workflow using "with" prop.
|
||||
const unityVersion = getInput('unityVersion') || '2019.2.11f1';
|
||||
const testMode = getInput('testMode') || 'all';
|
||||
const rawProjectPath = getInput('testMode') || '.';
|
||||
const rawArtifactsPath = getInput('testMode') || 'artifacts';
|
||||
|
||||
// Validate input
|
||||
if (!includes(this.testModes, testMode)) {
|
||||
throw new Error(`Invalid testMode ${testMode}`);
|
||||
}
|
||||
|
||||
// Sanitise input
|
||||
const projectPath = rawProjectPath.replace(/\/$/, '');
|
||||
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
||||
|
||||
// Return sanitised input
|
||||
return {
|
||||
unityVersion,
|
||||
projectPath,
|
||||
testMode,
|
||||
artifactsPath,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default Input;
|
||||
Reference in New Issue
Block a user