mirror of
https://github.com/game-ci/unity-test-runner.git
synced 2026-01-29 06:20:07 +08:00
Refactor to typescript (#158)
* Refactor to typescript * Fix platform and workflow * Fix workflow and platform * Update husky and image-tag * Use 'yarn lint-staged' instead of 'npx lint-staged'
This commit is contained in:
111
dist/steps/activate.sh
vendored
Executable file
111
dist/steps/activate.sh
vendored
Executable file
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Run in ACTIVATE_LICENSE_PATH directory
|
||||
echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory."
|
||||
pushd "$ACTIVATE_LICENSE_PATH"
|
||||
|
||||
if [[ -n "$UNITY_LICENSE" ]] || [[ -n "$UNITY_LICENSE_FILE" ]]; then
|
||||
#
|
||||
# PERSONAL LICENSE MODE
|
||||
#
|
||||
# This will activate Unity, using a license file
|
||||
#
|
||||
# Note that this is the ONLY WAY for PERSONAL LICENSES in 2020.
|
||||
# * See for more details: https://gitlab.com/gableroux/unity3d-gitlab-ci-example/issues/5#note_72815478
|
||||
#
|
||||
# The license file can be acquired using `game-ci/request-manual-activation-file` action.
|
||||
echo "Requesting activation (personal license)"
|
||||
|
||||
# Set the license file path
|
||||
FILE_PATH=UnityLicenseFile.ulf
|
||||
|
||||
if [[ -n "$UNITY_LICENSE" ]]; then
|
||||
# Copy license file from Github variables
|
||||
echo "$UNITY_LICENSE" | tr -d '\r' > $FILE_PATH
|
||||
elif [[ -n "$UNITY_LICENSE_FILE" ]]; then
|
||||
# Copy license file from file system
|
||||
cat "$UNITY_LICENSE_FILE" | tr -d '\r' > $FILE_PATH
|
||||
fi
|
||||
|
||||
# Activate license
|
||||
ACTIVATION_OUTPUT=$(unity-editor \
|
||||
-batchmode \
|
||||
-nographics \
|
||||
-logFile /dev/stdout \
|
||||
-quit \
|
||||
-manualLicenseFile $FILE_PATH)
|
||||
|
||||
# Store the exit code from the verify command
|
||||
UNITY_EXIT_CODE=$?
|
||||
|
||||
# The exit code for personal activation is always 1;
|
||||
# Determine whether activation was successful.
|
||||
#
|
||||
# Successful output should include the following:
|
||||
#
|
||||
# "LICENSE SYSTEM [2020120 18:51:20] Next license update check is after 2019-11-25T18:23:38"
|
||||
#
|
||||
ACTIVATION_SUCCESSFUL=$(echo $ACTIVATION_OUTPUT | grep 'Next license update check is after' | wc -l)
|
||||
|
||||
# Set exit code to 0 if activation was successful
|
||||
if [[ $ACTIVATION_SUCCESSFUL -eq 1 ]]; then
|
||||
UNITY_EXIT_CODE=0
|
||||
fi;
|
||||
|
||||
# Remove license file
|
||||
rm -f $FILE_PATH
|
||||
|
||||
elif [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
|
||||
#
|
||||
# PROFESSIONAL (SERIAL) LICENSE MODE
|
||||
#
|
||||
# This will activate unity, using the activating process.
|
||||
#
|
||||
# Note: This is the preferred way for PROFESSIONAL LICENSES.
|
||||
#
|
||||
echo "Requesting activation (professional license)"
|
||||
|
||||
# Activate license
|
||||
unity-editor \
|
||||
-batchmode \
|
||||
-nographics \
|
||||
-logFile /dev/stdout \
|
||||
-quit \
|
||||
-serial "$UNITY_SERIAL" \
|
||||
-username "$UNITY_EMAIL" \
|
||||
-password "$UNITY_PASSWORD"
|
||||
|
||||
# Store the exit code from the verify command
|
||||
UNITY_EXIT_CODE=$?
|
||||
|
||||
else
|
||||
#
|
||||
# NO LICENSE ACTIVATION STRATEGY MATCHED
|
||||
#
|
||||
# This will exit since no activation strategies could be matched.
|
||||
#
|
||||
echo "License activation strategy could not be determined."
|
||||
echo ""
|
||||
echo "Visit https://game.ci/docs/github/getting-started for more"
|
||||
echo "details on how to set up one of the possible activation strategies."
|
||||
|
||||
# Immediately exit as no UNITY_EXIT_CODE can be derived.
|
||||
exit 1;
|
||||
|
||||
fi
|
||||
|
||||
#
|
||||
# Display information about the result
|
||||
#
|
||||
if [ $UNITY_EXIT_CODE -eq 0 ]; then
|
||||
# Activation was a success
|
||||
echo "Activation complete."
|
||||
else
|
||||
# Activation failed so exit with the code from the license verification step
|
||||
echo "Unclassified error occured while trying to activate license."
|
||||
echo "Exit code was: $UNITY_EXIT_CODE"
|
||||
exit $UNITY_EXIT_CODE
|
||||
fi
|
||||
|
||||
# Return to previous working directory
|
||||
popd
|
||||
22
dist/steps/return_license.sh
vendored
Executable file
22
dist/steps/return_license.sh
vendored
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Run in ACTIVATE_LICENSE_PATH directory
|
||||
echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory."
|
||||
pushd "$ACTIVATE_LICENSE_PATH"
|
||||
|
||||
if [[ -n "$UNITY_SERIAL" ]]; then
|
||||
#
|
||||
# PROFESSIONAL (SERIAL) LICENSE MODE
|
||||
#
|
||||
# This will return the license that is currently in use.
|
||||
#
|
||||
unity-editor \
|
||||
-batchmode \
|
||||
-nographics \
|
||||
-logFile /dev/stdout \
|
||||
-quit \
|
||||
-returnlicense
|
||||
fi
|
||||
|
||||
# Return to previous working directory
|
||||
popd
|
||||
182
dist/steps/run_tests.sh
vendored
Executable file
182
dist/steps/run_tests.sh
vendored
Executable file
@@ -0,0 +1,182 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Set and display project path
|
||||
#
|
||||
|
||||
UNITY_PROJECT_PATH="$GITHUB_WORKSPACE/$PROJECT_PATH"
|
||||
echo "Using project path \"$UNITY_PROJECT_PATH\"."
|
||||
|
||||
#
|
||||
# Set and display the artifacts path
|
||||
#
|
||||
|
||||
echo "Using artifacts path \"$ARTIFACTS_PATH\" to save test results."
|
||||
FULL_ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_PATH
|
||||
|
||||
#
|
||||
# Display custom parameters
|
||||
#
|
||||
echo "Using custom parameters $CUSTOM_PARAMETERS."
|
||||
|
||||
# Set the modes for testing
|
||||
case $TEST_MODE in
|
||||
editmode)
|
||||
echo "Edit mode selected for testing."
|
||||
EDIT_MODE=true
|
||||
;;
|
||||
playmode)
|
||||
echo "Play mode selected for testing."
|
||||
PLAY_MODE=true
|
||||
;;
|
||||
*)
|
||||
echo "All modes selected for testing."
|
||||
EDIT_MODE=true
|
||||
PLAY_MODE=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# The following tests are 2019 mode (requires Unity 2019.2.11f1 or later)
|
||||
# Reference: https://docs.unity3d.com/2019.3/Documentation/Manual/CommandLineArguments.html
|
||||
|
||||
#
|
||||
# Display the unity version
|
||||
#
|
||||
|
||||
echo "Using Unity version \"$UNITY_VERSION\" to test."
|
||||
|
||||
#
|
||||
# Overall info
|
||||
#
|
||||
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Artifacts folder #"
|
||||
echo "###########################"
|
||||
echo ""
|
||||
echo "Creating \"$FULL_ARTIFACTS_PATH\" if it does not exist."
|
||||
mkdir -p $FULL_ARTIFACTS_PATH
|
||||
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Project directory #"
|
||||
echo "###########################"
|
||||
echo ""
|
||||
ls -alh $UNITY_PROJECT_PATH
|
||||
|
||||
#
|
||||
# Testing in EditMode
|
||||
#
|
||||
EDIT_MODE_EXIT_CODE=0
|
||||
if [ "$EDIT_MODE" = "true" ]; then
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Testing in EditMode #"
|
||||
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" \
|
||||
$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)";
|
||||
else
|
||||
echo "Unexpected exit code $EDIT_MODE_EXIT_CODE";
|
||||
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" \
|
||||
-projectPath "$UNITY_PROJECT_PATH" \
|
||||
-runTests \
|
||||
-testPlatform playmode \
|
||||
-testResults "$FULL_ARTIFACTS_PATH/playmode-results.xml" \
|
||||
$CUSTOM_PARAMETERS
|
||||
|
||||
# Catch exit code
|
||||
PLAY_MODE_EXIT_CODE=$?
|
||||
|
||||
# Print unity log output
|
||||
cat "$FULL_ARTIFACTS_PATH/playmode.log"
|
||||
|
||||
# Display results
|
||||
if [ $PLAY_MODE_EXIT_CODE -eq 0 ]; then
|
||||
echo "Run succeeded, no failures occurred";
|
||||
elif [ $PLAY_MODE_EXIT_CODE -eq 2 ]; then
|
||||
echo "Run succeeded, some tests failed";
|
||||
elif [ $PLAY_MODE_EXIT_CODE -eq 3 ]; then
|
||||
echo "Run failure (other failure)";
|
||||
else
|
||||
echo "Unexpected exit code $PLAY_MODE_EXIT_CODE";
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Results
|
||||
#
|
||||
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Project directory #"
|
||||
echo "###########################"
|
||||
echo ""
|
||||
ls -alh $UNITY_PROJECT_PATH
|
||||
|
||||
if [ "$EDIT_MODE" = "true" ]; then
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Edit Mode Results #"
|
||||
echo "###########################"
|
||||
echo ""
|
||||
cat "$FULL_ARTIFACTS_PATH/editmode-results.xml"
|
||||
cat "$FULL_ARTIFACTS_PATH/editmode-results.xml" | grep test-run | grep Passed
|
||||
fi
|
||||
|
||||
if [ "$PLAY_MODE" = "true" ]; then
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Play Mode Results #"
|
||||
echo "###########################"
|
||||
echo ""
|
||||
cat "$FULL_ARTIFACTS_PATH/playmode-results.xml"
|
||||
cat "$FULL_ARTIFACTS_PATH/playmode-results.xml" | grep test-run | grep Passed
|
||||
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
|
||||
23
dist/steps/set_gitcredential.sh
vendored
Executable file
23
dist/steps/set_gitcredential.sh
vendored
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -z "${GIT_PRIVATE_TOKEN}" ]
|
||||
then
|
||||
echo "GIT_PRIVATE_TOKEN unset skipping"
|
||||
else
|
||||
echo "GIT_PRIVATE_TOKEN is set configuring git credentials"
|
||||
|
||||
git config --global credential.helper store
|
||||
git config --global --replace-all url.https://github.com/.insteadOf ssh://git@github.com/
|
||||
git config --global --add url.https://github.com/.insteadOf git@github.com
|
||||
|
||||
git config --global url."https://token:$GIT_PRIVATE_TOKEN@github.com/".insteadOf "https://github.com/"
|
||||
git config --global url."https://ssh:$GIT_PRIVATE_TOKEN@github.com/".insteadOf "ssh://git@github.com/"
|
||||
git config --global url."https://git:$GIT_PRIVATE_TOKEN@github.com/".insteadOf "git@github.com:"
|
||||
|
||||
fi
|
||||
|
||||
echo "---------- git config --list -------------"
|
||||
git config --list
|
||||
|
||||
echo "---------- git config --list --show-origin -------------"
|
||||
git config --list --show-origin
|
||||
Reference in New Issue
Block a user