-
-
Notifications
You must be signed in to change notification settings - Fork 140
250 lines (231 loc) · 7.88 KB
/
test.yml
File metadata and controls
250 lines (231 loc) · 7.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# [Required secrets]
# UNITY_LICENSE: Contents of an Unity license file (*.ulf)
name: Test
on:
workflow_dispatch:
push:
paths:
- "**/Dockerfile"
- .github/workflows/test.yml
- reference-project-test/*
pull_request_target:
paths:
- "**/Dockerfile"
- reference-project-test/*
jobs:
###########################
# Build base and hub #
###########################
base-and-hub:
name: Base and hub
runs-on: ubuntu-18.04
outputs:
versions: ${{ steps.setup.outputs.versions }}
excludes: ${{ steps.setup.outputs.excludes }}
steps:
###########################
# Checkout #
###########################
- name: Checkout (default)
uses: actions/checkout@v2
if: github.event.event_type != 'pull_request_target'
- name: Checkout (pull_request_target)
uses: actions/checkout@v2
if: github.event.event_type == 'pull_request_target'
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
###########################
# Setup #
###########################
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
with:
driver: docker
###########################
# Build base and hub #
###########################
- name: Build base
uses: docker/build-push-action@v2
with:
context: .
file: base/Dockerfile
tags: base:dev
- name: Build hub
uses: docker/build-push-action@v2
with:
context: .
file: hub/Dockerfile
build-args: baseImage=base:dev
tags: hub:dev
###########################
# Save images for next #
###########################
- name: Save images for next
run: |
docker images
docker save -o base-and-hub.tar base:dev hub:dev
- uses: actions/upload-artifact@v2
with:
path: base-and-hub.tar
retention-days: 1
###########################
# Setup build matrix #
###########################
- name: "Setup build matrix"
id: setup
run: |
# Get the Unity versions for test. (The latest patch versions for each minor version.)
VERSIONS=`npx unity-changeset list --versions --latest-patch --json --min 2018.3`
echo "Versions: $VERSIONS"
echo "::set-output name=versions::$VERSIONS"
# Exclude linux-il2cpp for Unity 2019.2 or earlier
EXCLUDES="$EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2018|2019.1|2019.2\")) | { version: ., module: \"linux-il2cpp\"} ]'`"
EXCLUDES=`echo "$EXCLUDES" | jq -s -c 'flatten'`
echo "Excludes: $EXCLUDES"
echo "::set-output name=excludes::$EXCLUDES"
###########################
# Build editor and test #
###########################
editor:
needs: base-and-hub
name: Editor (${{ matrix.version }}, ${{ matrix.module }})
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
# The latest patch versions for each minor version.
version: ${{ fromJson(needs.base-and-hub.outputs.versions) }}
module:
- base
- linux-il2cpp
- windows-mono
- mac-mono
- ios
- android
- webgl
include:
- module: base
platform: StandaloneLinux64
- module: linux-il2cpp
platform: StandaloneLinux64
- module: windows-mono
platform: StandaloneWindows
- module: mac-mono
platform: StandaloneOSX
- module: ios
platform: iOS
- module: android
platform: Android
- module: webgl
platform: WebGL
exclude: ${{ fromJson(needs.base-and-hub.outputs.excludes) }}
steps:
###########################
# Setup #
###########################
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
with:
driver: docker
- name: Free disk space
run: .github/workflows/scripts/free_disk_space.sh
###########################
# Restore base and hub #
###########################
- uses: actions/download-artifact@v2
- name: Restore base and hub
run: |
docker load -i artifact/base-and-hub.tar
rm -rf artifact
###########################
# Setup to build #
###########################
- name: Setup to build
run: |
# The changeset for unity version
echo "CHANGESET=`npx unity-changeset ${{ matrix.version }}`" >> $GITHUB_ENV
# For 2019.3 or later, non-il2cpp would also be possible to build with il2cpp image.
if [ `echo "${{ matrix.version }}" | grep -v '\(2018\|2019.1\|2019.2\)'` ] && [ "${{ matrix.module }}" = 'base' ] ; then
echo "MODULE=linux-il2cpp" >> $GITHUB_ENV
else
echo "MODULE=${{ matrix.module }}" >> $GITHUB_ENV
fi
###########################
# Build editor #
###########################
- name: Build
# if: steps.build-1.outcome == 'failure'
uses: docker/build-push-action@v2
id: build-1
continue-on-error: true
timeout-minutes: 40
with:
context: .
file: editor/Dockerfile
build-args: |
baseImage=base:dev
hubImage=hub:dev
version=${{ matrix.version }}
changeSet=${{ env.CHANGESET }}
module=${{ env.MODULE }}
tags: editor:dev
###########################
# Build editor (retry) #
###########################
- name: Sleep for retry
if: steps.build-1.outcome == 'failure'
run: sleep 120
- name: Build (Retry)
if: steps.build-1.outcome == 'failure'
uses: docker/build-push-action@v2
id: build-2
# continue-on-error: true
timeout-minutes: 40
with:
context: .
file: editor/Dockerfile
build-args: |
baseImage=base:dev
hubImage=hub:dev
version=${{ matrix.version }}
changeSet=${{ env.CHANGESET }}
module=${{ env.MODULE }}
tags: editor:dev
###########################
# Setup to test #
###########################
- name: Show image size
run: docker images
- name: Setup to test
run: |
# For 'linux-il2cpp' module, switch the script backend to 'IL2CPP'
if [ "${{ matrix.module }}" = "linux-il2cpp" ] ; then
mv -f reference-project-test/ProjectSettings/ProjectSettings_il2cpp.asset reference-project-test/ProjectSettings/ProjectSettings.asset
fi
###########################
# Build #
###########################
- name: Build project
uses: game-ci/unity-builder@main
with:
unityVersion: ${{ matrix.version }}
customImage: editor:dev
projectPath: reference-project-test
targetPlatform: ${{ matrix.platform }}
allowDirtyBuild: true
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
###########################
# Test #
###########################
- name: Test project
uses: game-ci/unity-test-runner@main
with:
unityVersion: ${{ matrix.version }}
customImage: editor:dev
projectPath: reference-project-test
customParameters: -nographics -buildTarget ${{ matrix.platform }}
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}