Added basic coverage results building and combination
parent
d6f31010f5
commit
3407decdfb
|
@ -24,6 +24,14 @@ inputs:
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
description: 'Should code coverage results be collected for the test run.'
|
description: 'Should code coverage results be collected for the test run.'
|
||||||
|
coverageAssemblyFilters:
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
description: 'Optional coverage assembly filters when collecting code coverage.'
|
||||||
|
coverageResultsPath:
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
description: 'Path to write coverage results to when collecting code coverage.'
|
||||||
artifactsPath:
|
artifactsPath:
|
||||||
required: false
|
required: false
|
||||||
default: 'artifacts'
|
default: 'artifacts'
|
||||||
|
|
|
@ -42,7 +42,7 @@ function run() {
|
||||||
try {
|
try {
|
||||||
model_1.Action.checkCompatibility();
|
model_1.Action.checkCompatibility();
|
||||||
const { workspace, actionFolder } = model_1.Action;
|
const { workspace, actionFolder } = model_1.Action;
|
||||||
const { editorVersion, customImage, projectPath, customParameters, testMode, enableCodeCoverage, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, checkName, } = model_1.Input.getFromUser();
|
const { editorVersion, customImage, projectPath, customParameters, testMode, enableCodeCoverage, coverageAssemblyFilters, coverageResultsPath, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, checkName, } = model_1.Input.getFromUser();
|
||||||
const baseImage = new model_1.ImageTag({ editorVersion, customImage });
|
const baseImage = new model_1.ImageTag({ editorVersion, customImage });
|
||||||
const runnerTemporaryPath = process.env.RUNNER_TEMP;
|
const runnerTemporaryPath = process.env.RUNNER_TEMP;
|
||||||
try {
|
try {
|
||||||
|
@ -54,6 +54,8 @@ function run() {
|
||||||
customParameters,
|
customParameters,
|
||||||
testMode,
|
testMode,
|
||||||
enableCodeCoverage,
|
enableCodeCoverage,
|
||||||
|
coverageAssemblyFilters,
|
||||||
|
coverageResultsPath,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
sshAgent,
|
sshAgent,
|
||||||
|
@ -153,7 +155,7 @@ const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
const Docker = {
|
const Docker = {
|
||||||
run(image, parameters, silent = false) {
|
run(image, parameters, silent = false) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { actionFolder, editorVersion, workspace, projectPath, customParameters, testMode, enableCodeCoverage, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, runnerTemporaryPath, } = parameters;
|
const { actionFolder, editorVersion, workspace, projectPath, customParameters, testMode, enableCodeCoverage, coverageAssemblyFilters, coverageResultsPath, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, runnerTemporaryPath, } = parameters;
|
||||||
const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home');
|
const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home');
|
||||||
if (!(0, fs_1.existsSync)(githubHome))
|
if (!(0, fs_1.existsSync)(githubHome))
|
||||||
(0, fs_1.mkdirSync)(githubHome);
|
(0, fs_1.mkdirSync)(githubHome);
|
||||||
|
@ -173,6 +175,8 @@ const Docker = {
|
||||||
--env CUSTOM_PARAMETERS="${customParameters}" \
|
--env CUSTOM_PARAMETERS="${customParameters}" \
|
||||||
--env TEST_MODE="${testMode}" \
|
--env TEST_MODE="${testMode}" \
|
||||||
--env ENABLE_CODE_COVERAGE="${enableCodeCoverage}" \
|
--env ENABLE_CODE_COVERAGE="${enableCodeCoverage}" \
|
||||||
|
--env COVERAGE_ASSEMBLY_FILTERS="${coverageAssemblyFilters}" \
|
||||||
|
--env COVERAGE_RESULTS_PATH="${coverageResultsPath}" \
|
||||||
--env ARTIFACTS_PATH="${artifactsPath}" \
|
--env ARTIFACTS_PATH="${artifactsPath}" \
|
||||||
--env GITHUB_REF \
|
--env GITHUB_REF \
|
||||||
--env GITHUB_SHA \
|
--env GITHUB_SHA \
|
||||||
|
@ -387,7 +391,9 @@ const Input = {
|
||||||
const rawProjectPath = (0, core_1.getInput)('projectPath') || '.';
|
const rawProjectPath = (0, core_1.getInput)('projectPath') || '.';
|
||||||
const customParameters = (0, core_1.getInput)('customParameters') || '';
|
const customParameters = (0, core_1.getInput)('customParameters') || '';
|
||||||
const testMode = ((0, core_1.getInput)('testMode') || 'all').toLowerCase();
|
const testMode = ((0, core_1.getInput)('testMode') || 'all').toLowerCase();
|
||||||
const enableCodeCoverage = (0, core_1.getInput)('enableCodeCoverage') || 'false';
|
const rawEnableCodeCoverage = (0, core_1.getInput)('enableCodeCoverage') || 'false';
|
||||||
|
const coverageAssemblyFilters = (0, core_1.getInput)('coverageAssemblyFilters') || '';
|
||||||
|
const rawCoverageResultsPath = (0, core_1.getInput)('coverageResultsPath') || '';
|
||||||
const rawArtifactsPath = (0, core_1.getInput)('artifactsPath') || 'artifacts';
|
const rawArtifactsPath = (0, core_1.getInput)('artifactsPath') || 'artifacts';
|
||||||
const rawUseHostNetwork = (0, core_1.getInput)('useHostNetwork') || 'false';
|
const rawUseHostNetwork = (0, core_1.getInput)('useHostNetwork') || 'false';
|
||||||
const sshAgent = (0, core_1.getInput)('sshAgent') || '';
|
const sshAgent = (0, core_1.getInput)('sshAgent') || '';
|
||||||
|
@ -398,8 +404,23 @@ const Input = {
|
||||||
if (!this.testModes.includes(testMode)) {
|
if (!this.testModes.includes(testMode)) {
|
||||||
throw new Error(`Invalid testMode ${testMode}`);
|
throw new Error(`Invalid testMode ${testMode}`);
|
||||||
}
|
}
|
||||||
if (enableCodeCoverage !== 'true' && enableCodeCoverage !== 'false') {
|
if (rawEnableCodeCoverage !== 'true' && rawEnableCodeCoverage !== 'false') {
|
||||||
throw new Error(`Invalid enableCodeCoverage "${enableCodeCoverage}"`);
|
throw new Error(`Invalid enableCodeCoverage "${rawEnableCodeCoverage}"`);
|
||||||
|
}
|
||||||
|
if (rawEnableCodeCoverage !== 'true' && rawEnableCodeCoverage !== 'false') {
|
||||||
|
throw new Error(`Invalid enableCodeCoverage "${rawEnableCodeCoverage}"`);
|
||||||
|
}
|
||||||
|
if (rawEnableCodeCoverage !== 'true' && coverageAssemblyFilters !== '') {
|
||||||
|
throw new Error(`coverageAssemblyFilters should not be set if enableCodeCoverage is not enabled.`);
|
||||||
|
}
|
||||||
|
if (coverageAssemblyFilters !== '') {
|
||||||
|
throw new Error(`coverageAssemblyFilters should not be set if enableCodeCoverage is not enabled.`);
|
||||||
|
}
|
||||||
|
if (rawEnableCodeCoverage !== 'true' && rawCoverageResultsPath !== '') {
|
||||||
|
throw new Error(`coverageResultsPath should not be set if enableCodeCoverage is not enabled.`);
|
||||||
|
}
|
||||||
|
if (!this.isValidFolderName(rawCoverageResultsPath)) {
|
||||||
|
throw new Error(`Invalid coverageResultsPath "${rawCoverageResultsPath}"`);
|
||||||
}
|
}
|
||||||
if (!this.isValidFolderName(rawProjectPath)) {
|
if (!this.isValidFolderName(rawProjectPath)) {
|
||||||
throw new Error(`Invalid projectPath "${rawProjectPath}"`);
|
throw new Error(`Invalid projectPath "${rawProjectPath}"`);
|
||||||
|
@ -414,6 +435,8 @@ const Input = {
|
||||||
const projectPath = rawProjectPath.replace(/\/$/, '');
|
const projectPath = rawProjectPath.replace(/\/$/, '');
|
||||||
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
||||||
const useHostNetwork = rawUseHostNetwork === 'true';
|
const useHostNetwork = rawUseHostNetwork === 'true';
|
||||||
|
const enableCodeCoverage = rawEnableCodeCoverage === 'true';
|
||||||
|
const coverageResultsPath = rawCoverageResultsPath.replace(/\/$/, '');
|
||||||
const editorVersion = unityVersion === 'auto' ? unity_version_parser_1.default.read(projectPath) : unityVersion;
|
const editorVersion = unityVersion === 'auto' ? unity_version_parser_1.default.read(projectPath) : unityVersion;
|
||||||
// Return sanitised input
|
// Return sanitised input
|
||||||
return {
|
return {
|
||||||
|
@ -423,6 +446,8 @@ const Input = {
|
||||||
customParameters,
|
customParameters,
|
||||||
testMode,
|
testMode,
|
||||||
enableCodeCoverage,
|
enableCodeCoverage,
|
||||||
|
coverageAssemblyFilters,
|
||||||
|
coverageResultsPath,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
sshAgent,
|
sshAgent,
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -36,6 +36,38 @@ case $TEST_MODE in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build code coverage parameters
|
||||||
|
#
|
||||||
|
CODE_COVERAGE_PARAMETERS=""
|
||||||
|
if [ "$ENABLE_CODE_COVERAGE" = "true" ]; then
|
||||||
|
# Configure code coverage options
|
||||||
|
COVERAGE_OPTIONS=""
|
||||||
|
ASSEMBLY_FILTER_OPTIONS=""
|
||||||
|
COVERAGE_RESULTS_OPTIONS=""
|
||||||
|
|
||||||
|
# Setup assembly filters if provided
|
||||||
|
if [ -n "$COVERAGE_ASSEMBLY_FILTERS" ]; then
|
||||||
|
ASSEMBLY_FILTER_OPTIONS=";assemblyFilters:$COVERAGE_ASSEMBLY_FILTERS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setup coverage results path if provided
|
||||||
|
if [ -n "$COVERAGE_RESULTS_PATH" ]; then
|
||||||
|
COVERAGE_RESULTS_OPTIONS="-coverageResultsPath $COVERAGE_RESULTS_PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Options to combine both playmode and editmode results
|
||||||
|
if [ "$EDIT_MODE" = "true" ] && [ "$PLAY_MODE" = "true" ]; then
|
||||||
|
COVERAGE_OPTIONS="enableCyclomaticComplexity$ASSEMBLY_FILTER_OPTIONS"
|
||||||
|
else
|
||||||
|
COVERAGE_OPTIONS="enableCyclomaticComplexity;generateHtmlReport;generateBadgeReport$ASSEMBLY_FILTER_OPTIONS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set parameters for code coverage
|
||||||
|
CODE_COVERAGE_PARAMETERS="-debugCodeOptimization -enableCodeCoverage -coverageOptions $COVERAGE_OPTIONS $COVERAGE_RESULTS_OPTIONS"
|
||||||
|
fi
|
||||||
|
echo "Using code coverage parameters $CODE_COVERAGE_PARAMETERS."
|
||||||
|
|
||||||
# The following tests are 2019 mode (requires Unity 2019.2.11f1 or later)
|
# The following tests are 2019 mode (requires Unity 2019.2.11f1 or later)
|
||||||
# Reference: https://docs.unity3d.com/2019.3/Documentation/Manual/CommandLineArguments.html
|
# Reference: https://docs.unity3d.com/2019.3/Documentation/Manual/CommandLineArguments.html
|
||||||
|
|
||||||
|
@ -81,7 +113,8 @@ if [ "$EDIT_MODE" = "true" ]; then
|
||||||
-runTests \
|
-runTests \
|
||||||
-testPlatform editmode \
|
-testPlatform editmode \
|
||||||
-testResults "$FULL_ARTIFACTS_PATH/editmode-results.xml" \
|
-testResults "$FULL_ARTIFACTS_PATH/editmode-results.xml" \
|
||||||
$CUSTOM_PARAMETERS
|
$CUSTOM_PARAMETERS \
|
||||||
|
$CODE_COVERAGE_PARAMETERS
|
||||||
|
|
||||||
# Catch exit code
|
# Catch exit code
|
||||||
EDIT_MODE_EXIT_CODE=$?
|
EDIT_MODE_EXIT_CODE=$?
|
||||||
|
@ -118,7 +151,8 @@ if [ "$PLAY_MODE" = "true" ]; then
|
||||||
-runTests \
|
-runTests \
|
||||||
-testPlatform playmode \
|
-testPlatform playmode \
|
||||||
-testResults "$FULL_ARTIFACTS_PATH/playmode-results.xml" \
|
-testResults "$FULL_ARTIFACTS_PATH/playmode-results.xml" \
|
||||||
$CUSTOM_PARAMETERS
|
$CUSTOM_PARAMETERS \
|
||||||
|
$CODE_COVERAGE_PARAMETERS
|
||||||
|
|
||||||
# Catch exit code
|
# Catch exit code
|
||||||
PLAY_MODE_EXIT_CODE=$?
|
PLAY_MODE_EXIT_CODE=$?
|
||||||
|
@ -169,6 +203,32 @@ if [ "$PLAY_MODE" = "true" ]; then
|
||||||
cat "$FULL_ARTIFACTS_PATH/playmode-results.xml" | grep test-run | grep Passed
|
cat "$FULL_ARTIFACTS_PATH/playmode-results.xml" | grep test-run | grep Passed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Combine test results if needed
|
||||||
|
#
|
||||||
|
if [ "$EDIT_MODE" = "true" ] && [ "$PLAY_MODE" = "true" ] && [ "$ENABLE_CODE_COVERAGE" = "true" ]; then
|
||||||
|
# Setup coverage results path if provided
|
||||||
|
COVERAGE_RESULTS_OPTIONS=""
|
||||||
|
if [ -n "$COVERAGE_RESULTS_PATH" ]; then
|
||||||
|
COVERAGE_RESULTS_OPTIONS="-coverageResultsPath $COVERAGE_RESULTS_PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "##############################"
|
||||||
|
echo "# Combining Coverage Results #"
|
||||||
|
echo "##############################"
|
||||||
|
echo ""
|
||||||
|
unity-editor \
|
||||||
|
-batchmode \
|
||||||
|
-debugCodeOptimization \
|
||||||
|
-enableCodeCoverage \
|
||||||
|
-logFile "$FULL_ARTIFACTS_PATH/coverage_combination.log" \
|
||||||
|
-projectPath "$UNITY_PROJECT_PATH" \
|
||||||
|
$COVERAGE_RESULTS_OPTIONS \
|
||||||
|
-coverageOptions generateHtmlReport;generateBadgeReport \
|
||||||
|
-quit
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Exit
|
# Exit
|
||||||
#
|
#
|
||||||
|
|
|
@ -13,6 +13,8 @@ async function run() {
|
||||||
customParameters,
|
customParameters,
|
||||||
testMode,
|
testMode,
|
||||||
enableCodeCoverage,
|
enableCodeCoverage,
|
||||||
|
coverageAssemblyFilters,
|
||||||
|
coverageResultsPath,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
sshAgent,
|
sshAgent,
|
||||||
|
@ -32,6 +34,8 @@ async function run() {
|
||||||
customParameters,
|
customParameters,
|
||||||
testMode,
|
testMode,
|
||||||
enableCodeCoverage,
|
enableCodeCoverage,
|
||||||
|
coverageAssemblyFilters,
|
||||||
|
coverageResultsPath,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
sshAgent,
|
sshAgent,
|
||||||
|
|
|
@ -12,6 +12,8 @@ const Docker = {
|
||||||
customParameters,
|
customParameters,
|
||||||
testMode,
|
testMode,
|
||||||
enableCodeCoverage,
|
enableCodeCoverage,
|
||||||
|
coverageAssemblyFilters,
|
||||||
|
coverageResultsPath,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
sshAgent,
|
sshAgent,
|
||||||
|
@ -38,6 +40,8 @@ const Docker = {
|
||||||
--env CUSTOM_PARAMETERS="${customParameters}" \
|
--env CUSTOM_PARAMETERS="${customParameters}" \
|
||||||
--env TEST_MODE="${testMode}" \
|
--env TEST_MODE="${testMode}" \
|
||||||
--env ENABLE_CODE_COVERAGE="${enableCodeCoverage}" \
|
--env ENABLE_CODE_COVERAGE="${enableCodeCoverage}" \
|
||||||
|
--env COVERAGE_ASSEMBLY_FILTERS="${coverageAssemblyFilters}" \
|
||||||
|
--env COVERAGE_RESULTS_PATH="${coverageResultsPath}" \
|
||||||
--env ARTIFACTS_PATH="${artifactsPath}" \
|
--env ARTIFACTS_PATH="${artifactsPath}" \
|
||||||
--env GITHUB_REF \
|
--env GITHUB_REF \
|
||||||
--env GITHUB_SHA \
|
--env GITHUB_SHA \
|
||||||
|
|
|
@ -19,7 +19,9 @@ const Input = {
|
||||||
const rawProjectPath = getInput('projectPath') || '.';
|
const rawProjectPath = getInput('projectPath') || '.';
|
||||||
const customParameters = getInput('customParameters') || '';
|
const customParameters = getInput('customParameters') || '';
|
||||||
const testMode = (getInput('testMode') || 'all').toLowerCase();
|
const testMode = (getInput('testMode') || 'all').toLowerCase();
|
||||||
const enableCodeCoverage = getInput('enableCodeCoverage') || 'false';
|
const rawEnableCodeCoverage = getInput('enableCodeCoverage') || 'false';
|
||||||
|
const coverageAssemblyFilters = getInput('coverageAssemblyFilters') || '';
|
||||||
|
const rawCoverageResultsPath = getInput('coverageResultsPath') || '';
|
||||||
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
|
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
|
||||||
const rawUseHostNetwork = getInput('useHostNetwork') || 'false';
|
const rawUseHostNetwork = getInput('useHostNetwork') || 'false';
|
||||||
const sshAgent = getInput('sshAgent') || '';
|
const sshAgent = getInput('sshAgent') || '';
|
||||||
|
@ -32,8 +34,34 @@ const Input = {
|
||||||
throw new Error(`Invalid testMode ${testMode}`);
|
throw new Error(`Invalid testMode ${testMode}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableCodeCoverage !== 'true' && enableCodeCoverage !== 'false') {
|
if (rawEnableCodeCoverage !== 'true' && rawEnableCodeCoverage !== 'false') {
|
||||||
throw new Error(`Invalid enableCodeCoverage "${enableCodeCoverage}"`);
|
throw new Error(`Invalid enableCodeCoverage "${rawEnableCodeCoverage}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rawEnableCodeCoverage !== 'true' && rawEnableCodeCoverage !== 'false') {
|
||||||
|
throw new Error(`Invalid enableCodeCoverage "${rawEnableCodeCoverage}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rawEnableCodeCoverage !== 'true' && coverageAssemblyFilters !== '') {
|
||||||
|
throw new Error(
|
||||||
|
`coverageAssemblyFilters should not be set if enableCodeCoverage is not enabled.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (coverageAssemblyFilters !== '') {
|
||||||
|
throw new Error(
|
||||||
|
`coverageAssemblyFilters should not be set if enableCodeCoverage is not enabled.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rawEnableCodeCoverage !== 'true' && rawCoverageResultsPath !== '') {
|
||||||
|
throw new Error(
|
||||||
|
`coverageResultsPath should not be set if enableCodeCoverage is not enabled.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.isValidFolderName(rawCoverageResultsPath)) {
|
||||||
|
throw new Error(`Invalid coverageResultsPath "${rawCoverageResultsPath}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isValidFolderName(rawProjectPath)) {
|
if (!this.isValidFolderName(rawProjectPath)) {
|
||||||
|
@ -52,6 +80,8 @@ const Input = {
|
||||||
const projectPath = rawProjectPath.replace(/\/$/, '');
|
const projectPath = rawProjectPath.replace(/\/$/, '');
|
||||||
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
||||||
const useHostNetwork = rawUseHostNetwork === 'true';
|
const useHostNetwork = rawUseHostNetwork === 'true';
|
||||||
|
const enableCodeCoverage = rawEnableCodeCoverage === 'true';
|
||||||
|
const coverageResultsPath = rawCoverageResultsPath.replace(/\/$/, '');
|
||||||
const editorVersion =
|
const editorVersion =
|
||||||
unityVersion === 'auto' ? UnityVersionParser.read(projectPath) : unityVersion;
|
unityVersion === 'auto' ? UnityVersionParser.read(projectPath) : unityVersion;
|
||||||
|
|
||||||
|
@ -63,6 +93,8 @@ const Input = {
|
||||||
customParameters,
|
customParameters,
|
||||||
testMode,
|
testMode,
|
||||||
enableCodeCoverage,
|
enableCodeCoverage,
|
||||||
|
coverageAssemblyFilters,
|
||||||
|
coverageResultsPath,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
sshAgent,
|
sshAgent,
|
||||||
|
|
Loading…
Reference in New Issue