Add license and test step

This commit is contained in:
Webber
2019-11-03 02:39:16 +01:00
parent dd15503425
commit 8b47454028
4 changed files with 75 additions and 6 deletions

View File

@@ -1,11 +1,13 @@
# Unity Actions
Github actions for testing and building Unity projects (WIP)
Feel free to contribute.
Feel free to contribute.
## Jobs
- [ ] Checkout project
- [ ] Acquire license
- [ ] Open project in Unity
- [ ] Install dependencies
- [ ] Perform test suite
@@ -13,7 +15,7 @@ Feel free to contribute.
- [ ] Build scene(s)
## Platforms
- [ ] WebGL
- [ ] Windows
- [ ] Linux
@@ -31,10 +33,29 @@ on: push
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: webbertakken/unity-actions/test@master
- name: Checkout
uses: actions/checkout@master
- name: Get license
uses: webbertakken/unity-actions/get-license@master
env:
UNITY_USERNAME: ${{ secrets.UNITY_USERNAME }}
UNITY_PASSWORD: ${{ secrets.UNITY_USERNAME }}
- name: Test project
uses: webbertakken/unity-actions/test@master
env:
FOLDER: .
PLATFORM: playmode
```
## Credits
Huge thanks to
[gableroux](https://gableroux.com/)
for his docker [image](https://hub.docker.com/r/gableroux/unity3d/)
and gitlab-ci [example](https://gitlab.com/gableroux/unity3d).

14
get-license/Dockerfile Normal file
View File

@@ -0,0 +1,14 @@
FROM gableroux/unity3d:2019.2.11f1-webgl
LABEL "com.github.actions.name"="Unity get license"
LABEL "com.github.actions.description"="Retrieve license for Unity editor"
LABEL "com.github.actions.icon"="box"
LABEL "com.github.actions.color"="gray-dark"
LABEL "repository"="http://github.com/webbertakken/unity-actions"
LABEL "homepage"="http://github.com/webbertakken/unity-actions"
LABEL "maintainer"="Webber Takken <webber@takken.io>"
ADD entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -e
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
/opt/Unity/Editor/Unity \
-logFile /dev/stdout \
-batchmode \
-username "$UNITY_USERNAME" -password "$UNITY_PASSWORD"

View File

@@ -1,3 +1,28 @@
#!/bin/sh -l
#!/usr/bin/env bash
sh -c "echo Testing project in folder $FOLDER"
set -x
echo "Testing for $TEST_PLATFORM"
${UNITY_EXECUTABLE:-xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' /opt/Unity/Editor/Unity} \
-projectPath $(pwd) \
-runTests \
-testPlatform $TEST_PLATFORM \
-testResults $(pwd)/$TEST_PLATFORM-results.xml \
-logFile /dev/stdout \
-batchmode
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
cat $(pwd)/$TEST_PLATFORM-results.xml | grep test-run | grep Passed
exit $UNITY_TEST_EXIT_CODE