-
Notifications
You must be signed in to change notification settings - Fork 157
/
main.yml
595 lines (562 loc) · 23.9 KB
/
main.yml
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
#@ load("@ytt:template", "template")
#@ load("@ytt:overlay", "overlay")
#@ load("common.lib.yml", "configuration", "nugetPackages", "checkoutCode", "setupVcpkg", "actionCache", "actionUploadArtifact", "actionDownloadArtifact", "actionSetupMSBuild", "actionSetupDotnet", "actionRuniOSSimulator", "actionDockerLayerCaching", "actionDockerBuild", "actionDockerRun", "actionCoveralls", "actionDeleteArtifact", "actionDeployBaaS", "actionCleanupBaaS", "readVersionFromPackage", "uploadPackagesToSleet")
#@ isRelease = "contains(github.head_ref, 'release')"
#@ secret_BaseUrl = "${{ (" + isRelease + " && secrets.REALM_QA_BASE_URL) || secrets.REALM_BASE_URL }}"
#@ secret_AtlasBaseUrl = "${{ (" + isRelease + " && secrets.ATLAS_QA_BASE_URL) || secrets.ATLAS_BASE_URL }}"
#@ secret_AtlasPublicKey = "${{ (" + isRelease + " && secrets.ATLAS_QA_PUBLIC_API_KEY) || secrets.ATLAS_PUBLIC_API_KEY }}"
#@ secret_AtlasPrivateKey = "${{ (" + isRelease + " && secrets.ATLAS_QA_PRIVATE_API_KEY) || secrets.ATLAS_PRIVATE_API_KEY }}"
#@ secret_AtlasProjectId = "${{ (" + isRelease + " && secrets.ATLAS_QA_PROJECT_ID) || secrets.ATLAS_PROJECT_ID }}"
#@ androidABIs = [ 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' ]
#@ windowsArchs = [ 'Win32', 'x64' ]
#@ windowsUWPArchs = [ 'Win32', 'x64', 'ARM' ]
#@ wrappersCacheCondition = "steps.check-cache.outputs.cache-hit != 'true'"
#@ dotnetRuntime = "${{ (runner.os == 'macOS' && 'osx-x64') || (runner.os == 'Windows' && 'win-x64') || (runner.os == 'Linux' && 'linux-x64') || '???' }}"
#@ testTimeout = 45
#@ cleanupTimeout = 10
#@ baasTimeout = 20
#@ wrappersTimeout = 45
#@ baasTestArgs = " --baasurl=" + secret_BaseUrl + " --baascluster=${{ env.CLUSTER_NAME }} --baasapikey=" + secret_AtlasPublicKey + " --baasprivateapikey=" + secret_AtlasPrivateKey + " --baasprojectid=" + secret_AtlasProjectId
#@ def getWrapperBuildCommand(cmd, enableLto = True):
#@ defaultParams = " --configuration=" + configuration
#@ if enableLto:
#@ defaultParams = defaultParams + " -DCMAKE_INTERPROCEDURAL_OPTIMIZATION='ON'"
#@ end
#@ if cmd.startswith("powershell"):
#@ defaultParams = " -Configuration " + configuration
#@ if enableLto:
#@ defaultParams = defaultParams + " -EnableLTO"
#@ end
#@ end
#@ return cmd + defaultParams
#@ end
#@ def checkCache(outputVar):
#@ key = outputVar + "-" + configuration + "-${{hashFiles('./wrappers/**')}}"
name: Check cache
id: check-cache
uses: #@ actionCache
with:
path: ./wrappers/build/**
key: #@ key
#@ end
#@ def testJob(name, os, intermediateSteps, usePackage = True):
#@ baasJobName = "baas-" + name.replace(".", "").replace(" ", "-").lower()
#@ testJobName = "test-" + name.replace(".", "").replace(" ", "-").lower()
#@ cleanupJobName = "cleanup-" + name.replace(".", "").replace(" ", "-").lower()
#@yaml/text-templated-strings
(@= baasJobName @):
runs-on: ubuntu-latest
name: #@ "Deploy MDB Realm for " + name
outputs:
clusterName: ${{ steps.deploy-mdb-apps.outputs.clusterName }}
timeout-minutes: #@ baasTimeout
steps:
- #@ template.replace(checkoutCode(False, False))
- uses: #@ actionDeployBaaS
id: deploy-mdb-apps
with:
projectId: #@ secret_AtlasProjectId
realmUrl: #@ secret_BaseUrl
atlasUrl: #@ secret_AtlasBaseUrl
apiKey: #@ secret_AtlasPublicKey
privateApiKey: #@ secret_AtlasPrivateKey
differentiator: #@ name
#@yaml/text-templated-strings
(@= testJobName @):
runs-on: #@ os
name: #@ "Test " + name
needs:
- build-packages
- #@ baasJobName
env:
CLUSTER_NAME: #@ "${{ needs.baas-" + name.replace(".", "").replace(" ", "-").lower() + ".outputs.clusterName }}"
timeout-minutes: #@ testTimeout
steps:
- #@ template.replace(checkoutCode())
#@ if usePackage:
- #@ template.replace(fetchPackageArtifacts())
#@ else:
- #@ template.replace(fetchWrapperBinaries())
#@ end
#@ for step in intermediateSteps:
- #@ step
#@ end
#@yaml/text-templated-strings
(@= cleanupJobName @):
runs-on: ubuntu-latest
name: #@ "Cleanup " + name
needs:
- #@ testJobName
if: always()
timeout-minutes: #@ cleanupTimeout
steps:
- #@ template.replace(checkoutCode(False, False))
- uses: #@ actionCleanupBaaS
with:
projectId: #@ secret_AtlasProjectId
realmUrl: #@ secret_BaseUrl
atlasUrl: #@ secret_AtlasBaseUrl
apiKey: #@ secret_AtlasPublicKey
privateApiKey: #@ secret_AtlasPrivateKey
differentiator: #@ name
#@ end
#@ def uploadArtifacts(artifactName, relPath, retentionDays = "${{ github.event_name != 'pull_request' && 30 || 1 }}"):
name: #@ "Store artifacts for " + artifactName
uses: #@ actionUploadArtifact
with:
name: #@ artifactName
path: #@ "${{ github.workspace }}/" + relPath
retention-days: #@ retentionDays
#@ end
#@ def buildWrappers(cmd, outputVar, intermediateSteps = [], enableLto = True):
timeout-minutes: #@ wrappersTimeout
steps:
- #@ template.replace(checkoutCode("recursive"))
- #@ checkCache(outputVar)
#@ for step in intermediateSteps:
- #@ template.replace(step)
#@ end
- name: Build wrappers
run: #@ getWrapperBuildCommand(cmd, enableLto)
if: #@ wrappersCacheCondition
- #@ uploadArtifacts(outputVar, "wrappers/build/**", 1)
#@ end
#@ def setupWin81SDK():
- name: Install Win8.1 SDK
run: |
md C:\win81sdk
Invoke-WebRequest -Method Get -Uri https://go.microsoft.com/fwlink/p/?LinkId=323507 -OutFile C:\win81sdk\sdksetup.exe -UseBasicParsing
Start-Process -Wait C:\win81sdk\sdksetup.exe -ArgumentList "/q", "/norestart", "/features", "OptionId.WindowsDesktopSoftwareDevelopmentKit", "OptionId.NetFxSoftwareDevelopmentKit"
shell: powershell
if: #@ wrappersCacheCondition
#@ end
#@ def buildPackages():
#@ for pkgName in nugetPackages:
- #@ msbuild("Realm/" + pkgName, target="Pack", PackageOutputPath="${{ github.workspace }}/Realm/packages", VersionSuffix="${{ steps.set-version-suffix.outputs.build_suffix }}")
#@ end
#@ end
#@ def msbuildOnWin(projectPath, **properties):
- name: Add msbuild to PATH
uses: #@ actionSetupMSBuild
- #@ msbuild(projectPath, RestoreConfigFile="Tests/Test.NuGet.Config", UseRealmNupkgsWithVersion="${{ needs.build-packages.outputs.package_version }}", **properties)
#@ end
#@ def buildUnityPackage():
#@ finalPkgName = "io.realm.unity-" + "${{ steps.get-version.outputs.version }}.tgz"
- name: #@ "Build Unity"
run: #@ "dotnet run --project Tools/SetupUnityPackage/ -- realm --packages-path Realm/packages --pack"
- #@ uploadArtifacts(finalPkgName, "Realm/Realm.Unity/" + finalPkgName)
#@ end
#@ def netFrameworkTestSteps():
- #@ template.replace(msbuildOnWin("Tests/Realm.Tests", TargetFramework="net461"))
- name: Run the tests
run: #@ "./Tests/Realm.Tests/bin/" + configuration + "/net461/Realm.Tests.exe --result=TestResults.Windows.xml --labels=After" + baasTestArgs
- #@ publishTestsResults("TestResults.Windows.xml", ".NET Framework")
#@ end
#@ def uwpTestSteps():
- name: Import test certificate
run: |
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
$currentDirectory = Get-Location
[IO.File]::WriteAllBytes("${{ github.workspace }}\Tests\Tests.UWP\Tests.UWP_TemporaryKey.pfx", $pfx_cert_byte)
certutil -f -p ${{ secrets.Pfx_Password }} -importpfx my ${{ github.workspace }}\Tests\Tests.UWP\Tests.UWP_TemporaryKey.pfx
shell: powershell
- #@ template.replace(msbuildOnWin("Tests/Tests.UWP", AppxBundle="Always", PackageCertificateKeyFile="${{ github.workspace }}\Tests\Tests.UWP\Tests.UWP_TemporaryKey.pfx", PackageCertificatePassword="${{ secrets.Pfx_Password }}", UseDotNetNativeToolchain="false", AppxBundlePlatforms="x64"))
- name: Run the tests
run: #@ "./Tests/Tests.UWP/RunTests.ps1 -ExtraAppArgs '" + baasTestArgs + "'"
shell: powershell
- #@ publishTestsResults("${{ env.TEST_RESULTS }}", "UWP Managed")
#@ end
#@ def xamarinMacTestSteps():
- #@ msbuild("Tests/Tests.XamarinMac", RestoreConfigFile="Tests/Test.NuGet.Config", UseRealmNupkgsWithVersion="${{ needs.build-packages.outputs.package_version }}")
- name: Run the tests
run: #@ "Tests/Tests.XamarinMac/bin/" + configuration + "/Tests.XamarinMac.app/Contents/MacOS/Tests.XamarinMac --headless --result=${{ github.workspace }}/TestResults.macOS.xml --labels=All" + baasTestArgs
- #@ publishTestsResults("TestResults.macOS.xml", "Xamarin.macOS")
#@ end
#@ def xamariniOSTestSteps():
- #@ msbuild("Tests/Tests.iOS", Platform="iPhoneSimulator", RestoreConfigFile="Tests/Test.NuGet.Config", UseRealmNupkgsWithVersion="${{ needs.build-packages.outputs.package_version }}")
- name: Run the tests
uses: #@ actionRuniOSSimulator
with:
appPath: 'Tests/Tests.iOS/bin/iPhoneSimulator/Release/Tests.iOS.app'
bundleId: 'io.realm.dotnettests'
iphoneToSimulate: 'iPhone-8'
arguments: #@ "--headless --result=${{ github.workspace }}/TestResults.iOS.xml" + baasTestArgs
- #@ publishTestsResults("TestResults.iOS.xml", "Xamarin.iOS")
#@ end
#@ def xamarinAndroidTestSteps():
- #@ msbuild("Tests/Tests.Android", target="SignAndroidPackage", AndroidSupportedAbis="x86_64", AndroidUseSharedRuntime="False", EmbedAssembliesIntoApk="True", RestoreConfigFile="Tests/Test.NuGet.Config", UseRealmNupkgsWithVersion="${{ needs.build-packages.outputs.package_version }}")
- name: AVD cache
uses: actions/cache@v2
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: android-avd
- name: Create AVD for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Run the tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
arch: x86_64
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
#@yaml/text-templated-strings
script: |
adb devices
adb logcat -c
adb logcat -v time > "${{ github.workspace }}/logcat.txt" &
adb install ${{ github.workspace }}/Tests/Tests.Android/bin/Release/io.realm.xamarintests-Signed.apk
adb shell pm grant io.realm.xamarintests android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant io.realm.xamarintests android.permission.WRITE_EXTERNAL_STORAGE
echo "--baasurl=(@= secret_BaseUrl @) --baascluster=${{ env.CLUSTER_NAME }} --baasapikey=(@= secret_AtlasPublicKey @) --baasprivateapikey=(@= secret_AtlasPrivateKey @) --baasprojectid=(@= secret_AtlasProjectId @)" > ${{ github.workspace }}/testargs.txt
adb push ${{ github.workspace }}/testargs.txt /storage/emulated/0/RealmTests/testargs.txt
adb shell am instrument -w -r io.realm.xamarintests/.TestRunner
adb pull /storage/emulated/0/RealmTests/TestResults.Android.xml ${{ github.workspace }}/TestResults.Android.xml
adb shell rm /sdcard/Realmtests/TestResults.Android.xml
- name: Output logcat
if: always()
run: cat logcat.txt
- #@ publishTestsResults("TestResults.Android.xml", "Xamarin.Android")
#@ end
#@ def codeCoverageTestSteps():
- uses: #@ actionSetupDotnet
with:
dotnet-version: '5.0.x'
- name: Setup Coverlet & Report Generator
run: |
dotnet tool install coverlet.console --tool-path tools
dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools
echo "${{ github.workspace }}/tools" >> $GITHUB_PATH
- #@ template.replace(dotnetPublish("Tests/Realm.Tests", "net5.0", { "AdditionalFrameworks": "net5.0" }))
- name: Run the tests
run: #@ "./tools/coverlet ${{ steps.dotnet-publish.outputs.executable-path }} -t ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests -a '--result=TestResults.Linux.xml --labels=After" + baasTestArgs + "' -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*'"
- name: Publish Coverage
id: publish-coveralls
uses: #@ actionCoveralls
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./report.lcov
git-commit: ${{ github.event.pull_request.head.sha }}
- name: Output Coveralls response
run: echo ${{ steps.publish-coveralls.outputs.coveralls-api-result }}
- #@ publishTestsResults("TestResults.Linux.xml", "Code Coverage")
#@ end
#@ def buildDocs():
#@ docsCondition = "${{ " + isRelease + " }}"
- name: Check Docfx cache
id: check-docfx-cache
if: #@ docsCondition
uses: #@ actionCache
with:
path: 'C:\docfx'
key: docfx
- name: Download docfx
if: #@ "${{ steps.check-docfx-cache.outputs.cache-hit != 'true' && " + isRelease + " }}"
run: |
Invoke-WebRequest -Uri https://github.com/dotnet/docfx/releases/download/v2.58/docfx.zip -OutFile C:\docfx.zip
Expand-Archive -Path C:\docfx.zip -DestinationPath C:\docfx
shell: powershell
- name: Build docs
if: #@ docsCondition
run: |
C:\docfx\docfx Docs/docfx.json
Compress-Archive -Path Docs/_site -DestinationPath "Realm/packages/Docs.zip"
- _: #@ template.replace(uploadArtifacts("Docs.zip", "Realm/packages/Docs.zip"))
if: #@ docsCondition
#@ end
#@ def uploadPackageArtifacts():
#@ for pkgName in [ 'Realm.Fody', 'Realm' ]:
#@ finalPkgName = pkgName + ".${{ steps.get-version.outputs.version }}"
- #@ uploadArtifacts(finalPkgName, "Realm/packages/" + finalPkgName + ".*nupkg")
#@ end
#@ end
#@ def fetchPackageArtifacts():
#@ for pkg in [ "Realm", "Realm.Fody" ]:
- name: #@ "Fetch " + pkg
uses: #@ actionDownloadArtifact
with:
name: #@ pkg + ".${{ needs.build-packages.outputs.package_version }}"
path: ${{ github.workspace }}/Realm/packages/
#@ end
#@ end
#@ def getWrapperBinaryNames():
#@ wrapperPlatforms = [ 'macos', 'ios', 'linux' ]
#@ for androidABI in androidABIs:
#@ wrapperPlatforms.append("android-" + androidABI)
#@ end
#@ for windowsArch in windowsArchs:
#@ wrapperPlatforms.append("windows-" + windowsArch)
#@ end
#@ for uwpArch in windowsUWPArchs:
#@ wrapperPlatforms.append("windows-uwp-" + uwpArch)
#@ end
#@
#@ return wrapperPlatforms
#@ end
#@ def fetchWrapperBinaries():
#@ for platform in getWrapperBinaryNames():
- name: #@ "Fetch artifacts for " + platform
uses: #@ actionDownloadArtifact
with:
name: #@ "wrappers-" + platform
path: wrappers/build
#@ end
#@ end
#@ def dotnetPublishAndRunTests(projectPath, framework, executeCommand):
#@ properties = {
#@ "AdditionalFrameworks": framework,
#@ "RestoreConfigFile": "Tests/Test.NuGet.Config",
#@ "UseRealmNupkgsWithVersion": "${{ needs.build-packages.outputs.package_version }}"
#@ }
#@
- #@ template.replace(dotnetPublish(projectPath, framework, properties))
- name: Run the tests
run: #@ "${{ steps.dotnet-publish.outputs.executable-path }}/" + executeCommand
#@ end
#@ def dotnetPublish(projectPath, framework, properties = {}):
#@ propsArg = ""
#@ for prop in properties.keys():
#@ propsArg += " -p:" + prop + "=" + properties[prop]
#@ end
- name: #@ "Publish " + projectPath
run: #@ "dotnet publish " + projectPath + " -c " + configuration + " -f " + framework + " -r " + dotnetRuntime + propsArg + " --no-self-contained"
- name: Output executable path
id: dotnet-publish
run: #@ "echo '::set-output name=executable-path::./" + projectPath + "/bin/" + configuration + "/" + framework + "/" + dotnetRuntime + "'"
#@ end
#@ def publishTestsResults(files, test_title):
name: Publish Unit Test Results
uses: LaPeste/test-reporter@b8a650f4490e7472b930f56bbb92c7b42dc5db15 #! v1.5.1
if: always()
with:
name: #@ "Results " + test_title
path: #@ files
reporter: java-junit
list-suites: failed
list-tests: failed
path-replace-backslashes: true
fail-on-error: false
#@ end
#@ def msbuild(projectPath, **properties):
#@ parsedProps = ""
#@ target = ""
#@ for prop in properties.keys():
#@ if prop == "target":
#@ target = " -t:" + properties[prop]
#@ else:
#@ parsedProps += " -p:" + prop + "=" + properties[prop]
#@ end
#@ end
#@
name: #@ "Build " + projectPath
run: #@ "msbuild " + projectPath + target + " -p:Configuration=" + configuration + " -restore" + parsedProps
#@ end
---
name: main
"on":
push:
branches:
- main
- master
pull_request:
env:
REALM_DISABLE_ANALYTICS: true
DOTNET_NOLOGO: true
jobs:
build-wrappers-macos:
runs-on: macos-latest
name: Wrappers macOS
_: #@ template.replace(buildWrappers("./wrappers/build-macos.sh", "wrappers-macos"))
build-wrappers-ios:
runs-on: macos-latest
name: Wrappers iOS
_: #@ template.replace(buildWrappers("./wrappers/build-ios.sh", "wrappers-ios"))
build-wrappers-linux:
runs-on: ubuntu-latest
name: Wrappers Linux
timeout-minutes: #@ wrappersTimeout
steps:
- #@ template.replace(checkoutCode("recursive"))
- #@ checkCache("wrappers-linux")
- uses: #@ actionDockerLayerCaching
continue-on-error: true
if: #@ wrappersCacheCondition
- name: Build CentOS image
uses: #@ actionDockerBuild
with:
tags: wrappers-centos:latest
file: ./wrappers/centos.Dockerfile
push: false
if: #@ wrappersCacheCondition
- name: Build wrappers
uses: #@ actionDockerRun
with:
image: wrappers-centos:latest
shell: bash
options: -v ${{ github.workspace }}:/work
run: #@ getWrapperBuildCommand("/work/wrappers/build.sh")
if: #@ wrappersCacheCondition
- #@ uploadArtifacts("wrappers-linux", "wrappers/build/**", 1)
build-wrappers-android:
runs-on: ubuntu-20.04
name: Wrappers Android
strategy:
matrix:
arch: #@ androidABIs
_: #@ template.replace(buildWrappers("./wrappers/build-android.sh --ARCH=${{ matrix.arch }}", "wrappers-android-${{ matrix.arch }}", [], False))
build-wrappers-windows:
runs-on: windows-latest
name: Wrappers Windows
strategy:
matrix:
arch: #@ windowsArchs
_: #@ template.replace(buildWrappers("powershell ./wrappers/build.ps1 Windows -Platforms ${{ matrix.arch }}", "wrappers-windows-${{ matrix.arch }}", [ setupVcpkg(wrappersCacheCondition), setupWin81SDK() ]))
build-wrappers-windows-uwp:
runs-on: windows-latest
name: Wrappers UWP
strategy:
matrix:
arch: #@ windowsUWPArchs
_: #@ template.replace(buildWrappers("powershell ./wrappers/build.ps1 WindowsStore -Platforms ${{ matrix.arch }}", "wrappers-windows-uwp-${{ matrix.arch }}", [ setupVcpkg(wrappersCacheCondition) ]))
build-packages:
runs-on: windows-latest
name: Package
needs:
- build-wrappers-windows
- build-wrappers-macos
- build-wrappers-ios
- build-wrappers-android
- build-wrappers-linux
- build-wrappers-windows-uwp
outputs:
package_version: ${{ steps.get-version.outputs.version }}
timeout-minutes: #@ wrappersTimeout
steps:
- name: Add msbuild to PATH
uses: #@ actionSetupMSBuild
- #@ template.replace(checkoutCode())
- name: Set version suffix
id: set-version-suffix
#! Build suffix is pr-1234.5 for pr builds or alpha.123 for branch builds.
run: |
$suffix = ""
if ($env:GITHUB_EVENT_NAME -eq "pull_request")
{
if (-Not "${{ github.head_ref }}".Contains("release"))
{
$suffix = "pr-${{ github.event.number }}.$env:GITHUB_RUN_NUMBER"
}
}
else
{
$suffix = "alpha.$env:GITHUB_RUN_NUMBER"
}
echo "::set-output name=build_suffix::$suffix"
- #@ template.replace(fetchWrapperBinaries())
- #@ template.replace(buildPackages())
- #@ template.replace(readVersionFromPackage())
- #@ template.replace(buildDocs())
- #@ template.replace(uploadPackageArtifacts())
- #@ template.replace(buildUnityPackage())
- #@ uploadArtifacts("ExtractedChangelog", "Realm/Realm/ExtractedChangelog.md")
publish-packages-to-sleet:
runs-on: ubuntu-latest
name: Publish package to S3
needs:
- build-packages
if: ${{ github.event_name != 'pull_request' }}
steps:
- #@ template.replace(checkoutCode(False, False))
- #@ template.replace(fetchPackageArtifacts())
- #@ template.replace(uploadPackagesToSleet("needs.build-packages.outputs.package_version", True))
_: #@ template.replace(testJob(".NET Framework", "windows-latest", netFrameworkTestSteps()))
_: #@ template.replace(testJob("UWP Managed", "windows-latest", uwpTestSteps()))
run-tests-netcore:
runs-on: ${{ matrix.os}}
name: "Test .NET"
needs:
- build-packages
strategy:
fail-fast: false
matrix:
os: [ macos-latest, windows-latest, ubuntu-latest, win81 ]
targetFramework: [ netcoreapp3.1, net5.0, net6.0 ]
timeout-minutes: #@ testTimeout
steps:
- name: Cleanup Workspace
run: Remove-Item ${{ github.workspace }}\* -Recurse -Force
if: matrix.os == 'win81'
- #@ template.replace(checkoutCode())
- #@ template.replace(fetchPackageArtifacts())
- uses: #@ actionSetupDotnet
if: matrix.targetFramework == 'net6.0'
with:
dotnet-version: '6.0.x'
include-prerelease: true
- #@ template.replace(dotnetPublishAndRunTests("Tests/Realm.Tests", "${{ matrix.targetFramework }}", "Realm.Tests --result=TestResults.xml --labels=After"))
- #@ publishTestsResults("TestResults.xml", ".NET (${{ matrix.os }}, ${{ matrix.targetFramework }})")
_: #@ template.replace(testJob("Xamarin.macOS", "macos-latest", xamarinMacTestSteps()))
_: #@ template.replace(testJob("Xamarin.iOS", "macos-latest", xamariniOSTestSteps()))
_: #@ template.replace(testJob("Xamarin.Android", "macos-latest", xamarinAndroidTestSteps()))
run-tests-weaver:
runs-on: windows-latest
name: Test Weaver
timeout-minutes: #@ testTimeout
steps:
- #@ template.replace(checkoutCode())
- #@ template.replace(dotnetPublish("Tests/Weaver/Realm.Fody.Tests", "netcoreapp3.1"))
- name: Run Tests
run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Fody.Tests --result=TestResults.Weaver.xml --labels=After
- #@ publishTestsResults("TestResults.Weaver.xml", "Weaver")
_: #@ template.replace(testJob("Code Coverage", "ubuntu-latest", codeCoverageTestSteps(), False))
run-cleanup:
runs-on: ubuntu-latest
name: Workflow cleanup
needs:
- test-code-coverage
if: always()
timeout-minutes: #@ cleanupTimeout
steps:
#@ for platform in getWrapperBinaryNames():
- name: #@ "Delete artifacts for " + platform
uses: #@ actionDeleteArtifact
with:
name: #@ "wrappers-" + platform
#@ end
benchmark-linux:
name: Benchmark Linux
needs: build-packages
runs-on: performance-tests
if: ${{ github.event_name == 'push' }}
timeout-minutes: #@ testTimeout
steps:
- name: Cleanup Workspace
run: rm -rf ${{ github.workspace }}/*
- #@ template.replace(checkoutCode())
- #@ template.replace(fetchPackageArtifacts())
- #@ template.replace(dotnetPublishAndRunTests("Tests/Benchmarks/PerformanceTests", "net5.0", "PerformanceTests -f \"*\" --join"))
- name: Find Results file
id: find-results-file
run: |
cd BenchmarkDotNet.Artifacts/results
file=$(basename BenchmarkRun*json)
echo "::set-output name=benchmark-results::$file"
- name: Publish Benchmark Results
uses: ./.github/actions/benchmark-uploader
with:
realm-token: ${{ secrets.Realm_Token }}
file: ${{ github.workspace }}/BenchmarkDotNet.Artifacts/results/${{ steps.find-results-file.outputs.benchmark-results }}
dashboard-path: dashboard.charts
nuget-package: ${{ github.workspace }}/Realm/packages/Realm.${{ needs.build-packages.outputs.package_version }}.nupkg
- #@ uploadArtifacts("dashboard.charts", "dashboard.charts", 30)