Test playmode, editmode and all modes

This commit is contained in:
Webber
2019-11-28 00:07:17 +01:00
committed by Webber Takken
parent c71997dc22
commit 0a693aa053
3 changed files with 216 additions and 139 deletions

View File

@@ -1,18 +1,31 @@
name: Workflow Actions
name: Happy flow
on: [push]
jobs:
testWorkflowActions:
requestManualActivationFile:
runs-on: ubuntu-latest
name: Request manual activation file
steps:
# Checkout repository (required to test local actions)
- name: Checkout repository
uses: actions/checkout@v1
# Configure request manual activation file action
- name: Request manual activation file
uses: ./request-manual-activation-file
id: getManualLicenseFile
# Upload artifact
- name: Expose as artifact
uses: actions/upload-artifact@v1
with:
name: ${{ steps.getManualLicenseFile.outputs.filePath }}
path: ${{ steps.getManualLicenseFile.outputs.filePath }}
requestActivation:
runs-on: ubuntu-latest
name: Test the workflow actions
# Set Unity version
strategy:
matrix:
unity-tag: [2019.2.11f1] # TODO - Reference this tag in all steps
steps:
# Checkout repository (required to test local actions)
- name: Checkout repository
uses: actions/checkout@v1
@@ -23,31 +36,75 @@ jobs:
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
testRunnerInEditMode:
runs-on: ubuntu-latest
name: Test the workflow actions
steps:
# Checkout repository (required to test local actions)
- name: Checkout repository
uses: actions/checkout@v1
# Configure test runner
- name: Run tests
uses: ./test-runner
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_PROJECT: sample-project
TEST_PLATFORM: playmode # [ playmode | editmode ]
UNITY_PROJECT: unity-project-with-correct-tests
TEST_MODE: editmode
# Upload artifact
- name: Expose as artifact
uses: actions/upload-artifact@v1
with:
name: 2019.2 test results
path: sample-project/old-results.xml
name: Test results (edit mode)
path: artifacts/unity-project-with-correct-tests/editmode-results.xml
# TODO - Verify that playmode-results does not exist
testRunnerInPlayMode:
runs-on: ubuntu-latest
name: Test the workflow actions
steps:
# Checkout repository (required to test local actions)
- name: Checkout repository
uses: actions/checkout@v1
# Configure test runner
- name: Run tests
uses: ./test-runner
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_PROJECT: unity-project-with-correct-tests
TEST_MODE: playmode
# Upload artifact
- name: Expose as artifact
uses: actions/upload-artifact@v1
with:
name: 2019.3 edit mode results
path: sample-project/editmode-results.xml
name: Test results (play mode)
path: artifacts/unity-project-with-correct-tests/playmode-results.xml
# Upload artifact
# TODO - Verify that editmode-results does not exist
testRunnerInAllModes:
runs-on: ubuntu-latest
name: Test the workflow actions
steps:
# Checkout repository (required to test local actions)
- name: Checkout repository
uses: actions/checkout@v1
# Configure test runner
- name: Run tests
uses: ./test-runner
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_PROJECT: unity-project-with-correct-tests
TEST_MODE: all
# Upload artifacts
- name: Expose as artifact
uses: actions/upload-artifact@v1
with:
name: 2019.3 play mode results
path: sample-project/playmode-results.xml
name: Test results (all modes)
path: artifacts/unity-project-with-correct-tests/

View File

@@ -1,30 +0,0 @@
name: Request manual activation file
on: [push]
jobs:
requestManualActivationFile:
runs-on: ubuntu-latest
name: Request manual activation file
# Set Unity version
strategy:
matrix:
unity-tag: [2019.2.11f1] # TODO - Reference this tag in all steps
steps:
# Checkout repository (required to test local actions)
- name: Checkout repository
uses: actions/checkout@v1
# Configure request manual activation file action
- name: Request manual activation file
uses: ./request-manual-activation-file
id: getManualLicenseFile
# Upload artifact
- name: Expose as artifact
uses: actions/upload-artifact@v1
with:
name: ${{ steps.getManualLicenseFile.outputs.filePath }}
path: ${{ steps.getManualLicenseFile.outputs.filePath }}

View File

@@ -1,129 +1,179 @@
#!/usr/bin/env bash
# Set the license file path
LICENSE_FILE_PATH=UnityLicenseFile.ulf
UNITY_PROJECT_PATH=$GITHUB_WORKSPACE/$UNITY_PROJECT
# Set the license file path
LICENSE_FILE_PATH=UnityLicenseFile.ulf
UNITY_PROJECT_PATH=$GITHUB_WORKSPACE/$UNITY_PROJECT
TEST_ARTIFACTS_PATH=$GITHUB_WORKSPACE/artifacts/$UNITY_PROJECT
# Copy license file from Github variables
echo "$UNITY_LICENSE" | tr -d '\r' > $LICENSE_FILE_PATH
echo "$UNITY_LICENSE" | tr -d '\r' > /root/.local/share/unity3d/Unity/Unity_lic.ulf
# TODO - test if this line has any effect
echo "$UNITY_LICENSE" | tr -d '\r' > /root/.local/share/unity3d/Unity/Unity_v2019.x.ulf
# 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
##
## Activate license
##
echo "Requesting activation"
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
/opt/Unity/Editor/Unity \
-batchmode \
-nographics \
-logFile /dev/stdout \
-quit \
-manualLicenseFile $LICENSE_FILE_PATH
# This is expected to always exit with code 1 (both success and failure).
# Convert to exit code 0 by echoing the current exit code.
echo $?
# Exit code is now 0
# Copy license file from Github variables
echo "$UNITY_LICENSE" | tr -d '\r' > $LICENSE_FILE_PATH
echo "$UNITY_LICENSE" | tr -d '\r' > /root/.local/share/unity3d/Unity/Unity_lic.ulf
# TODO - test if this line has any effect
echo "$UNITY_LICENSE" | tr -d '\r' > /root/.local/share/unity3d/Unity/Unity_v2019.x.ulf
echo "Testing the 2019.2 way"
# Reference: https://docs.unity3d.com/2019.2/Documentation/Manual/CommandLineArguments.html
echo "Using path: $UNITY_PROJECT_PATH"
ls -alh $UNITY_PROJECT_PATH
##
## Activate license
##
echo "Requesting activation"
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
/opt/Unity/Editor/Unity \
-batchmode \
-logfile /dev/stdout \
-runEditorTests "$UNITY_PROJECT_PATH" \
-editorTestsResultFile "$UNITY_PROJECT_PATH/old-results.xml"
-nographics \
-logFile /dev/stdout \
-quit \
-manualLicenseFile $LICENSE_FILE_PATH
# This is expected to always exit with code 1 (both success and failure).
# Convert to exit code 0 by echoing the current exit code.
echo $?
# Exit code is now 0
UNITY_EXIT_CODE=$?
if [ $UNITY_EXIT_CODE -eq 0 ]; then
echo "Run succeeded, no failures occurred";
elif [ $UNITY_EXIT_CODE -eq 2 ]; then
echo "Run succeeded, some tests failed";
elif [ $UNITY_EXIT_CODE -eq 3 ]; then
echo "Run failure (other failure)";
else
echo "Unexpected exit code $UNITY_EXIT_CODE";
fi
# Test 2019.3 mode
# The following tests are 2019 mode (requires Unity 2019.2.11f1 or later)
# Reference: https://docs.unity3d.com/2019.3/Documentation/Manual/CommandLineArguments.html
#
# EditMode
# Overall info
#
echo ""
echo "###########################"
echo "# Artifacts folder #"
echo "###########################"
echo ""
echo "Creating \"$TEST_ARTIFACTS_PATH\" if it does not exist."
mkdir -p $TEST_ARTIFACTS_PATH
echo ""
echo "###########################"
echo "# Project directory #"
echo "###########################"
echo ""
ls -alh $UNITY_PROJECT_PATH
echo "Testing the 2019.3 way (editmode)"
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 "$UNITY_PROJECT_PATH/editmode-results.xml"
UNITY_EXIT_CODE=$?
#
# Testing in EditMode
#
if [ $UNITY_EXIT_CODE -eq 0 ]; then
echo "Run succeeded, no failures occurred";
elif [ $UNITY_EXIT_CODE -eq 2 ]; then
echo "Run succeeded, some tests failed";
elif [ $UNITY_EXIT_CODE -eq 3 ]; then
echo "Run failure (other failure)";
else
echo "Unexpected exit code $UNITY_EXIT_CODE";
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 "$TEST_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
#
# PlayMode
# Testing in PlayMode
#
ls -alh $UNITY_PROJECT_PATH
echo "Testing the 2019.3 way (playmode)"
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 "$UNITY_PROJECT_PATH/playmode-results.xml"
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 "$TEST_ARTIFACTS_PATH/playmode-results.xml"
UNITY_EXIT_CODE=$?
# Catch exit code
PLAY_MODE_EXIT_CODE=$?
if [ $UNITY_EXIT_CODE -eq 0 ]; then
echo "Run succeeded, no failures occurred";
elif [ $UNITY_EXIT_CODE -eq 2 ]; then
echo "Run succeeded, some tests failed";
elif [ $UNITY_EXIT_CODE -eq 3 ]; then
echo "Run failure (other failure)";
else
echo "Unexpected exit code $UNITY_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
echo "Results:"
cat "$UNITY_PROJECT_PATH/$TEST_PLATFORM-results.xml"
cat "$UNITY_PROJECT_PATH/$TEST_PLATFORM-results.xml" | grep test-run | grep Passed
echo "\n\nEditMode Results\n\n"
cat "$UNITY_PROJECT_PATH/editmode-results.xml"
cat "$UNITY_PROJECT_PATH/editmode-results.xml" | grep test-run | grep Passed
echo "\n\nPlayMode Results\n\n"
cat "$UNITY_PROJECT_PATH/playmode-results.xml"
cat "$UNITY_PROJECT_PATH/playmode-results.xml" | grep test-run | grep Passed
if [ $EDIT_MODE = true ]; then
echo ""
echo "###########################"
echo "# Edit Mode Results #"
echo "###########################"
echo ""
cat "$TEST_ARTIFACTS_PATH/editmode-results.xml"
cat "$TEST_ARTIFACTS_PATH/editmode-results.xml" | grep test-run | grep Passed
fi
if [ $PLAY_MODE = true ]; then
echo ""
echo "###########################"
echo "# Edit Mode Results #"
echo "###########################"
echo ""
cat "$TEST_ARTIFACTS_PATH/playmode-results.xml"
cat "$TEST_ARTIFACTS_PATH/playmode-results.xml" | grep test-run | grep Passed
fi
#
# Exit
#
exit $UNITY_EXIT_CODE
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