-
-
Notifications
You must be signed in to change notification settings - Fork 140
596 lines (547 loc) · 21.3 KB
/
test.yml
File metadata and controls
596 lines (547 loc) · 21.3 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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
name: Test
on:
workflow_dispatch:
push:
paths:
- "**/Dockerfile"
- "**/scripts/**"
- ".github/workflows/test.yml"
- "reference-project-test/**"
pull_request:
paths:
- "**/Dockerfile"
- "**/scripts/**"
- ".github/workflows/test.yml"
- "reference-project-test/**"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
##########################
# Test Backend #
##########################
reportingTest:
# Only run if not a PR as we need access to secrets
if: github.base_ref == ''
name: "🧪 Test reporting system (${{ matrix.imageType }})"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
jobId:
- dryRun # specifically use `dryRun` for testing.
imageType:
- base
- hub
- editor
baseOs:
- ubuntu
repoVersion:
- 0.1
include:
- imageType: editor
editorVersion: 2020.1.4f1
targetPlatform: android
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Report new build
uses: ./.github/workflows/actions/report-to-backend
with:
token: ${{ secrets.VERSIONING_TOKEN }}
jobId: ${{ matrix.jobId }}
status: started
# Build info
imageType: ${{ matrix.imageType }}
baseOs: ${{ matrix.baseOs }}
repoVersion: ${{ matrix.repoVersion }}
editorVersion: ${{ matrix.editorVersion }}
targetPlatform: ${{ matrix.targetPlatform }}
- name: Report build failure
uses: ./.github/workflows/actions/report-to-backend
with:
token: ${{ secrets.VERSIONING_TOKEN }}
jobId: ${{ matrix.jobId }}
status: failed
# Build info
imageType: ${{ matrix.imageType }}
baseOs: ${{ matrix.baseOs }}
repoVersion: ${{ matrix.repoVersion }}
editorVersion: ${{ matrix.editorVersion }}
targetPlatform: ${{ matrix.targetPlatform }}
# Failed specific
reason: "no real reason"
- name: Report publication
uses: ./.github/workflows/actions/report-to-backend
with:
token: ${{ secrets.VERSIONING_TOKEN }}
jobId: ${{ matrix.jobId }}
status: published
# Build info
imageType: ${{ matrix.imageType }}
baseOs: ${{ matrix.baseOs }}
repoVersion: ${{ matrix.repoVersion }}
editorVersion: ${{ matrix.editorVersion }}
targetPlatform: ${{ matrix.targetPlatform }}
# Published specific
imageRepo: unityci
imageName: ${{ matrix.imageType }}
friendlyTag: ${{ matrix.editorVersion }}-${{ matrix.targetPlatform }}-${{ matrix.repoVersion }}
specificTag: ${{ matrix.baseOs }}-${{ matrix.editorVersion }}-${{ matrix.targetPlatform }}-${{ matrix.repoVersion }}
digest: sha256:ef872b67450a680fbeebe1b037190b8f8fbfb04088531f422873915520e26e0f;
##########################
# Setup build matrix #
##########################
build-matrix:
name: Setup Build Matrix
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.setup.outputs.versions }}
linuxExcludes: ${{ steps.setup.outputs.linuxExcludes }}
windowsExcludes: ${{ steps.setup.outputs.windowsExcludes }}
steps:
- 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 2019.3`
echo "Versions: $VERSIONS"
echo "versions=$VERSIONS" >> "$GITHUB_OUTPUT"
# Unity 2021.1 and 2021.2 do not build il2cpp properly and will be skipped
WINDOWS_EXCLUDES="$WINDOWS_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2021.1|2021.2\")) | { version: ., module: \"windows-il2cpp\"} ]'`"
# Issues with 2021.1 and 2021.2 on Universal Windows Platform so they are skipped
WINDOWS_EXCLUDES="$WINDOWS_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2021.1|2021.2\")) | { version: ., module: \"universal-windows-platform\"} ]'`"
# Issues with 2021.1 and 2021.2 on AppleTV so they are skipped
WINDOWS_EXCLUDES="$WINDOWS_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2021.1|2021.2\")) | { version: ., module: \"appletv\"} ]'`"
# Issues with 2021.1 and 2021.2 on Android so they are skipped
WINDOWS_EXCLUDES="$WINDOWS_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2021.1|2021.2\")) | { version: ., module: \"android\"} ]'`"
# Issues with 2021.1 and 2021.2 on Mono so they are skipped
WINDOWS_EXCLUDES="$WINDOWS_EXCLUDES `echo \"$VERSIONS\" | jq -c '[ .[] | select(test(\"2021.1|2021.2\")) | { version: ., module: \"base\"} ]'`"
LINUX_EXCLUDES=`echo "$LINUX_EXCLUDES" | jq -s -c 'flatten'`
WINDOWS_EXCLUDES=`echo "$WINDOWS_EXCLUDES" | jq -s -c 'flatten'`
echo "Linux Excludes: $LINUX_EXCLUDES"
echo "Windows Excludes: $WINDOWS_EXCLUDES"
echo "linuxExcludes=$LINUX_EXCLUDES" >> "$GITHUB_OUTPUT"
echo "windowsExcludes=$WINDOWS_EXCLUDES" >> "$GITHUB_OUTPUT"
#################################
# Build Ubuntu base and hub #
#################################
ubuntu-base-and-hub:
name: Ubuntu Base and Hub
runs-on: ubuntu-latest
steps:
#############
# Setup #
#############
- uses: actions/checkout@v5
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
with:
driver: docker
#################################
# Build Ubuntu base and hub #
#################################
- name: Build base
uses: docker/build-push-action@v5
with:
file: ./images/ubuntu/base/Dockerfile
tags: base:ubuntu-dev
- name: Build hub
uses: docker/build-push-action@v5
with:
file: ./images/ubuntu/hub/Dockerfile
build-args: baseImage=base:ubuntu-dev
tags: hub:ubuntu-dev
###################################################
# Save images for later steps in the workflow #
###################################################
- name: Save images
run: |
docker images
docker save -o ubuntu-base-and-hub.tar base:ubuntu-dev hub:ubuntu-dev
- uses: actions/upload-artifact@v4
with:
name: ubuntu-base-and-hub
path: ubuntu-base-and-hub.tar
retention-days: 1
##################################
# Build Windows base and hub #
##################################
windows-base-and-hub:
name: Windows Base and Hub
runs-on: windows-2022
steps:
#############
# Setup #
#############
- uses: actions/checkout@v5
##################################
# Build Windows base and hub #
##################################
- name: Build base
run: |
docker build -t base:windows-dev -f ./images/windows/base/Dockerfile .
- name: Build hub
run: |
docker build -t hub:windows-dev -f ./images/windows/hub/Dockerfile --build-arg baseImage=base:windows-dev .
###################################################
# Save images for later steps in the workflow #
###################################################
- name: Show disk space
if: always()
run: get-PSDrive
- name: Save images
run: |
docker images
mkdir c:\artifact
cd c:\artifact
docker save -o windows-base-and-hub.tar base:windows-dev hub:windows-dev
zstd -z -12 --format=zstd windows-base-and-hub.tar
- uses: actions/upload-artifact@v4
with:
name: windows-base-and-hub
path: C:/artifact/windows-base-and-hub.tar.zst
retention-days: 1
- name: Show disk space
if: always()
run: get-PSDrive
#############################
# Build editor and test #
#############################
ubuntu-editor:
needs: [ubuntu-base-and-hub, build-matrix]
name: Ubuntu (${{ matrix.version }}, ${{ matrix.module }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# The latest patch versions for each minor version.
version: ${{ fromJson(needs.build-matrix.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: StandaloneWindows64
- module: mac-mono
platform: StandaloneOSX
- module: ios
platform: iOS
- module: android
platform: Android
- module: webgl
platform: WebGL
exclude: ${{ fromJson(needs.build-matrix.outputs.linuxExcludes) }}
steps:
#############
# Setup #
#############
- uses: actions/checkout@v5
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
with:
driver: docker
- name: Free disk space
run: .github/workflows/scripts/free_disk_space.sh
############################
# Restore base and hub #
############################
- uses: actions/download-artifact@v4
with:
name: ubuntu-base-and-hub
- name: Restore base and hub
run: |
docker load -i ubuntu-base-and-hub.tar
rm ubuntu-base-and-hub.tar
######################
# Setup to build #
######################
- name: Setup to build
id: setup
run: |
# The changeset for unity version
echo "CHANGESET=`npx unity-changeset ${{ matrix.version }}`" >> "$GITHUB_OUTPUT"
# 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_OUTPUT"
else
echo "MODULE=${{ matrix.module }}" >> "$GITHUB_OUTPUT"
fi
###########################
# Build Ubuntu editor #
###########################
- name: Build
# if: steps.build-1.outcome == 'failure'
uses: docker/build-push-action@v5
id: build-1
continue-on-error: true
timeout-minutes: 40
with:
file: ./images/ubuntu/editor/Dockerfile
build-args: |
baseImage=base:ubuntu-dev
hubImage=hub:ubuntu-dev
version=${{ matrix.version }}
changeSet=${{ steps.setup.outputs.CHANGESET }}
module=${{ steps.setup.outputs.MODULE }}
tags: editor:ubuntu-dev
###################################
# Build Ubuntu 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@v5
id: build-2
# continue-on-error: true
timeout-minutes: 40
with:
file: ./images/ubuntu/editor/Dockerfile
build-args: |
baseImage=base:ubuntu-dev
hubImage=hub:ubuntu-dev
version=${{ matrix.version }}
changeSet=${{ steps.setup.outputs.CHANGESET }}
module=${{ steps.setup.outputs.MODULE }}
tags: editor:ubuntu-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
# For editors prior to 2020, use built-in packages. Otherwise use the packages.json with the necessary packages.
if [[ $(echo ${{ matrix.version }} | cut -d '.' -f1) -ge 2020 ]]; then
mv -f reference-project-test/Packages_Disabled reference-project-test/Packages
fi
#############
# Build #
#############
- name: Build project
uses: game-ci/unity-builder@main
timeout-minutes: 35
# Only run if not a PR as we need access to secrets
if: github.base_ref == ''
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
unityVersion: ${{ matrix.version }}
customImage: editor:ubuntu-dev
projectPath: reference-project-test
targetPlatform: ${{ matrix.platform }}
allowDirtyBuild: true
###########################
# Build (Ubuntu GZip) #
###########################
- name: "⚙️ Setup (Ubuntu GZip)"
if: steps.setup.outputs.MODULE == 'webgl'
run: |
# Set WebGL compression format to gzip
sed -i -e 's/webGLCompressionFormat: .*$/webGLCompressionFormat: 1/' reference-project-test/ProjectSettings/ProjectSettings.asset
- name: Build project (GZip)
if: steps.setup.outputs.MODULE == 'webgl' && github.base_ref == ''
uses: game-ci/unity-builder@main
timeout-minutes: 15
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
unityVersion: ${{ matrix.version }}
customImage: editor:ubuntu-dev
projectPath: reference-project-test
targetPlatform: ${{ matrix.platform }}
allowDirtyBuild: true
#############################
# Build (Ubuntu Brotli) #
#############################
- name: "⚙️ Setup (Ubuntu Brotli)"
if: steps.setup.outputs.MODULE == 'webgl'
run: |
# Set WebGL compression format to brotli
sed -i -e 's/webGLCompressionFormat: .*$/webGLCompressionFormat: 0/' reference-project-test/ProjectSettings/ProjectSettings.asset
- name: Build project (Brotli)
if: steps.setup.outputs.MODULE == 'webgl' && github.base_ref == ''
uses: game-ci/unity-builder@main
timeout-minutes: 15
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
unityVersion: ${{ matrix.version }}
customImage: editor:ubuntu-dev
projectPath: reference-project-test
targetPlatform: ${{ matrix.platform }}
allowDirtyBuild: true
############
# Test #
############
- name: Test project
timeout-minutes: 10
uses: game-ci/unity-test-runner@main
# Only run if not a PR as we need access to secrets
if: github.base_ref == ''
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
unityVersion: ${{ matrix.version }}
customImage: editor:ubuntu-dev
projectPath: reference-project-test
customParameters: -nographics -buildTarget ${{ matrix.platform }}
##############################
# Validate Android Utils #
##############################
- name: Validate Android Utils
if: steps.setup.outputs.MODULE == 'android'
uses: addnab/docker-run-action@v3
with:
image: editor:ubuntu-dev
run: bash -l -c 'java -version && sdkmanager --version && cat $ANDROID_NDK_HOME/source.properties'
#############################
# Build editor and test #
#############################
windows-editor:
needs: [windows-base-and-hub, build-matrix]
name: Windows (${{ matrix.version }}, ${{ matrix.module }})
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
# The latest patch versions for each minor version.
version: ${{ fromJson(needs.build-matrix.outputs.versions) }}
module:
- base
- windows-il2cpp
- universal-windows-platform
- appletv
- android
include:
- module: base
platform: StandaloneWindows64
- module: windows-il2cpp
platform: StandaloneWindows64
- module: appletv
platform: tvOS
- module: universal-windows-platform
platform: WSAPlayer
- module: android
platform: Android
exclude: ${{ fromJson(needs.build-matrix.outputs.windowsExcludes) }}
steps:
#############
# Setup #
#############
- uses: actions/checkout@v5
############################
# Restore base and hub #
############################
- uses: actions/download-artifact@v4
with:
name: windows-base-and-hub
- name: Restore base and hub
run: |
mkdir c:/artifact
mv windows-base-and-hub.tar.zst c:/artifact
cd c:/artifact
zstd -d windows-base-and-hub.tar.zst
docker load -i windows-base-and-hub.tar
RAW_WORKSPACE_PATH="${{ github.workspace }}"
WORKSPACE_PATH=${RAW_WORKSPACE_PATH//\\//}
cd $WORKSPACE_PATH
rm -rf c:/artifact
shell: bash
######################
# Setup to build #
######################
- name: Setup to build
id: setup
run: |
# The changeset for unity version
echo "CHANGESET=`npx unity-changeset ${{ matrix.version }}`" >> "$GITHUB_OUTPUT"
# 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=windows-il2cpp" >> "$GITHUB_OUTPUT"
else
echo "MODULE=${{ matrix.module }}" >> "$GITHUB_OUTPUT"
fi
shell: bash
###########################
# Build Windows editor #
###########################
- name: Build
continue-on-error: true
timeout-minutes: 90
id: build-1
run: |
docker build -t editor:windows-dev --build-arg baseImage=base:windows-dev `
--build-arg hubImage=hub:windows-dev --build-arg version=${{ matrix.version }} `
--build-arg changeSet=${{ steps.setup.outputs.CHANGESET }} --build-arg module=${{ steps.setup.outputs.MODULE }} ./images/windows/editor
####################################
# Build Windows editor (retry) #
####################################
- name: Sleep for retry
if: steps.build-1.outcome == 'failure'
run: sleep 120
- name: Build (Retry)
if: steps.build-1.outcome == 'failure'
id: build-2
timeout-minutes: 90
run: |
docker build -t editor:windows-dev --build-arg baseImage=base:windows-dev `
--build-arg hubImage=hub:windows-dev --build-arg version=${{ matrix.version }} `
--build-arg changeSet=${{ steps.setup.outputs.CHANGESET }} --build-arg module=${{ steps.setup.outputs.MODULE }} ./images/windows/editor
#####################
# Setup to test #
#####################
- name: Show image size
run: docker images
- name: Setup to test
run: |
# For 'windows-il2cpp' module, switch the script backend to 'IL2CPP'
if [ "${{ matrix.module }}" = "windows-il2cpp" ] ; then
mv -f reference-project-test/ProjectSettings/ProjectSettings_il2cpp.asset reference-project-test/ProjectSettings/ProjectSettings.asset
fi
# For editors prior to 2020, use built-in packages. Otherwise use the packages.json with the necessary packages.
if [[ $(echo ${{ matrix.version }} | cut -d '.' -f1) -ge 2020 ]]; then
mv -f reference-project-test/Packages_Disabled reference-project-test/Packages
fi
shell: bash
#############
# Build #
#############
- name: Build project
# Only run if not a PR as we need access to secrets
if: github.base_ref == ''
timeout-minutes: 15
uses: game-ci/unity-builder@main
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
unityVersion: ${{ matrix.version }}
customImage: editor:windows-dev
projectPath: reference-project-test
targetPlatform: ${{ matrix.platform }}
allowDirtyBuild: true