forked from sipsorcery-org/sipsorcery
-
Notifications
You must be signed in to change notification settings - Fork 0
359 lines (338 loc) · 13.3 KB
/
unity-smoke-test.yml
File metadata and controls
359 lines (338 loc) · 13.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
name: unity-smoke-test
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
smoke-test:
name: Unity ${{ matrix.unityVersion }} PlayMode smoke test (Linux)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
unityVersion:
- 6000.4.7f1
testMode:
- playmode
steps:
- name: Check for Unity license secret
id: license_check
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
run: |
if [ -z "$UNITY_LICENSE" ] || [ -z "$UNITY_EMAIL" ] || [ -z "$UNITY_PASSWORD" ]; then
echo "has_license=false" >> "$GITHUB_OUTPUT"
echo "::warning::Unity license secrets (UNITY_LICENSE + UNITY_EMAIL + UNITY_PASSWORD) are not all set; skipping Unity smoke test. See test/Unity/README.md for setup."
else
echo "has_license=true" >> "$GITHUB_OUTPUT"
fi
- name: Checkout
if: steps.license_check.outputs.has_license == 'true'
uses: actions/checkout@v4
with:
lfs: false
- name: Setup .NET
if: steps.license_check.outputs.has_license == 'true'
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Build SIPSorcery and stage Unity plugin DLLs
if: steps.license_check.outputs.has_license == 'true'
env:
PLUGINS_DIR: test/Unity/SipSorceryUnitySmokeTest/Assets/Plugins
run: |
set -euo pipefail
mkdir -p staging "$PLUGINS_DIR"
dotnet publish src/SIPSorcery/SIPSorcery.csproj \
--configuration Release \
--framework netstandard2.1 \
--output staging
# Copy DLLs into Assets/Plugins, excluding ones Unity already
# provides as built-in reference assemblies (the duplicates cause
# CS1703 "Multiple assemblies with equivalent identity").
unity_provided=(
Microsoft.CSharp.dll
)
for dll in staging/*.dll; do
name=$(basename "$dll")
skip=false
for provided in "${unity_provided[@]}"; do
if [ "$name" = "$provided" ]; then skip=true; break; fi
done
if [ "$skip" = "false" ]; then
cp -v "$dll" "$PLUGINS_DIR/"
else
echo "Skipping Unity-provided $name"
fi
done
- name: Generate plugin .meta files
if: steps.license_check.outputs.has_license == 'true'
env:
PLUGINS_DIR: test/Unity/SipSorceryUnitySmokeTest/Assets/Plugins
# Without these, Unity defaults validateReferences=true and refuses
# to load plugins with unresolved transitive refs (notably
# Makaretu.Dns.Multicast -> Tmds.LibC). Pre-authoring the .meta
# files lets the smoke test run in a single Unity invocation.
run: |
set -euo pipefail
for dll in "$PLUGINS_DIR"/*.dll; do
meta="$dll.meta"
if [ -f "$meta" ]; then continue; fi
guid=$(printf "%s" "$(basename "$dll")" | md5sum | cut -c1-32)
cat > "$meta" <<EOF
fileFormatVersion: 2
guid: $guid
PluginImporter:
externalObjects: {}
serializedVersion: 3
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 0
platformData:
Any:
enabled: 1
settings: {}
Editor:
enabled: 1
settings:
DefaultValueInitialized: true
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
EOF
done
- name: Cache Unity Library
if: steps.license_check.outputs.has_license == 'true'
uses: actions/cache@v4
with:
path: test/Unity/SipSorceryUnitySmokeTest/Library
key: Library-SipSorceryUnitySmokeTest-${{ matrix.unityVersion }}-${{ hashFiles('test/Unity/SipSorceryUnitySmokeTest/Packages/manifest.json', 'test/Unity/SipSorceryUnitySmokeTest/ProjectSettings/ProjectVersion.txt') }}
restore-keys: |
Library-SipSorceryUnitySmokeTest-${{ matrix.unityVersion }}-
Library-SipSorceryUnitySmokeTest-
- name: Run Unity ${{ matrix.testMode }} tests
if: steps.license_check.outputs.has_license == 'true'
uses: game-ci/unity-test-runner@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
projectPath: test/Unity/SipSorceryUnitySmokeTest
unityVersion: ${{ matrix.unityVersion }}
testMode: ${{ matrix.testMode }}
artifactsPath: test/Unity/SipSorceryUnitySmokeTest/artifacts
githubToken: ${{ secrets.GITHUB_TOKEN }}
checkName: Unity ${{ matrix.testMode }} results
- name: Upload test results
if: always() && steps.license_check.outputs.has_license == 'true'
uses: actions/upload-artifact@v4
with:
name: unity-test-results-${{ matrix.unityVersion }}-${{ matrix.testMode }}
path: test/Unity/SipSorceryUnitySmokeTest/artifacts
smoke-test-windows:
# Windows-runner job that actually reproduces issue #1614 — the bug is
# in Unity's Windows-shipped Mono runtime (NetworkInformation.NetworkChange
# throws PlatformNotSupportedException), and the GameCI Linux container
# runs Linux Mono where the same code path works. Without this job the
# smoke test passes even when the bug is present.
name: Unity ${{ matrix.unityVersion }} PlayMode smoke test (Windows)
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
unityVersion:
- 6000.4.7f1
steps:
- name: Check for Unity license secret
id: license_check
shell: bash
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
run: |
if [ -z "$UNITY_EMAIL" ] || [ -z "$UNITY_PASSWORD" ]; then
echo "has_license=false" >> "$GITHUB_OUTPUT"
echo "::warning::UNITY_EMAIL / UNITY_PASSWORD secrets are not set; skipping Unity Windows smoke test. See test/Unity/README.md for setup."
else
echo "has_license=true" >> "$GITHUB_OUTPUT"
fi
- name: Checkout
if: steps.license_check.outputs.has_license == 'true'
uses: actions/checkout@v4
with:
lfs: false
- name: Setup .NET
if: steps.license_check.outputs.has_license == 'true'
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Build SIPSorcery and stage Unity plugin DLLs
if: steps.license_check.outputs.has_license == 'true'
shell: bash
env:
PLUGINS_DIR: test/Unity/SipSorceryUnitySmokeTest/Assets/Plugins
run: |
set -euo pipefail
mkdir -p staging "$PLUGINS_DIR"
dotnet publish src/SIPSorcery/SIPSorcery.csproj \
--configuration Release \
--framework netstandard2.1 \
--output staging
unity_provided=(
Microsoft.CSharp.dll
)
for dll in staging/*.dll; do
name=$(basename "$dll")
skip=false
for provided in "${unity_provided[@]}"; do
if [ "$name" = "$provided" ]; then skip=true; break; fi
done
if [ "$skip" = "false" ]; then
cp -v "$dll" "$PLUGINS_DIR/"
else
echo "Skipping Unity-provided $name"
fi
done
- name: Generate plugin .meta files
if: steps.license_check.outputs.has_license == 'true'
shell: bash
env:
PLUGINS_DIR: test/Unity/SipSorceryUnitySmokeTest/Assets/Plugins
run: |
set -euo pipefail
for dll in "$PLUGINS_DIR"/*.dll; do
meta="$dll.meta"
if [ -f "$meta" ]; then continue; fi
guid=$(printf "%s" "$(basename "$dll")" | md5sum | cut -c1-32)
cat > "$meta" <<EOF
fileFormatVersion: 2
guid: $guid
PluginImporter:
externalObjects: {}
serializedVersion: 3
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 0
platformData:
Any:
enabled: 1
settings: {}
Editor:
enabled: 1
settings:
DefaultValueInitialized: true
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
EOF
done
- name: Cache Unity Library
if: steps.license_check.outputs.has_license == 'true'
uses: actions/cache@v4
with:
path: test/Unity/SipSorceryUnitySmokeTest/Library
key: Library-Windows-SipSorceryUnitySmokeTest-${{ matrix.unityVersion }}-${{ hashFiles('test/Unity/SipSorceryUnitySmokeTest/Packages/manifest.json', 'test/Unity/SipSorceryUnitySmokeTest/ProjectSettings/ProjectVersion.txt') }}
restore-keys: |
Library-Windows-SipSorceryUnitySmokeTest-${{ matrix.unityVersion }}-
Library-Windows-SipSorceryUnitySmokeTest-
- name: Install Unity ${{ matrix.unityVersion }}
id: unity
if: steps.license_check.outputs.has_license == 'true'
uses: RageAgainstThePixel/unity-setup@v2
with:
unity-version: ${{ matrix.unityVersion }}
build-targets: StandaloneWindows64
cache-installation: true
- name: Activate Unity license
if: steps.license_check.outputs.has_license == 'true'
uses: RageAgainstThePixel/activate-unity-license@v2
with:
license: Personal
username: ${{ secrets.UNITY_EMAIL }}
password: ${{ secrets.UNITY_PASSWORD }}
- name: Run Unity PlayMode tests
if: steps.license_check.outputs.has_license == 'true'
timeout-minutes: 30
shell: pwsh
run: |
$proj = "$env:GITHUB_WORKSPACE\test\Unity\SipSorceryUnitySmokeTest"
$unity = "${{ steps.unity.outputs.unity-editor-path }}"
if (-not (Test-Path $unity)) {
throw "Unity editor path not found: $unity"
}
New-Item -ItemType Directory -Path "$proj\artifacts" -Force | Out-Null
$results = "$proj\artifacts\playmode-results.xml"
$log = "$proj\artifacts\playmode.log"
Write-Host "Running: $unity"
# Unity.exe is a Windows-subsystem app, so PowerShell's call
# operator (`&`) returns immediately without waiting. Use
# Start-Process -Wait -PassThru to actually block on it and
# capture the exit code.
$unityArgs = @(
'-batchmode',
'-projectPath', $proj,
'-runTests',
'-testPlatform', 'PlayMode',
'-testResults', $results,
'-logFile', $log
)
$proc = Start-Process -FilePath $unity -ArgumentList $unityArgs `
-NoNewWindow -PassThru -Wait
$unityExit = $proc.ExitCode
Write-Host "Unity process exit code: $unityExit"
if (-not (Test-Path $results)) {
Write-Host "::error::No test-results.xml produced — Unity likely crashed before tests ran."
if (Test-Path $log) { Get-Content $log -Tail 100 }
exit 1
}
[xml]$xml = Get-Content $results
$run = $xml.'test-run'
$passed = [int]$run.passed
$failed = [int]$run.failed
$total = [int]$run.total
Write-Host "Results: total=$total passed=$passed failed=$failed result=$($run.result)"
if ($failed -gt 0) {
Write-Host "::error::$failed Unity PlayMode test(s) failed"
# Surface the failure messages, plus the tail of the Unity log
# for diagnosis.
$xml.SelectNodes("//test-case[@result='Failed']") | ForEach-Object {
Write-Host "----- FAILED: $($_.fullname) -----"
Write-Host $_.failure.message.InnerText
Write-Host $_.failure.'stack-trace'.InnerText
}
exit 1
}
if ($total -eq 0) {
Write-Host "::error::0 tests were discovered — plugin import or compile likely failed."
if (Test-Path $log) { Get-Content $log -Tail 100 }
exit 1
}
- name: Upload test results
if: always() && steps.license_check.outputs.has_license == 'true'
uses: actions/upload-artifact@v4
with:
name: unity-test-results-windows-${{ matrix.unityVersion }}-playmode
path: test/Unity/SipSorceryUnitySmokeTest/artifacts