Generate test coverage

pull/176/head
Paul Pacheco 2022-03-28 10:08:55 -05:00
parent 920c3b6d23
commit 7bf7583106
5 changed files with 25 additions and 0 deletions

View File

@ -20,6 +20,10 @@ inputs:
required: false required: false
default: 'all' default: 'all'
description: 'The type of tests to be run by the test runner.' description: 'The type of tests to be run by the test runner.'
coverageReport:
required: false
default: false
description: 'Whether to generate a coverage report.'
artifactsPath: artifactsPath:
required: false required: false
default: 'artifacts' default: 'artifacts'

View File

@ -14,6 +14,12 @@ echo "Using project path \"$UNITY_PROJECT_PATH\"."
echo "Using artifacts path \"$ARTIFACTS_PATH\" to save test results." echo "Using artifacts path \"$ARTIFACTS_PATH\" to save test results."
FULL_ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_PATH FULL_ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_PATH
COVERAGE=""
if [ "$GENERATE_COVERAGE_REPORT" == "true" ]; then
echo "Generating code coverage report."
COVERAGE="-enableCodeCoverage"
fi
# #
# Display custom parameters # Display custom parameters
# #
@ -81,6 +87,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" \
-coverageResultsPath "$FULL_ARTIFACTS_PATH" \
$COVERAGE \
$CUSTOM_PARAMETERS $CUSTOM_PARAMETERS
# Catch exit code # Catch exit code
@ -118,6 +126,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" \
-coverageResultsPath "$FULL_ARTIFACTS_PATH" \
$COVERAGE \
$CUSTOM_PARAMETERS $CUSTOM_PARAMETERS
# Catch exit code # Catch exit code

View File

@ -12,6 +12,7 @@ async function run() {
projectPath, projectPath,
customParameters, customParameters,
testMode, testMode,
generateCoverageReport,
artifactsPath, artifactsPath,
useHostNetwork, useHostNetwork,
sshAgent, sshAgent,
@ -33,6 +34,7 @@ async function run() {
projectPath, projectPath,
customParameters, customParameters,
testMode, testMode,
generateCoverageReport,
artifactsPath, artifactsPath,
useHostNetwork, useHostNetwork,
sshAgent, sshAgent,

View File

@ -26,6 +26,7 @@ const Docker = {
projectPath, projectPath,
customParameters, customParameters,
testMode, testMode,
generateCoverageReport,
artifactsPath, artifactsPath,
useHostNetwork, useHostNetwork,
sshAgent, sshAgent,
@ -51,6 +52,7 @@ const Docker = {
--env PROJECT_PATH="${projectPath}" \ --env PROJECT_PATH="${projectPath}" \
--env CUSTOM_PARAMETERS="${customParameters}" \ --env CUSTOM_PARAMETERS="${customParameters}" \
--env TEST_MODE="${testMode}" \ --env TEST_MODE="${testMode}" \
--env GENERATE_COVERAGE_REPORT="${generateCoverageReport}" \
--env ARTIFACTS_PATH="${artifactsPath}" \ --env ARTIFACTS_PATH="${artifactsPath}" \
--env GITHUB_REF \ --env GITHUB_REF \
--env GITHUB_SHA \ --env GITHUB_SHA \

View File

@ -19,6 +19,7 @@ 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 coverageReport = getInput('coverageReport') || 'false';
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') || '';
@ -31,6 +32,10 @@ const Input = {
throw new Error(`Invalid testMode ${testMode}`); throw new Error(`Invalid testMode ${testMode}`);
} }
if (coverageReport !== 'true' && coverageReport !== 'false') {
throw new Error(`Invalid coverageReport "${coverageReport}"`);
}
if (!this.isValidFolderName(rawProjectPath)) { if (!this.isValidFolderName(rawProjectPath)) {
throw new Error(`Invalid projectPath "${rawProjectPath}"`); throw new Error(`Invalid projectPath "${rawProjectPath}"`);
} }
@ -44,6 +49,7 @@ const Input = {
} }
// Sanitise input // Sanitise input
const generateCoverageReport = coverageReport === 'true';
const projectPath = rawProjectPath.replace(/\/$/, ''); const projectPath = rawProjectPath.replace(/\/$/, '');
const artifactsPath = rawArtifactsPath.replace(/\/$/, ''); const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
const useHostNetwork = rawUseHostNetwork === 'true'; const useHostNetwork = rawUseHostNetwork === 'true';
@ -57,6 +63,7 @@ const Input = {
projectPath, projectPath,
customParameters, customParameters,
testMode, testMode,
generateCoverageReport,
artifactsPath, artifactsPath,
useHostNetwork, useHostNetwork,
sshAgent, sshAgent,