Remove XRSettings. Remove license file check and rely on error codes instead. Exponential backoff Unity license activation retry strategy

This commit is contained in:
Andrew Kahr 2023-11-24 18:39:29 -08:00
parent 28890ad72d
commit 88edf4e8f5
7 changed files with 58 additions and 37 deletions

View File

@ -1,10 +0,0 @@
{
"m_SettingKeys": [
"VR Device Disabled",
"VR Device User Alert"
],
"m_SettingValues": [
"False",
"False"
]
}

View File

@ -41,7 +41,7 @@ echo ""
echo "Please note that the exit code is not very descriptive."
echo "Most likely it will not help you solve the issue."
echo ""
echo "To find the reason for failure: please search for errors in the log above."
echo "To find the reason for failure: please search for errors in the log above and check for annotations in the summary view."
echo ""
fi;

View File

@ -20,10 +20,6 @@ echo "Requesting activation"
# Store the exit code from the verify command
UNITY_EXIT_CODE=$?
if [ ! -f "/Library/Application Support/Unity/Unity_lic.ulf" ]; then
echo "::error ::There was an error while trying to activate the Unity license."
fi
#
# Display information about the result
#

View File

@ -4,10 +4,19 @@ if [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
#
# SERIAL LICENSE MODE
#
# This will activate unity, using the activating process.
# This will activate unity, using the serial activation process.
#
echo "Requesting activation"
# Loop the unity-editor call until the license is activated with exponential backoff and a maximum of 5 retries
retry_count=0
# Initialize delay to 15 seconds
delay=15
# Loop until UNITY_EXIT_CODE is 0 or retry count reaches 5
while [[ $retry_count -lt 5 ]]
do
# Activate license
unity-editor \
-logFile /dev/stdout \
@ -20,8 +29,26 @@ if [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
# Store the exit code from the verify command
UNITY_EXIT_CODE=$?
if [ ! -f "~/.local/share/unity3d/Unity/Unity_lic.ulf" ]; then
echo "::error ::There was an error while trying to activate the Unity license."
# Check if UNITY_EXIT_CODE is 0
if [[ $UNITY_EXIT_CODE -eq 0 ]]
then
echo "Activation successful"
break
else
echo "Activation failed, retrying in $delay seconds..."
sleep $delay
# Increment retry count
((retry_count++))
# Double the delay for the next iteration
delay=$((delay * 2))
fi
done
if [[ $retry_count -eq 5 ]]
then
echo "Activation failed after 5 retries"
fi
elif [[ -n "$UNITY_LICENSING_SERVER" ]]; then
@ -50,8 +77,9 @@ else
echo "Visit https://game.ci/docs/github/getting-started for more"
echo "details on how to set up one of the possible activation strategies."
echo "::error ::No valid license activation strategy could be determined."
# Immediately exit as no UNITY_EXIT_CODE can be derrived.
echo "::error ::No valid license activation strategy could be determined. Make sure to provide UNITY_EMAIL, UNITY_PASSWORD, and either a UNITY_SERIAL \
or UNITY_LICENSE. Otherwise please use UNITY_LICENSING_SERVER."
# Immediately exit as no UNITY_EXIT_CODE can be derived.
exit 1;
fi
@ -66,6 +94,7 @@ 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"
echo "::error ::There was an error while trying to activate the Unity license."
exit $UNITY_EXIT_CODE
fi

View File

@ -6,6 +6,12 @@
source /steps/set_extra_git_configs.sh
source /steps/set_gitcredential.sh
source /steps/activate.sh
# If we didn't activate successfully, exit with the exit code from the activation step.
if [[ $UNITY_EXIT_CODE -ne 0 ]]; then
exit $UNITY_EXIT_CODE
fi
source /steps/build.sh
source /steps/return_license.sh
@ -22,7 +28,7 @@ echo ""
echo "Please note that the exit code is not very descriptive."
echo "Most likely it will not help you solve the issue."
echo ""
echo "To find the reason for failure: please search for errors in the log above."
echo "To find the reason for failure: please search for errors in the log above and check for annotations in the summary view."
echo ""
fi;

View File

@ -13,7 +13,4 @@ Write-Output ""
-projectPath "c:/BlankProject" `
-logfile - | Out-Host
if(-not(Test-path "C:/ProgramData/Unity/Unity_lic.ulf" -PathType leaf))
{
Write-Output "::error ::There was an error while trying to activate the Unity license."
}
$ACTIVATION_EXIT_CODE = $LASTEXITCODE

View File

@ -1,5 +1,4 @@
Get-Process
Start-Sleep -Seconds 3
# Import any necessary registry keys, ie: location of windows 10 sdk
# No guarantee that there will be any necessary registry keys, ie: tvOS
@ -17,13 +16,17 @@ Get-Process -Name regsvr32 | ForEach-Object { Stop-Process -Id $_.Id -Force }
# Activate Unity
. "c:\steps\activate.ps1"
# If we didn't activate successfully, exit with the exit code from the activation step.
if ($ACTIVATION_EXIT_CODE -ne 0) {
exit $ACTIVATION_EXIT_CODE
}
# Build the project
. "c:\steps\build.ps1"
# Free the seat for the activated license
. "c:\steps\return_license.ps1"
Start-Sleep -Seconds 3
Get-Process
exit $BUILD_EXIT_CODE