Update Docker images for GitHub Actions #10
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
name: Build | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
workflow_dispatch: | |
env: | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
jobs: | |
test: | |
name: Test in ${{ matrix.testMode }} | |
runs-on: ubuntu-latest | |
container: unityci/editor:2019.4.34f1-base-3 | |
strategy: | |
matrix: | |
testMode: | |
- EditMode | |
- PlayMode | |
steps: | |
- name: Checkout Package | |
uses: actions/checkout@v1 | |
with: | |
lfs: true | |
- name: Restore Library from cache | |
uses: actions/cache@v4 | |
with: | |
path: Library | |
key: Library-base | |
- name: Activate Unity | |
run: | | |
echo "$UNITY_LICENSE" > /Unity_v2019.x.ulf | |
unity-editor \ | |
-batchmode -nographics -quit -logFile \ | |
-manualLicenseFile /Unity_v2019.x.ulf || true | |
rm /Unity_v2019.x.ulf | |
- name: Run ${{ matrix.testMode }} tests | |
shell: sh {0} | |
run: | | |
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \ | |
unity-editor \ | |
-batchmode -logFile \ | |
-projectPath . \ | |
-runTests -testPlatform ${{ matrix.testMode }} \ | |
-testResults Builds/TestResults-${{ matrix.testMode }}.xml | |
UNITY_EXIT_CODE=$? | |
if [ $UNITY_EXIT_CODE -eq 0 ]; then | |
cat Builds/TestResults-${{ matrix.testMode }}.xml | grep test-run | grep result | |
echo "Run succeeded, no failures occurred" | |
elif [ $UNITY_EXIT_CODE -eq 2 ]; then | |
cat Builds/TestResults-${{ matrix.testMode }}.xml | grep test-run | grep Failed | |
cat Builds/TestResults-${{ matrix.testMode }}.xml | grep test-case | grep Failed | |
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 | |
exit $UNITY_EXIT_CODE | |
- name: Upload ${{ matrix.testMode }} test results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: TestResults-${{ matrix.testMode }}.xml | |
path: Builds/TestResults-${{ matrix.testMode }}.xml | |
build-tgz: | |
needs: test | |
name: Build tgz | |
runs-on: ubuntu-latest | |
container: unityci/editor:2019.4.34f1-base-3 | |
steps: | |
- name: Checkout Package | |
uses: actions/checkout@v1 | |
with: | |
lfs: true | |
- name: Restore Library from cache | |
uses: actions/cache@v4 | |
with: | |
path: Library | |
key: Library-base | |
- name: Activate Unity | |
run: | | |
echo "$UNITY_LICENSE" > /Unity_v2019.x.ulf | |
unity-editor \ | |
-batchmode -nographics -quit -logFile \ | |
-manualLicenseFile /Unity_v2019.x.ulf || true | |
rm /Unity_v2019.x.ulf | |
- name: Build .tgz | |
id: build_tgz | |
run: | | |
mkdir -p Builds | |
unity-editor \ | |
-batchmode -nographics -quit -logFile \ | |
-projectPath . \ | |
-executeMethod PackageBuilder.PackTgz | |
echo "path=$(ls Builds/*.tgz)" >> $GITHUB_OUTPUT | |
echo "name=$(basename Builds/*.tgz)" >> $GITHUB_OUTPUT | |
- name: Upload .tgz | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.build_tgz.outputs.name }} | |
path: ${{ steps.build_tgz.outputs.path }} |