Skip to content

Commit be11bae

Browse files
committed
build: update test workflow
1 parent 595cee8 commit be11bae

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

.github/workflows/unity-test.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Secrets
2+
# ULF_REPO: Git repository url contains ulf files. https://mob-sakai:{{token}}@github.com/mob-sakai/ulfs.git
3+
# WORKING_DIR: Unity project path (default: '.')
4+
name: unity-test
5+
6+
on:
7+
push:
8+
branches:
9+
- develop
10+
tags:
11+
- "!*"
12+
pull_request:
13+
types:
14+
- opened
15+
- synchronize
16+
17+
jobs:
18+
build-unity:
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
unity:
23+
[
24+
"2018.4.25f1",
25+
"2019.4.10f1",
26+
"2020.1.0f1",
27+
"2020.1.1f1",
28+
"2020.1.2f1",
29+
"2020.1.3f1",
30+
"2020.1.4f1",
31+
"2020.1.5f1",
32+
]
33+
34+
runs-on: ubuntu-latest
35+
container:
36+
# Use Unity image from https://hub.docker.com/r/gableroux/unity3d/tags
37+
image: gableroux/unity3d:${{ matrix.unity }}
38+
39+
steps:
40+
# Activate Unity Editor
41+
- name: Activate Unity Editor
42+
id: activation
43+
run: |
44+
# Clone ulfs.
45+
apt-get update
46+
apt-get install software-properties-common -y
47+
apt-add-repository ppa:git-core/ppa -y
48+
apt-get update
49+
apt-get install git -y
50+
git clone --depth 1 ${ULF_REPO} .ulfs
51+
52+
# Activate with ulf.
53+
ULF_FILE=.ulfs/Unity_v${UNITY_VERSION}.ulf
54+
echo $ULF_FILE
55+
if [ -e ${ULF_FILE} ]; then
56+
/opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -manualLicenseFile ${ULF_FILE} \
57+
| grep -E 'LICENSE SYSTEM.*\w{32} != \w{32}' && FAILED=true
58+
else
59+
echo "::error:: ulf file '${ULF_FILE}' is not found."
60+
FAILED=true
61+
fi
62+
63+
# Activation failed.
64+
if [ $FAILED ]; then
65+
echo "::error:: the unity activation may have failed. manual activation is required.%0A \
66+
1. download the artifact's .alf file.%0A \
67+
2. Go to https://license.unity3d.com/manual to activate manually.%0A \
68+
3. Generate a .ulf file from the .alf file and download it.%0A \
69+
4. Rename .ulf to 'Unity_v${UNITY_VERSION}.ulf'.%0A \
70+
5. Add file to ulfs repository.%0A \
71+
5. Re-run the jobs."
72+
73+
/opt/Unity/Editor/Unity -quit -batchmode -nographics -logFile -createManualActivationFile
74+
exit 1
75+
fi
76+
env:
77+
ULF_REPO: ${{ secrets.ULF_REPO }}
78+
UNITY_VERSION: ${{ matrix.unity }}
79+
80+
# (On failed activation) Upload unity activation file
81+
- name: Upload unity activation file
82+
uses: actions/upload-artifact@v2
83+
if: failure()
84+
with:
85+
name: Unity_v${{ matrix.unity }}.alf
86+
path: ./*.alf
87+
88+
# Setup testspace
89+
- uses: testspace-com/setup-testspace@v1
90+
with:
91+
domain: ${{ github.repository_owner }}
92+
93+
# Checkout sandbox project
94+
- uses: actions/checkout@v2
95+
with:
96+
ref: "sandbox"
97+
submodules: "true"
98+
fetch-depth: "1"
99+
100+
# Update package submodule
101+
- name: "Update package submodule"
102+
working-directory: Packages/dev
103+
run: git checkout ${{ github.head_ref }}
104+
105+
# Build editor tests
106+
- name: "Build editor tests"
107+
if: always() && steps.activation.conclusion == 'success'
108+
run: |
109+
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
110+
/opt/Unity/Editor/Unity -batchmode -nographics -silent-crashes -logFile -projectPath . -runEditorTests \
111+
|| [ -e ./editor_unittest.xml ] && exit 0 || exit 1
112+
113+
# Push test results
114+
- name: Push test results
115+
if: always() && steps.activation.conclusion == 'success'
116+
run: testspace "[${{ matrix.unity }}]TestResults-*.xml"

0 commit comments

Comments
 (0)