Test the action
parent
a2c8e17ce3
commit
a22749a16c
|
@ -0,0 +1,61 @@
|
||||||
|
name: Actions 😎
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
testRunnerInAllModes:
|
||||||
|
name: Test all modes ✨
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Checkout repository (required to test local actions)
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
|
||||||
|
# Configure test runner
|
||||||
|
- name: Run tests
|
||||||
|
id: allTests
|
||||||
|
uses: webbertakken/unity-test-runner@v1
|
||||||
|
env:
|
||||||
|
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||||
|
TEST_MODE: all
|
||||||
|
UNITY_PROJECT_PATH: unity-project-with-correct-tests
|
||||||
|
# Test implicit ARTIFACTS_PATH, by not setting it
|
||||||
|
|
||||||
|
# Upload artifacts
|
||||||
|
- name: Upload test results
|
||||||
|
uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: Test results (all)
|
||||||
|
path: ${{ steps.allTests.outputs.artifactsPath }}
|
||||||
|
|
||||||
|
testRunnerInEachModeSeparately:
|
||||||
|
name: Test each mode sequentially # don't try this at home (it's much slower)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Checkout repository (required to test local actions)
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
|
||||||
|
# Configure first test runner
|
||||||
|
- name: Tests in editmode 📝
|
||||||
|
uses: webbertakken/unity-test-runner@v1
|
||||||
|
env:
|
||||||
|
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||||
|
TEST_MODE: editmode
|
||||||
|
UNITY_PROJECT_PATH: unity-project-with-correct-tests
|
||||||
|
ARTIFACTS_PATH: artifacts/editmode
|
||||||
|
|
||||||
|
# Configure second test runner
|
||||||
|
- name: Tests in playmode 📺
|
||||||
|
uses: webbertakken/unity-test-runner@v1
|
||||||
|
env:
|
||||||
|
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||||
|
TEST_MODE: playmode
|
||||||
|
UNITY_PROJECT_PATH: unity-project-with-correct-tests
|
||||||
|
ARTIFACTS_PATH: artifacts/playmode
|
||||||
|
|
||||||
|
# Upload combined artifacts
|
||||||
|
- name: Upload combined test results
|
||||||
|
uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: Test results (by reference)
|
||||||
|
path: artifacts/
|
|
@ -39,11 +39,11 @@ Configure the test runner as follows:
|
||||||
# Choose: "all", "playmode", "editmode"
|
# Choose: "all", "playmode", "editmode"
|
||||||
TEST_MODE: all
|
TEST_MODE: all
|
||||||
|
|
||||||
# Optional: Folder of your project, leave blank for "./"
|
# Optional: Path to your project, leave blank for "./"
|
||||||
UNITY_PROJECT_PATH: relative/path/to/your/project
|
UNITY_PROJECT_PATH: relative/path/to/your/project
|
||||||
|
|
||||||
# Optional: Artifacts folder, leave blank for "artifacts"
|
# Optional: Artifacts path, leave blank for "artifacts"
|
||||||
ARTIFACTS_FOLDER: store/artifacts/here
|
ARTIFACTS_PATH: store/artifacts/here
|
||||||
```
|
```
|
||||||
|
|
||||||
You use the id to **upload the artifacts** like so:
|
You use the id to **upload the artifacts** like so:
|
||||||
|
|
|
@ -5,10 +5,10 @@ LICENSE_FILE_PATH=UnityLicenseFile.ulf
|
||||||
UNITY_PROJECT_PATH=$GITHUB_WORKSPACE/$UNITY_PROJECT_PATH
|
UNITY_PROJECT_PATH=$GITHUB_WORKSPACE/$UNITY_PROJECT_PATH
|
||||||
|
|
||||||
# Set the artifacts path
|
# Set the artifacts path
|
||||||
if [ -z "$ARTIFACTS_FOLDER" ]; then
|
if [ -z "$ARTIFACTS_PATH" ]; then
|
||||||
ARTIFACTS_FOLDER=artifacts
|
ARTIFACTS_PATH=artifacts
|
||||||
fi
|
fi
|
||||||
ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_FOLDER
|
FULL_ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_PATH
|
||||||
|
|
||||||
# Set the modes for testing
|
# Set the modes for testing
|
||||||
case $TEST_MODE in
|
case $TEST_MODE in
|
||||||
|
@ -62,8 +62,8 @@ echo "###########################"
|
||||||
echo "# Artifacts folder #"
|
echo "# Artifacts folder #"
|
||||||
echo "###########################"
|
echo "###########################"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Creating \"$ARTIFACTS_PATH\" if it does not exist."
|
echo "Creating \"$FULL_ARTIFACTS_PATH\" if it does not exist."
|
||||||
mkdir -p $ARTIFACTS_PATH
|
mkdir -p $FULL_ARTIFACTS_PATH
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "###########################"
|
echo "###########################"
|
||||||
|
@ -89,7 +89,7 @@ if [ $EDIT_MODE = true ]; then
|
||||||
-projectPath "$UNITY_PROJECT_PATH" \
|
-projectPath "$UNITY_PROJECT_PATH" \
|
||||||
-runTests \
|
-runTests \
|
||||||
-testPlatform editmode \
|
-testPlatform editmode \
|
||||||
-testResults "$ARTIFACTS_PATH/editmode-results.xml"
|
-testResults "$FULL_ARTIFACTS_PATH/editmode-results.xml"
|
||||||
|
|
||||||
# Catch exit code
|
# Catch exit code
|
||||||
EDIT_MODE_EXIT_CODE=$?
|
EDIT_MODE_EXIT_CODE=$?
|
||||||
|
@ -123,7 +123,7 @@ if [ $PLAY_MODE = true ]; then
|
||||||
-projectPath "$UNITY_PROJECT_PATH" \
|
-projectPath "$UNITY_PROJECT_PATH" \
|
||||||
-runTests \
|
-runTests \
|
||||||
-testPlatform playmode \
|
-testPlatform playmode \
|
||||||
-testResults "$ARTIFACTS_PATH/playmode-results.xml"
|
-testResults "$FULL_ARTIFACTS_PATH/playmode-results.xml"
|
||||||
|
|
||||||
# Catch exit code
|
# Catch exit code
|
||||||
PLAY_MODE_EXIT_CODE=$?
|
PLAY_MODE_EXIT_CODE=$?
|
||||||
|
@ -157,8 +157,8 @@ if [ $EDIT_MODE = true ]; then
|
||||||
echo "# Edit Mode Results #"
|
echo "# Edit Mode Results #"
|
||||||
echo "###########################"
|
echo "###########################"
|
||||||
echo ""
|
echo ""
|
||||||
cat "$ARTIFACTS_PATH/editmode-results.xml"
|
cat "$FULL_ARTIFACTS_PATH/editmode-results.xml"
|
||||||
cat "$ARTIFACTS_PATH/editmode-results.xml" | grep test-run | grep Passed
|
cat "$FULL_ARTIFACTS_PATH/editmode-results.xml" | grep test-run | grep Passed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $PLAY_MODE = true ]; then
|
if [ $PLAY_MODE = true ]; then
|
||||||
|
@ -167,8 +167,8 @@ if [ $PLAY_MODE = true ]; then
|
||||||
echo "# Edit Mode Results #"
|
echo "# Edit Mode Results #"
|
||||||
echo "###########################"
|
echo "###########################"
|
||||||
echo ""
|
echo ""
|
||||||
cat "$ARTIFACTS_PATH/playmode-results.xml"
|
cat "$FULL_ARTIFACTS_PATH/playmode-results.xml"
|
||||||
cat "$ARTIFACTS_PATH/playmode-results.xml" | grep test-run | grep Passed
|
cat "$FULL_ARTIFACTS_PATH/playmode-results.xml" | grep test-run | grep Passed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -176,7 +176,7 @@ fi
|
||||||
#
|
#
|
||||||
|
|
||||||
# Set resulting name as output variable
|
# Set resulting name as output variable
|
||||||
echo ::set-output name=artifactsPath::$ARTIFACTS_PATH
|
echo ::set-output name=artifactsPath::$FULL_ARTIFACTS_PATH
|
||||||
|
|
||||||
#
|
#
|
||||||
# Exit
|
# Exit
|
||||||
|
|
Loading…
Reference in New Issue