mirror of
https://github.com/game-ci/unity-test-runner.git
synced 2026-01-29 06:20:07 +08:00
* Added basic framework for enable code coverage * Added basic coverage results building and combination * fixed ENABLE_CODE_COVERAGE to be `true` or `false` * Added code coverage project to manifest * Updated to add more tests for code coverage build * Updated coverage parameter documentation * Fixed small syntax error * Enabled code coverage flag for code coverage tests * Fixed error in test file build * Updated project run settings * Fixed error when creating combined code coverage results * Updated testing workflows * updated test workflows * Updated parameters and added tests * Updated tests and bash script for running * Updated run_tests.sh script to simplfy some parameters * Updated run_tests to remove incorrect ';' * Updated run_tests script * Fixed small syntax error * Fixed for loop in run_tests.sh * Updated run_tests syntax error for '=' operator * Fixed runTests variable assignment * Fixed parameters for running tests via bash * Corrected bash arguments * Updated test cases in main.yml * Updated parameter names and default values for code coverage * Fixed broken paths for coverage results upload in main.yml * Corrected names of coverage results artifacts
73 lines
2.3 KiB
TypeScript
73 lines
2.3 KiB
TypeScript
import UnityVersionParser from './unity-version-parser';
|
|
import { getInput } from '@actions/core';
|
|
|
|
const Input = {
|
|
get testModes() {
|
|
return ['all', 'playmode', 'editmode'];
|
|
},
|
|
|
|
isValidFolderName(folderName) {
|
|
const validFolderName = new RegExp(/^(\.|\.\/)?(\.?[\w~]+([ _-]?[\w~]+)*\/?)*$/);
|
|
|
|
return validFolderName.test(folderName);
|
|
},
|
|
|
|
getFromUser() {
|
|
// Input variables specified in workflow using "with" prop.
|
|
const unityVersion = getInput('unityVersion') || 'auto';
|
|
const customImage = getInput('customImage') || '';
|
|
const rawProjectPath = getInput('projectPath') || '.';
|
|
const customParameters = getInput('customParameters') || '';
|
|
const testMode = (getInput('testMode') || 'all').toLowerCase();
|
|
const coverageOptions = getInput('coverageOptions') || '';
|
|
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
|
|
const rawUseHostNetwork = getInput('useHostNetwork') || 'false';
|
|
const sshAgent = getInput('sshAgent') || '';
|
|
const gitPrivateToken = getInput('gitPrivateToken') || '';
|
|
const githubToken = getInput('githubToken') || '';
|
|
const checkName = getInput('checkName') || 'Test Results';
|
|
|
|
// Validate input
|
|
if (!this.testModes.includes(testMode)) {
|
|
throw new Error(`Invalid testMode ${testMode}`);
|
|
}
|
|
|
|
if (!this.isValidFolderName(rawProjectPath)) {
|
|
throw new Error(`Invalid projectPath "${rawProjectPath}"`);
|
|
}
|
|
|
|
if (!this.isValidFolderName(rawArtifactsPath)) {
|
|
throw new Error(`Invalid artifactsPath "${rawArtifactsPath}"`);
|
|
}
|
|
|
|
if (rawUseHostNetwork !== 'true' && rawUseHostNetwork !== 'false') {
|
|
throw new Error(`Invalid useHostNetwork "${rawUseHostNetwork}"`);
|
|
}
|
|
|
|
// Sanitise input
|
|
const projectPath = rawProjectPath.replace(/\/$/, '');
|
|
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
|
const useHostNetwork = rawUseHostNetwork === 'true';
|
|
const editorVersion =
|
|
unityVersion === 'auto' ? UnityVersionParser.read(projectPath) : unityVersion;
|
|
|
|
// Return sanitised input
|
|
return {
|
|
editorVersion,
|
|
customImage,
|
|
projectPath,
|
|
customParameters,
|
|
testMode,
|
|
coverageOptions,
|
|
artifactsPath,
|
|
useHostNetwork,
|
|
sshAgent,
|
|
gitPrivateToken,
|
|
githubToken,
|
|
checkName,
|
|
};
|
|
},
|
|
};
|
|
|
|
export default Input;
|