forked from game-ci/unity-test-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for macos game-ci#211
- Loading branch information
Showing
35 changed files
with
152,039 additions
and
10,016 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
# | ||
# Create directory for license activation | ||
# | ||
|
||
sudo mkdir /Library/Application\ Support/Unity | ||
sudo chmod -R 777 /Library/Application\ Support/Unity | ||
|
||
ACTIVATE_LICENSE_PATH="$GITHUB_WORKSPACE/_activate-license" | ||
mkdir -p "$ACTIVATE_LICENSE_PATH" | ||
|
||
# | ||
# Run steps | ||
# | ||
|
||
source "$ACTION_FOLDER/platforms/mac/steps/activate.sh" | ||
source "$ACTION_FOLDER/platforms/mac/steps/set_gitcredential.sh" | ||
source "$ACTION_FOLDER/platforms/mac/steps/run_tests.sh" | ||
source "$ACTION_FOLDER/platforms/mac/steps/return_license.sh" | ||
|
||
# | ||
# Remove license activation directory | ||
# | ||
|
||
sudo rm -r /Library/Application\ Support/Unity | ||
rm -r "$ACTIVATE_LICENSE_PATH" | ||
|
||
# | ||
# Instructions for debugging | ||
# | ||
|
||
if [[ $TEST_RUNNER_EXIT_CODE -gt 0 ]]; then | ||
echo "" | ||
echo "###########################" | ||
echo "# Failure #" | ||
echo "###########################" | ||
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 "" | ||
fi; | ||
|
||
# | ||
# Exit with code from the build step. | ||
# | ||
|
||
if [[ $USE_EXIT_CODE == true || $TEST_RUNNER_EXIT_CODE -ne 2 ]]; then | ||
exit $TEST_RUNNER_EXIT_CODE | ||
fi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#!/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=$(/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \ | ||
-batchmode \ | ||
-nographics \ | ||
-logFile \ | ||
-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 | ||
/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \ | ||
-batchmode \ | ||
-nographics \ | ||
-logFile \ | ||
-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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Run in ACTIVATE_LICENSE_PATH directory | ||
echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory." | ||
pushd "$ACTIVATE_LICENSE_PATH" | ||
|
||
/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \ | ||
-logFile - \ | ||
-batchmode \ | ||
-nographics \ | ||
-quit \ | ||
-username "$UNITY_EMAIL" \ | ||
-password "$UNITY_PASSWORD" \ | ||
-returnlicense \ | ||
-projectPath "$ACTIVATE_LICENSE_PATH" | ||
|
||
# Return to previous working directory | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# Fix for kqueue error | ||
# | ||
|
||
export EVENT_NOKQUEUE=1 | ||
|
||
# | ||
# 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 | ||
|
||
# | ||
# Set and display the coverage results path | ||
# | ||
|
||
echo "Using coverage results path \"$COVERAGE_RESULTS_PATH\" to save test coverage results." | ||
FULL_COVERAGE_RESULTS_PATH=$GITHUB_WORKSPACE/$COVERAGE_RESULTS_PATH | ||
|
||
# | ||
# Display custom parameters | ||
# | ||
|
||
echo "Using custom parameters $CUSTOM_PARAMETERS." | ||
|
||
# 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 for each platform | ||
# | ||
for platform in ${TEST_PLATFORMS//;/ }; do | ||
echo "" | ||
echo "###########################" | ||
echo "# Testing in $platform #" | ||
echo "###########################" | ||
echo "" | ||
|
||
if [[ "$platform" != "COMBINE_RESULTS" ]]; then | ||
runTests="-runTests -testPlatform $platform -testResults $FULL_ARTIFACTS_PATH/$platform-results.xml" | ||
else | ||
runTests="-quit" | ||
fi | ||
|
||
/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \ | ||
-batchmode \ | ||
-silent-crashes \ | ||
-logFile "$FULL_ARTIFACTS_PATH/$platform.log" \ | ||
-projectPath "$UNITY_PROJECT_PATH" \ | ||
-coverageResultsPath "$FULL_COVERAGE_RESULTS_PATH" \ | ||
$runTests \ | ||
-enableCodeCoverage \ | ||
-debugCodeOptimization \ | ||
-coverageOptions "$COVERAGE_OPTIONS" \ | ||
$CUSTOM_PARAMETERS | ||
|
||
# Catch exit code | ||
TEST_EXIT_CODE=$? | ||
|
||
cat ~/Library/Logs/Unity/Unity.Licensing.Client.log | ||
|
||
# Print unity log output | ||
cat "$FULL_ARTIFACTS_PATH/$platform.log" | ||
|
||
# Display results | ||
if [ $TEST_EXIT_CODE -eq 0 ]; then | ||
echo "Run succeeded, no failures occurred"; | ||
elif [ $TEST_EXIT_CODE -eq 2 ]; then | ||
echo "Run succeeded, some tests failed"; | ||
elif [ $TEST_EXIT_CODE -eq 3 ]; then | ||
echo "Run failure (other failure)"; | ||
else | ||
echo "Unexpected exit code $TEST_EXIT_CODE"; | ||
fi | ||
|
||
if [ $TEST_EXIT_CODE -ne 0 ]; then | ||
TEST_RUNNER_EXIT_CODE=$TEST_EXIT_CODE | ||
fi | ||
|
||
echo "" | ||
echo "###########################" | ||
echo "# $platform Results #" | ||
echo "###########################" | ||
echo "" | ||
|
||
if [[ "$platform" != "COMBINE_RESULTS" ]]; then | ||
cat "$FULL_ARTIFACTS_PATH/$platform-results.xml" | ||
cat "$FULL_ARTIFACTS_PATH/$platform-results.xml" | grep test-run | grep Passed | ||
fi | ||
done | ||
|
||
# | ||
# Permissions | ||
# | ||
|
||
# Make a given user owner of all artifacts | ||
if [[ -n "$CHOWN_FILES_TO" ]]; then | ||
chown -R "$CHOWN_FILES_TO" "$UNITY_PROJECT_PATH" | ||
chown -R "$CHOWN_FILES_TO" "$FULL_ARTIFACTS_PATH" | ||
chown -R "$CHOWN_FILES_TO" "$FULL_COVERAGE_RESULTS_PATH" | ||
fi | ||
|
||
# Add read permissions for everyone to all artifacts | ||
chmod -R a+r "$UNITY_PROJECT_PATH" | ||
chmod -R a+r "$FULL_ARTIFACTS_PATH" | ||
chmod -R a+r "$FULL_COVERAGE_RESULTS_PATH" |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
dist/entrypoint.sh → dist/platforms/ubuntu/entrypoint.sh
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -x | ||
# | ||
# Create directory for license activation | ||
# | ||
|
0
dist/steps/activate.sh → dist/platforms/ubuntu/steps/activate.sh
100755 → 100644
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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://[email protected]/ | ||
git config --global --add url.https://github.com/.insteadOf [email protected] | ||
|
||
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://[email protected]/" | ||
git config --global url."https://git:$GIT_PRIVATE_TOKEN@github.com/".insteadOf "[email protected]:" | ||
|
||
fi | ||
|
||
echo "---------- git config --list -------------" | ||
git config --list | ||
|
||
echo "---------- git config --list --show-origin -------------" | ||
git config --list --show-origin |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.