forked from getsentry/sentry-unity
-
Notifications
You must be signed in to change notification settings - Fork 0
469 lines (408 loc) · 18.4 KB
/
ci.yml
File metadata and controls
469 lines (408 loc) · 18.4 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
name: CI
on:
push:
paths-ignore:
- 'CHANGELOG.md'
branches:
- main
- release/**
pull_request:
paths-ignore:
- 'CHANGELOG.md'
jobs:
build:
name: Unity ${{ matrix.unity-version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 120
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
# 2022.1.0a12 removed until S.T.J issues fixed
unity-version: [2019.4.33f1, 2020.3.21f1, 2021.1.26f1]
include:
- os: windows-latest
unity-installation-path: C:/Program Files/Unity/
unity-root: C:/Program Files/Unity/Hub/Editor/
unity-path: Editor/
unity-config-path: C:/ProgramData/Unity/config/
- os: macos-latest
unity-installation-path: /Applications/Unity/
unity-root: /Applications/Unity/Hub/Editor/
unity-path: Unity.app/Contents/MacOS
unity-config-path: /Library/Application Support/Unity/config/
- unity-version: 2019.4.33f1
unity-version-changeset: c9b2b02eeeef
- unity-version: 2020.3.21f1
unity-version-changeset: a38c86f6690f
- unity-version: 2021.1.26f1
unity-version-changeset: 6f076387c01d
# - unity-version: 2022.1.0a12
# unity-version-changeset: 816252c3efbb
steps:
# Tag: 0.9.1
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@a40b8845c0683271d9f53dfcb887a7e181d3918b
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v2.3.3
with:
submodules: recursive
- run: echo "::add-mask::${{ secrets.LICENSE_SERVER_URL }}"
- name: Setup .NET SDK (v6.0)
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: "Set up Java: 11"
uses: actions/setup-java@v1
with:
java-version: 11
# Unity is about 4GB in size and takes 20 minutes to download and install.
# Caching still takes some time, but brings it down to about 5 minutes.
- name: Restore cached Unity installation
id: cache-unity
uses: actions/cache@v2
with:
path: ${{ matrix.unity-installation-path }}
key: ${{ matrix.os }}-${{ matrix.unity-version }}-${{ matrix.unity-version-changeset }}
- name: Restore previous build
uses: actions/cache@v2
with:
path: samples/artifacts/builds
# using hash of package.json to bust cache on release builds which modify it
key: ${{ matrix.os }}-${{ matrix.unity-version }}-${{ matrix.unity-version-changeset }}-${{ hashFiles('package/package.json') }}
- name: Restore Unity Packages
uses: actions/cache@v2
with:
path: samples/unity-of-bugs/Library
key: ${{ matrix.os }}-${{ matrix.unity-version }}-${{ matrix.unity-version-changeset }}-${{ hashFiles('samples/unity-of-bugs/Packages/packages-lock.json') }}
- name: Get submodule information
run: |
git submodule status > submodules-status
cat submodules-status
- name: Restore native SDKs
uses: actions/cache@v2
with:
# The raw NDK symbols are needed to get bundled for the final craft artifact
path: |
package-dev/Plugins/iOS
package-dev/Plugins/Android
modules/sentry-java/sentry-android-ndk/build/intermediates/merged_native_libs/release/out/lib
# We only build the native SDKs if the respective 'package-dev/Plugins/' directories are empty
# Output changes only depending on the git sha of the submodules
# hash of package/package.json for cache busting on release builds (version bump)
key: ${{ matrix.os }}-${{ hashFiles('submodules-status') }}-${{ matrix.unity-version }}-${{ matrix.unity-version-changeset }}-${{ hashFiles('package/package.json') }}
- name: Setup Unity
uses: getsentry/setup-unity@46c2e082d98cc3a825a5b59038cb31705fe9ff56
id: setup-unity
with:
unity-version: ${{ matrix.unity-version }}
unity-version-changeset: ${{ matrix.unity-version-changeset }}
- name: Setup Unity Modules - Windows IL2CPP
if: matrix.os == 'windows-latest'
uses: getsentry/setup-unity@46c2e082d98cc3a825a5b59038cb31705fe9ff56
with:
unity-version: ${{ matrix.unity-version }}
unity-modules: windows-il2cpp
- name: Setup Unity Modules - macOS IL2CPP
if: matrix.os == 'macos-latest'
uses: getsentry/setup-unity@46c2e082d98cc3a825a5b59038cb31705fe9ff56
with:
unity-version: ${{ matrix.unity-version }}
unity-modules: mac-il2cpp
- name: Setup Unity Modules - Android
uses: getsentry/setup-unity@46c2e082d98cc3a825a5b59038cb31705fe9ff56
with:
unity-version: ${{ matrix.unity-version }}
unity-modules: android
- name: Setup Unity Modules - iOS
uses: getsentry/setup-unity@46c2e082d98cc3a825a5b59038cb31705fe9ff56
with:
unity-version: ${{ matrix.unity-version }}
unity-modules: ios
- name: Create Unity license config
shell: pwsh
run: |
New-Item -Path '${{ matrix.unity-config-path }}' -ItemType Directory
Set-Content -Path '${{ matrix.unity-config-path }}services-config.json' -Value '${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}'
# Need to write to $GITHUB_PATH to make the environment variable available to other steps.
- name: Add Unity on PATH
shell: pwsh
run: |
Write-Output '${{ matrix.unity-root }}${{ matrix.unity-version }}/${{ matrix.unity-path }}' | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# Step used to reduce the Unity path to avoid long path errors on Windows.
- name: Make symbolic link for Unity (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
New-Item -ItemType SymbolicLink -Path "C:\${{ matrix.unity-version }}" -Target "C:\Program Files\Unity\Hub\Editor\${{ matrix.unity-version }}"
- name: Install Unity UPM Packages
env:
UNITY_VERSION: ${{ matrix.unity-version }}
run: dotnet msbuild /t:UnityRestorePackages /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
- name: Build Android SDK
env:
UNITY_VERSION: ${{ matrix.unity-version }}
run: dotnet msbuild /t:BuildAndroidSDK /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
- name: Build iOS SDK
env:
UNITY_VERSION: ${{ matrix.unity-version }}
run: dotnet msbuild /t:BuildCocoaSDK /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
- name: Build Sentry.Unity Solution
env:
UNITY_VERSION: ${{ matrix.unity-version }}
run: dotnet build -c Release
- name: Assembly alias
run: |
dotnet tool install --global Alias --version 0.2.0
assemblyalias --target-directory "package-dev/Runtime" --internalize --prefix "Sentry." --assemblies-to-alias "Microsoft*;System*"
- name: Run Unity tests (playmode)
# TODO: Run Play mode tests on 2022 once S.T.J loading issue resolved.
# System.MissingMethodException : Method not found: System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.ReadOnlyMemory`1<byte>,System.Text.Json.JsonDocumentOptions)
if: ${{ matrix.unity-version != '2022.1.0a12' }}
env:
UNITY_VERSION: ${{ matrix.unity-version }}
run: dotnet msbuild /t:UnityPlayModeTest /p:Configuration=Release /p:OutDir=other test/Sentry.Unity.Tests
- name: Upload test artifacts (playmode)
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: Test results (playmode)
path: artifacts/test/playmode
- name: Run Unity tests (editmode)
# TODO: Run Edit mode tests on 2022 once S.T.J loading issue resolved.
# https://forum.unity.com/threads/unity-future-net-development-status.1092205/page-8#post-7602256
if: ${{ matrix.unity-version != '2022.1.0a12' }}
env:
UNITY_VERSION: ${{ matrix.unity-version }}
run: dotnet msbuild /t:UnityEditModeTest /p:Configuration=Release /p:OutDir=other test/Sentry.Unity.Editor.Tests
- name: Upload test artifacts (editmode)
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: Test results (editmode)
path: artifacts/test/editmode
- name: Build Android Player with IL2CPP
env:
UNITY_VERSION: ${{ matrix.unity-version }}
run: dotnet msbuild /t:UnityBuildPlayerAndroidIL2CPP /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
- name: Build iOS Player
if: matrix.os == 'macos-latest'
env:
UNITY_VERSION: ${{ matrix.unity-version }}
run: dotnet msbuild /t:UnityBuildPlayerIOS /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
- name: Build Standalone Player with IL2CPP
env:
UNITY_VERSION: ${{ matrix.unity-version }}
run: dotnet msbuild /t:UnityBuildStandalonePlayerIL2CPP /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
- name: Run Smoke Tests
env:
UNITY_VERSION: ${{ matrix.unity-version }}
run: dotnet msbuild /t:UnitySmokeTestStandalonePlayerIL2CPP /p:OutDir=other src/Sentry.Unity
- name: Preparing test app for smoke test.
uses: actions/upload-artifact@v2
with:
name: droid-testapp-${{ matrix.unity-version }}
path: samples/artifacts/builds/Android/IL2CPP_Player.apk
- name: Prepare Sentry package for release
shell: pwsh
run: ./scripts/pack.ps1
- name: Upload build artifacts if build failed
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: Build output
path: artifacts/build
- name: Integration Test - Create new Project
shell: pwsh
run: ./test/Scripts.Integration.Test/integration-create-project.ps1 "${{ env.UNITY_PATH }}"
- name: Integration Test - Build Standalone Player without Sentry SDK
shell: pwsh
run: ./test/Scripts.Integration.Test/integration-build-project.ps1 "${{ env.UNITY_PATH }}"
- name: Integration Test - Add Sentry to test project
shell: pwsh
run: ./test/Scripts.Integration.Test/integration-update-sentry.ps1 "${{ env.UNITY_PATH }}"
- name: Integration Test - Build Standalone Player Sentry SDK
shell: pwsh
run: ./test/Scripts.Integration.Test/integration-build-project.ps1 "${{ env.UNITY_PATH }}"
- name: Integration Test - Run Player - Smoke Test
shell: pwsh
run: ./test/Scripts.Integration.Test/integration-run-smoke-test.ps1
- name: Upload release artifacts
uses: actions/upload-artifact@v2
# Only on macOS which contain all native plugin needed
if: matrix.os == 'macos-latest'
with:
name: ${{ github.sha }}
if-no-files-found: error
# Adding the native libraries so the symbol collector craft target can find/upload them
path: |
package-release.zip
modules/sentry-java/sentry-android-ndk/build/intermediates/merged_native_libs/release/out/lib/*
- name: Upload Android Build
uses: actions/upload-artifact@v2
with:
name: Android Build
path: samples/artifacts/builds/Android
package-validation:
needs: [build]
name: UPM Package validation
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2.3.3
- name: Download UPM package
uses: actions/download-artifact@v2
with:
# Artifact name is the commit sha. Which is what craft uses to find the relevant artifact.
name: ${{ github.sha }}
- name: Verify package content against snapshot
shell: pwsh
# If this step fails, you can accept the new file content by
# running the following script locally with 'accept' as an argument
# and committing the new snapshot file to your branch. i.e:
# pwsh ./test/Scripts.Tests/test-pack-contents.ps1 accept
run: ./test/Scripts.Tests/test-pack-contents.ps1
android-smoke-test:
needs: [build]
name: Smoke Test - Android ${{ matrix.api-level }} Unity ${{ matrix.unity-version }}
runs-on: macos-latest
strategy:
max-parallel: 5
fail-fast: false
matrix:
api-level: [21, 27, 29]
avd-target: [default]
unity-version: [2019.4.33f1, 2020.3.21f1, 2021.1.26f1]
steps:
- name: Checkout
uses: actions/checkout@v2.3.3
- name: Download test app artifact
uses: actions/download-artifact@v2
with:
name: droid-testapp-${{ matrix.unity-version }}
path: samples/artifacts/builds/Android
- name: Android emulator setup + Smoke test
id: smoke-test
continue-on-error: true
timeout-minutes: 10
uses: reactivecircus/android-emulator-runner@2b2ebf2e518e38a17180117fc2b677006db27330
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.avd-target }}
force-avd-creation: false
ram-size: 2048M
arch: x86
cores: 2
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: sudo pwsh ./scripts/smoke-test-droid.ps1
- name: Kill emulator if AVD failed.
continue-on-error: true
if: ${{ steps.smoke-test.outputs.smoke-status != 'Completed' }}
run: |
adb emu kill
sleep 7
- name: Android emulator setup + Smoke test (Retry)
id: smoke-test-retry
continue-on-error: true
timeout-minutes: 10
# We only want to retry the tests if the previous fail happened on the emulator startup.
if: ${{ steps.smoke-test.outputs.smoke-status != 'Completed' }}
uses: reactivecircus/android-emulator-runner@2b2ebf2e518e38a17180117fc2b677006db27330
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.avd-target }}
ram-size: 2048M
cores: 2
arch: x86
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: sudo pwsh ./scripts/smoke-test-droid.ps1
- name: Throw error if Smoke test failed
# We want to throw an error if the smoke test failed.
# We will ignore flaky errors from the emulator setup.
if: ${{ (steps.smoke-test.outcome != 'success' && steps.smoke-test.outputs.smoke-status == 'Completed') || (steps.smoke-test-retry.outcome != 'success' && steps.smoke-test-retry.outputs.smoke-status == 'Completed') }}
run: exit -1
- name: Upload screenshot if smoke test failed
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: droid-${{ matrix.api-level }}-testapp${{ matrix.unity-version }}-screenshot
path: samples/artifacts/builds/Android/screen.png
android-smoke-test-with-gservices:
needs: [build]
name: Smoke Test - Android ${{ matrix.api-level }} Unity ${{ matrix.unity-version }}
runs-on: macos-latest
strategy:
max-parallel: 2
fail-fast: false
matrix:
api-level: [30]
avd-target: [google_apis]
#api-level 30 image is only available with google services.
unity-version: [2019.4.33f1, 2020.3.21f1, 2021.1.26f1]
steps:
- name: Checkout
uses: actions/checkout@v2.3.3
- name: Download test app artifact
uses: actions/download-artifact@v2
with:
name: droid-testapp-${{ matrix.unity-version }}
path: samples/artifacts/builds/Android
- name: Android emulator setup + Smoke test
id: smoke-test
continue-on-error: true
timeout-minutes: 10
uses: reactivecircus/android-emulator-runner@2b2ebf2e518e38a17180117fc2b677006db27330
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.avd-target }}
force-avd-creation: false
ram-size: 2048M
arch: x86
cores: 2
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: sudo pwsh ./scripts/smoke-test-droid.ps1
- name: Kill emulator if AVD failed.
continue-on-error: true
if: ${{ steps.smoke-test.outputs.smoke-status != 'Completed' }}
run: |
adb emu kill
sleep 7
- name: Android emulator setup + Smoke test (Retry)
id: smoke-test-retry
continue-on-error: true
timeout-minutes: 10
# We only want to retry the tests if the previous fail happened on the emulator startup.
if: ${{ steps.smoke-test.outputs.smoke-status != 'Completed' }}
uses: reactivecircus/android-emulator-runner@2b2ebf2e518e38a17180117fc2b677006db27330
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.avd-target }}
ram-size: 2048M
cores: 2
arch: x86
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: sudo pwsh ./scripts/smoke-test-droid.ps1
- name: Throw error if Smoke test failed
# We want to throw an error if the smoke test failed.
# We will ignore flaky errors from the emulator setup.
if: ${{ (steps.smoke-test.outcome != 'success' && steps.smoke-test.outputs.smoke-status == 'Completed') || (steps.smoke-test-retry.outcome != 'success' && steps.smoke-test-retry.outputs.smoke-status == 'Completed') }}
run: exit -1
- name: Upload screenshot if smoke test failed
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: droid-${{ matrix.api-level }}-testapp${{ matrix.unity-version }}-screenshot
path: samples/artifacts/builds/Android/screen.png