Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dist/platforms/mac/steps/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,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 "See the activation output above (starting at \"Requesting activation\") for the actual reason Unity gave."
exit $UNITY_EXIT_CODE
fi

Expand Down
24 changes: 16 additions & 8 deletions dist/platforms/ubuntu/steps/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,24 @@ if [[ "$LICENSING_METHOD" == "file" ]]; then
cat "$UNITY_LICENSE_FILE" | tr -d '\r' > $FILE_PATH
fi

# Unlike the serial/floating/personal branches below, this used to capture
# Unity's output into a variable via command substitution instead of
# streaming it through `tee` - so on a genuine (non-transient) activation
# failure, the user got nothing but the generic "Unclassified error occured
# while trying to activate license." at the bottom of this script, with the
# actual reason Unity gave silently discarded. `tee` now mirrors it live to
# the build log the same way every other licensing method here already
# does (game-ci/cli#252).
ACTIVATE_LOG="$(mktemp)"
for ATTEMPT in $(seq 1 "$UNITY_ACTIVATE_MAX_ATTEMPTS"); do
# Activate license
ACTIVATION_OUTPUT=$(${ENGINE_LAUNCH_WRAPPER:-} unity-editor \
${ENGINE_LAUNCH_WRAPPER:-} unity-editor \
-logFile /dev/stdout \
-quit \
-manualLicenseFile $FILE_PATH)
-manualLicenseFile $FILE_PATH 2>&1 | tee "$ACTIVATE_LOG"

# Store the exit code from the verify command
UNITY_EXIT_CODE=$?
UNITY_EXIT_CODE=${PIPESTATUS[0]}

# The exit code for personal activation is always 1;
# Determine whether activation was successful.
Expand All @@ -68,15 +77,12 @@ if [[ "$LICENSING_METHOD" == "file" ]]; then
#
# "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
if grep -q 'Next license update check is after' "$ACTIVATE_LOG"; then
UNITY_EXIT_CODE=0
break
fi

if [ "$ATTEMPT" -lt "$UNITY_ACTIVATE_MAX_ATTEMPTS" ] && grep -qE "$UNITY_ACTIVATE_TRANSIENT_PATTERN" <<< "$ACTIVATION_OUTPUT"; then
if [ "$ATTEMPT" -lt "$UNITY_ACTIVATE_MAX_ATTEMPTS" ] && grep -qE "$UNITY_ACTIVATE_TRANSIENT_PATTERN" "$ACTIVATE_LOG"; then
# Exponential backoff - see mac/steps/activate.sh's matching comment.
UNITY_ACTIVATE_RETRY_DELAY=$((UNITY_ACTIVATE_RETRY_DELAY_SECONDS * (1 << (ATTEMPT - 1))))
echo "Unity activation failed with a known-transient licensing error (attempt $ATTEMPT/$UNITY_ACTIVATE_MAX_ATTEMPTS) - retrying in ${UNITY_ACTIVATE_RETRY_DELAY}s..."
Expand All @@ -86,6 +92,7 @@ if [[ "$LICENSING_METHOD" == "file" ]]; then

break
done
rm -f "$ACTIVATE_LOG"

# Remove license file
rm -f $FILE_PATH
Expand Down Expand Up @@ -252,6 +259,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 "See the activation output above (starting at \"Requesting activation\") for the actual reason Unity gave."
exit $UNITY_EXIT_CODE
fi

Expand Down
1 change: 1 addition & 0 deletions dist/platforms/windows/activate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ else {
# Activation failed so exit with the code from the license verification step
Write-Host "Unclassified error occured while trying to activate license."
Write-Host "Exit code was: $($global:UNITY_EXIT_CODE)"
Write-Host 'See the activation output above (starting at "Requesting activation") for the actual reason Unity gave.'
exit $global:UNITY_EXIT_CODE
}

Expand Down
1 change: 1 addition & 0 deletions dist/platforms/windows/steps/activate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ if ($global:UNITY_EXIT_CODE -eq 0) {
} else {
Write-Host 'Unclassified error occured while trying to activate license.'
Write-Host "Exit code was: $($global:UNITY_EXIT_CODE)"
Write-Host 'See the activation output above (starting at "Requesting activation") for the actual reason Unity gave.'
Pop-Location
exit $global:UNITY_EXIT_CODE
}
Expand Down
29 changes: 29 additions & 0 deletions scripts/test-licensing-steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,35 @@ run_step UNITY_LICENSING_METHOD="serial" UNITY_SERIAL="F4-XXXX" UNITY_LICENSING_
check "an explicit strategy governs the return" "$(cat "$ARGV_LOG")" "-returnlicense"
refute "and does not fall back to floating" "$(cat "$ARGV_LOG")" "--return-floating"

echo "License file activation output"
# Regression test for game-ci/cli#252: the .ulf branch used to capture
# unity-editor's output into a variable via command substitution instead of
# streaming it through `tee` like every other strategy here, so a genuine
# (non-transient) failure surfaced nothing but the generic "Unclassified
# error" summary - the actual reason Unity gave was silently discarded.
: > "$ARGV_LOG"
cat > "$WORK/unity-editor" <<'STUB'
#!/usr/bin/env bash
echo "EDITOR $*" >> "$ARGV_LOG"
echo "DistinctiveActivationFailureReason: seat already in use by another machine"
exit 1
STUB
chmod +x "$WORK/unity-editor"
OUT=$(run_step UNITY_LICENSE="<License/>" UNITY_LICENSE_RETRY_MAX_ATTEMPTS=1 \
bash -c 'source "$STEPS_DIR/activate.sh"' 2>&1)
check "a failed license-file activation surfaces Unity's actual output" "$OUT" \
"DistinctiveActivationFailureReason"
check "and still reports the generic summary alongside it" "$OUT" "Unclassified error"

# Restore the always-succeeding stub for every test below.
cat > "$WORK/unity-editor" <<'STUB'
#!/usr/bin/env bash
echo "EDITOR $*" >> "$ARGV_LOG"
echo "LICENSE SYSTEM [CI stub] Next license update check is after 2099-01-01T00:00:00"
exit "${STUB_EXIT:-0}"
STUB
chmod +x "$WORK/unity-editor"

echo "Failure classification"
OUT=$(run_step UNITY_EMAIL="ci@example.com" UNITY_PASSWORD="pw123456" \
STUB_EXIT=1 STUB_OUTPUT="Error: no available seats for this organization" \
Expand Down
8 changes: 4 additions & 4 deletions src/generated/embedded-assets.ts

Large diffs are not rendered by default.

Loading