Split up steps and implement license management
parent
2d11601618
commit
2ca91788af
|
@ -1,173 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Set the license file path
|
||||
UNITY_PROJECT_PATH=$GITHUB_WORKSPACE/$PROJECT_PATH
|
||||
|
||||
# Set the artifacts path
|
||||
if [ -z "$ARTIFACTS_PATH" ]; then
|
||||
ARTIFACTS_PATH=artifacts
|
||||
fi
|
||||
FULL_ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_PATH
|
||||
|
||||
# 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
|
||||
# Run steps
|
||||
#
|
||||
|
||||
echo "Using Unity version \"$UNITY_VERSION\" to test."
|
||||
source /steps/activate.sh
|
||||
source /steps/run_tests.sh
|
||||
source /steps/return_license.sh
|
||||
|
||||
#
|
||||
# Overall info
|
||||
# Exit with code from the build step.
|
||||
#
|
||||
|
||||
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
|
||||
#
|
||||
|
||||
if [ $EDIT_MODE = true ]; then
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Testing in EditMode #"
|
||||
echo "###########################"
|
||||
echo ""
|
||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
||||
/opt/Unity/Editor/Unity \
|
||||
-batchmode \
|
||||
-logfile /dev/stdout \
|
||||
-projectPath "$UNITY_PROJECT_PATH" \
|
||||
-runTests \
|
||||
-testPlatform editmode \
|
||||
-testResults "$FULL_ARTIFACTS_PATH/editmode-results.xml"
|
||||
|
||||
# Catch exit code
|
||||
EDIT_MODE_EXIT_CODE=$?
|
||||
|
||||
# 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
|
||||
#
|
||||
|
||||
if [ $PLAY_MODE = true ]; then
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Testing in PlayMode #"
|
||||
echo "###########################"
|
||||
echo ""
|
||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
||||
/opt/Unity/Editor/Unity \
|
||||
-batchmode \
|
||||
-logfile /dev/stdout \
|
||||
-projectPath "$UNITY_PROJECT_PATH" \
|
||||
-runTests \
|
||||
-testPlatform playmode \
|
||||
-testResults "$FULL_ARTIFACTS_PATH/playmode-results.xml"
|
||||
|
||||
# Catch exit code
|
||||
PLAY_MODE_EXIT_CODE=$?
|
||||
|
||||
# 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
|
||||
|
||||
#
|
||||
# Output variables
|
||||
#
|
||||
|
||||
# Set resulting name as output variable
|
||||
echo ::set-output name=artifactsPath::$ARTIFACTS_PATH
|
||||
|
||||
#
|
||||
# Exit
|
||||
#
|
||||
|
||||
if [ $EDIT_MODE_EXIT_CODE -gt 0 ]; then
|
||||
exit $EDIT_MODE_EXIT_CODE
|
||||
fi
|
||||
|
||||
if [ $PLAY_MODE_EXIT_CODE -gt 0 ]; then
|
||||
exit $PLAY_MODE_EXIT_CODE
|
||||
fi
|
||||
exit $TEST_RUNNER_EXIT_CODE
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,101 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [[ -n "$UNITY_LICENSE" ]]; 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 `webbertakken/request-manual-activation-file` action.
|
||||
echo "Requesting activation (personal license)"
|
||||
|
||||
# Set the license file path
|
||||
FILE_PATH=UnityLicenseFile.ulf
|
||||
|
||||
# Copy license file from Github variables
|
||||
echo "$UNITY_LICENSE" | tr -d '\r' > $FILE_PATH
|
||||
|
||||
# Activate license
|
||||
ACTIVATION_OUTPUT=$(xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
||||
/opt/Unity/Editor/Unity \
|
||||
-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
|
||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
||||
/opt/Unity/Editor/Unity \
|
||||
-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://github.com/webbertakken/unity-builder#usage for more"
|
||||
echo "details on how to set up one of the possible activation strategies."
|
||||
|
||||
# Immediately exit as no UNITY_EXIT_CODE can be derrived.
|
||||
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
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [[ -n "$UNITY_SERIAL" ]]; then
|
||||
#
|
||||
# PROFESSIONAL (SERIAL) LICENSE MODE
|
||||
#
|
||||
# This will return the license that is currently in use.
|
||||
#
|
||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
||||
/opt/Unity/Editor/Unity \
|
||||
-batchmode \
|
||||
-nographics \
|
||||
-logFile /dev/stdout \
|
||||
-quit \
|
||||
-returnlicense
|
||||
fi
|
|
@ -0,0 +1,168 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Set the license file path
|
||||
UNITY_PROJECT_PATH=$GITHUB_WORKSPACE/$PROJECT_PATH
|
||||
echo "Using project path \"$UNITY_PROJECT_PATH\"."
|
||||
|
||||
# Set the artifacts path
|
||||
if [ -z "$ARTIFACTS_PATH" ]; then
|
||||
ARTIFACTS_PATH=artifacts
|
||||
fi
|
||||
echo "Using build path \"$ARTIFACTS_PATH\" to save test results."
|
||||
FULL_ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_PATH
|
||||
|
||||
# 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
|
||||
#
|
||||
|
||||
if [ $EDIT_MODE = true ]; then
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Testing in EditMode #"
|
||||
echo "###########################"
|
||||
echo ""
|
||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
||||
/opt/Unity/Editor/Unity \
|
||||
-batchmode \
|
||||
-logfile /dev/stdout \
|
||||
-projectPath "$UNITY_PROJECT_PATH" \
|
||||
-runTests \
|
||||
-testPlatform editmode \
|
||||
-testResults "$FULL_ARTIFACTS_PATH/editmode-results.xml"
|
||||
|
||||
# Catch exit code
|
||||
EDIT_MODE_EXIT_CODE=$?
|
||||
|
||||
# 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
|
||||
#
|
||||
|
||||
if [ $PLAY_MODE = true ]; then
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Testing in PlayMode #"
|
||||
echo "###########################"
|
||||
echo ""
|
||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
||||
/opt/Unity/Editor/Unity \
|
||||
-batchmode \
|
||||
-logfile /dev/stdout \
|
||||
-projectPath "$UNITY_PROJECT_PATH" \
|
||||
-runTests \
|
||||
-testPlatform playmode \
|
||||
-testResults "$FULL_ARTIFACTS_PATH/playmode-results.xml"
|
||||
|
||||
# Catch exit code
|
||||
PLAY_MODE_EXIT_CODE=$?
|
||||
|
||||
# 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
|
Loading…
Reference in New Issue