Updated tests and bash script for running

pull/182/head
Nick Maltbie 2022-04-18 21:03:45 -04:00
parent 3297ad7442
commit 41bec93f8a
4 changed files with 50 additions and 113 deletions

11
dist/index.js generated vendored
View File

@ -162,6 +162,13 @@ const Docker = {
const githubWorkflow = path_1.default.join(runnerTemporaryPath, '_github_workflow');
if (!(0, fs_1.existsSync)(githubWorkflow))
(0, fs_1.mkdirSync)(githubWorkflow);
const testPlatforms = (testMode === 'all' ? ['playmode', 'editmode', 'COMBINE_RESULTS'] : [testMode]).join(';');
const coverageOptions = [
'-enableCodeCoverage',
'-debugCodeOptimization',
'-coverageOptions',
coverageParameters,
].join(' ');
const command = `docker run \
--workdir /github/workspace \
--rm \
@ -173,8 +180,8 @@ const Docker = {
--env UNITY_VERSION="${editorVersion}" \
--env PROJECT_PATH="${projectPath}" \
--env CUSTOM_PARAMETERS="${customParameters}" \
--env TEST_MODE="${testMode}" \
--env COVERAGE_OPTIONS="${coverageParameters}" \
--env TEST_PLATFORMS="${testPlatforms}" \
--env COVERAGE_OPTIONS="${coverageOptions}" \
--env COVERAGE_RESULTS_PATH="${coverageResultsPath}" \
--env ARTIFACTS_PATH="${artifactsPath}" \
--env GITHUB_REF \

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -14,6 +14,13 @@ echo "Using project path \"$UNITY_PROJECT_PATH\"."
echo "Using artifacts path \"$ARTIFACTS_PATH\" to save test results."
FULL_ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_PATH
#
# Set and display the coverage results path
#
echo "Using artifacts path \"$COVERAGE_RESULTS_PATH\" to save test coverage results."
FULL_COVERAGE_RESULTS_PATH=$GITHUB_WORKSPACE/$COVERAGE_RESULTS_PATH
#
# Display custom parameters
#
@ -69,85 +76,52 @@ echo "###########################"
echo ""
ls -alh $UNITY_PROJECT_PATH
IFS=';' read -ra test_platforms <<< "$TEST_PLATFORMS"
#
# Testing in EditMode
# Testing for each platform
#
EDIT_MODE_EXIT_CODE=0
if [ "$EDIT_MODE" = "true" ]; then
for $platform in "${test_platforms[@]}"; do
echo ""
echo "###########################"
echo "# Testing in EditMode #"
echo "# Testing in $platform #"
echo "###########################"
echo ""
unity-editor \
-batchmode \
-logFile "$FULL_ARTIFACTS_PATH/editmode.log" \
-projectPath "$UNITY_PROJECT_PATH" \
-runTests \
-testPlatform editmode \
-testResults "$FULL_ARTIFACTS_PATH/editmode-results.xml" \
-enableCodeCoverage \
-debugCodeOptimization \
-coverageResultsPath "$FULL_COVERAGE_RESULTS_PATH" \
-coverageOptions "$COVERAGE_OPTIONS" \
$CUSTOM_PARAMETERS
# Catch exit code
EDIT_MODE_EXIT_CODE=$?
# Print unity log output
cat "$FULL_ARTIFACTS_PATH/editmode.log"
# Display results
if [ $EDIT_MODE_EXIT_CODE -eq 0 ]; then
echo "Run succeeded, no failures occurred";
elif [ $EDIT_MODE_EXIT_CODE -eq 2 ]; then
echo "Run succeeded, some tests failed";
elif [ $EDIT_MODE_EXIT_CODE -eq 3 ]; then
echo "Run failure (other failure)";
if [ $platform -ne "COMBINE_RESULTS" ]; then;
$runTests = "-runTests -testPlatform $platform -testResults $FULL_ARTIFACTS_PATH/$platform-results.xml"
else
echo "Unexpected exit code $EDIT_MODE_EXIT_CODE";
$runTests = "-quit"
fi
fi
#
# Testing in PlayMode
#
PLAY_MODE_EXIT_CODE=0
if [ "$PLAY_MODE" = "true" ]; then
echo ""
echo "###########################"
echo "# Testing in PlayMode #"
echo "###########################"
echo ""
unity-editor \
-batchmode \
-logFile "$FULL_ARTIFACTS_PATH/playmode.log" \
-logFile "$FULL_ARTIFACTS_PATH/$platform.log" \
-projectPath "$UNITY_PROJECT_PATH" \
-runTests \
-testPlatform playmode \
-testResults "$FULL_ARTIFACTS_PATH/playmode-results.xml" \
-enableCodeCoverage \
-debugCodeOptimization \
-coverageResultsPath "$FULL_COVERAGE_RESULTS_PATH" \
-coverageOptions "$COVERAGE_OPTIONS" \
$runTests \
"$COVERAGE_OPTIONS" \
$CUSTOM_PARAMETERS
# Catch exit code
PLAY_MODE_EXIT_CODE=$?
TEST_EXIT_CODE=$?
# Print unity log output
cat "$FULL_ARTIFACTS_PATH/playmode.log"
cat "$FULL_ARTIFACTS_PATH/$platform.log"
# Display results
if [ $PLAY_MODE_EXIT_CODE -eq 0 ]; then
if [ $TEST_EXIT_CODE -eq 0 ]; then
echo "Run succeeded, no failures occurred";
elif [ $PLAY_MODE_EXIT_CODE -eq 2 ]; then
elif [ $TEST_EXIT_CODE -eq 2 ]; then
echo "Run succeeded, some tests failed";
elif [ $PLAY_MODE_EXIT_CODE -eq 3 ]; then
elif [ $TEST_EXIT_CODE -eq 3 ]; then
echo "Run failure (other failure)";
else
echo "Unexpected exit code $PLAY_MODE_EXIT_CODE";
echo "Unexpected exit code $TEST_EXIT_CODE";
fi
if [ $TEST_EXIT_CODE -gt 0 ]; then
TEST_RUNNER_EXIT_CODE=$TEST_EXIT_CODE
fi
fi
@ -181,56 +155,3 @@ if [ "$PLAY_MODE" = "true" ]; then
cat "$FULL_ARTIFACTS_PATH/playmode-results.xml"
cat "$FULL_ARTIFACTS_PATH/playmode-results.xml" | grep test-run | grep Passed
fi
#
# Combine test results if needed
#
COMBINE_EXIT_CODE=0
if [ "$EDIT_MODE" = "true" ] && [ "$PLAY_MODE" = "true" ] && [ "$COVERAGE" = "true" ]; then
echo ""
echo "##############################"
echo "# Combining Coverage Results #"
echo "##############################"
echo ""
unity-editor \
-batchmode \
-projectPath "$UNITY_PROJECT_PATH" \
-enableCodeCoverage \
-debugCodeOptimization \
-coverageResultsPath "$FULL_COVERAGE_RESULTS_PATH" \
-coverageOptions "$COVERAGE_OPTIONS" \
-quit
# Catch exit code
COMBINE_EXIT_CODE=$?
# Print unity log output
cat "$FULL_ARTIFACTS_PATH/combine_coverage.log"
# Display results
if [ $COMBINE_EXIT_CODE -eq 0 ]; then
echo "Combine coverage succeeded, no failures occurred";
elif [ $COMBINE_EXIT_CODE -eq 2 ]; then
echo "Combine coverage, some tests failed";
elif [ $COMBINE_EXIT_CODE -eq 3 ]; then
echo "Combine coverage (other failure)";
else
echo "Unexpected exit code $COMBINE_EXIT_CODE";
fi
fi
#
# Exit
#
if [ $EDIT_MODE_EXIT_CODE -gt 0 ]; then
TEST_RUNNER_EXIT_CODE=$EDIT_MODE_EXIT_CODE
fi
if [ $PLAY_MODE_EXIT_CODE -gt 0 ]; then
TEST_RUNNER_EXIT_CODE=$PLAY_MODE_EXIT_CODE
fi
if [ $COMBINE_EXIT_CODE -gt 0 ]; then
TEST_RUNNER_EXIT_CODE=$COMBINE_EXIT_CODE
fi

View File

@ -25,6 +25,15 @@ const Docker = {
if (!existsSync(githubHome)) mkdirSync(githubHome);
const githubWorkflow = path.join(runnerTemporaryPath, '_github_workflow');
if (!existsSync(githubWorkflow)) mkdirSync(githubWorkflow);
const testPlatforms = (
testMode === 'all' ? ['playmode', 'editmode', 'COMBINE_RESULTS'] : [testMode]
).join(';');
const coverageOptions = [
'-enableCodeCoverage',
'-debugCodeOptimization',
'-coverageOptions',
coverageParameters,
].join(' ');
const command = `docker run \
--workdir /github/workspace \
@ -37,8 +46,8 @@ const Docker = {
--env UNITY_VERSION="${editorVersion}" \
--env PROJECT_PATH="${projectPath}" \
--env CUSTOM_PARAMETERS="${customParameters}" \
--env TEST_MODE="${testMode}" \
--env COVERAGE_OPTIONS="${coverageParameters}" \
--env TEST_PLATFORMS="${testPlatforms}" \
--env COVERAGE_OPTIONS="${coverageOptions}" \
--env COVERAGE_RESULTS_PATH="${coverageResultsPath}" \
--env ARTIFACTS_PATH="${artifactsPath}" \
--env GITHUB_REF \