diff --git a/README.md b/README.md index 4d456bd..18105ba 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/get-license/Dockerfile b/get-license/Dockerfile new file mode 100644 index 0000000..21468db --- /dev/null +++ b/get-license/Dockerfile @@ -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 " + +ADD entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/get-license/entrypoint.sh b/get-license/entrypoint.sh new file mode 100644 index 0000000..90b7dc2 --- /dev/null +++ b/get-license/entrypoint.sh @@ -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" diff --git a/test/entrypoint.sh b/test/entrypoint.sh index 565a919..3f9c1c5 100644 --- a/test/entrypoint.sh +++ b/test/entrypoint.sh @@ -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