Skip to content

Commit 863ee6a

Browse files
chore: Device/integration tests for mobile on .net10 (#4750)
1 parent cbd1f38 commit 863ee6a

File tree

14 files changed

+81
-47
lines changed

14 files changed

+81
-47
lines changed

.github/actions/environment/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ runs:
9797
global-json-file: global.json
9898
dotnet-version: |
9999
8.0.x
100-
9.0.304
100+
9.0.310
101101
102102
# .NET 5.0 does not support ARM64 on macOS
103103
- name: Install .NET 5.0 SDK

.github/workflows/device-tests-android.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
tfm: [net9.0]
20+
tfm: [net9.0, net10.0]
2121
env:
2222
DOTNET_CLI_TELEMETRY_OPTOUT: 1
2323
DOTNET_NOLOGO: 1
@@ -40,13 +40,12 @@ jobs:
4040
- name: Build Android Test App
4141
run: pwsh ./scripts/device-test.ps1 android -Build -Tfm ${{ matrix.tfm }}
4242

43-
- name: Upload Android Test App (net9.0)
44-
if: matrix.tfm == 'net9.0'
43+
- name: Upload Android Test App (${{ matrix.tfm }})
4544
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
4645
with:
47-
name: device-test-android-net9.0
46+
name: device-test-android-${{ matrix.tfm }}
4847
if-no-files-found: error
49-
path: test/Sentry.Maui.Device.TestApp/bin/Release/net9.0-android/android-x64/io.sentry.dotnet.maui.device.testapp-Signed.apk
48+
path: test/Sentry.Maui.Device.TestApp/bin/Release/${{ matrix.tfm }}-android/android-x64/io.sentry.dotnet.maui.device.testapp-Signed.apk
5049

5150
android:
5251
needs: [build]
@@ -58,7 +57,7 @@ jobs:
5857
strategy:
5958
fail-fast: false
6059
matrix:
61-
tfm: [net9.0]
60+
tfm: [net9.0, net10.0]
6261
# Must be 34+ for new apps and app updates as of August 31, 2024.
6362
# See https://apilevels.com/
6463
api-level: [34, 36]
@@ -130,7 +129,7 @@ jobs:
130129
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
131130
with:
132131
repository: getsentry/github-workflows
133-
ref: a5e409bd5bad4c295201cdcfe862b17c50b29ab7 # v2.14.1
132+
ref: 95603f4efe938315ff0dd427a1f2bb40b1889a92 # 3.2.0
134133
path: modules/github-workflows
135134

136135
- name: Run Integration Tests
@@ -147,7 +146,7 @@ jobs:
147146
disk-size: ${{ env.ANDROID_EMULATOR_DISK_SIZE }}
148147
emulator-options: ${{ env.ANDROID_EMULATOR_OPTIONS }}
149148
disable-animations: false
150-
script: pwsh integration-test/android.Tests.ps1
149+
script: pwsh integration-test/android.Tests.ps1 -dotnet_version ${{ matrix.tfm }}
151150

152151
- name: Retry Integration Tests (if previous failed to run)
153152
if: steps.first-integration-test-run.outcome == 'failure'

Sentry.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "integration-test", "integra
278278
integration-test\pester.ps1 = integration-test\pester.ps1
279279
integration-test\ios.Tests.ps1 = integration-test\ios.Tests.ps1
280280
integration-test\msbuild.Tests.ps1 = integration-test\msbuild.Tests.ps1
281+
integration-test\android.Tests.ps1 = integration-test\android.Tests.ps1
281282
EndProjectSection
282283
EndProject
283284
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net4-console", "net4-console", "{33793113-C7B5-434D-B5C1-6CA1A9587842}"

integration-test/android.Tests.ps1

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
param(
2+
[string] $dotnet_version = "net10.0"
3+
)
4+
15
# This file contains test cases for https://pester.dev/
26
Set-StrictMode -Version Latest
37
$ErrorActionPreference = 'Stop'
48
. $PSScriptRoot/pester.ps1
9+
. $PSScriptRoot/common.ps1
510
. $PSScriptRoot/../scripts/device-test-utils.ps1
611

712
BeforeDiscovery {
@@ -12,11 +17,14 @@ BeforeDiscovery {
1217
$script:emulator = Get-AndroidEmulatorId
1318
}
1419

15-
Describe 'MAUI app (<tfm>, <configuration>)' -ForEach @(
16-
@{ tfm = "net9.0-android35.0"; configuration = "Release" }
17-
@{ tfm = "net9.0-android35.0"; configuration = "Debug" }
18-
) -Skip:(-not $script:emulator) {
20+
$cases = @(
21+
@{ configuration = 'Release' }
22+
@{ configuration = 'Debug' }
23+
)
24+
Describe 'MAUI app (<dotnet_version>, <configuration>)' -ForEach $cases -Skip:(-not $script:emulator) {
1925
BeforeAll {
26+
$tfm = "$dotnet_version-android$(GetAndroidTpv $dotnet_version)"
27+
2028
Remove-Item -Path "$PSScriptRoot/mobile-app" -Recurse -Force -ErrorAction SilentlyContinue
2129
Copy-Item -Path "$PSScriptRoot/net9-maui" -Destination "$PSScriptRoot/mobile-app" -Recurse -Force
2230
Push-Location $PSScriptRoot/mobile-app
@@ -126,9 +134,9 @@ Describe 'MAUI app (<tfm>, <configuration>)' -ForEach @(
126134

127135
Dump-ServerErrors -Result $result
128136
$result.HasErrors() | Should -BeFalse
129-
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.ApplicationException`""
130-
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGABRT`""
131-
$result.Envelopes() | Should -HaveCount 1
137+
$result.Events() | Should -AnyElementMatch "`"type`":`"System.ApplicationException`""
138+
$result.Events() | Should -Not -AnyElementMatch "`"type`":`"SIGABRT`""
139+
$result.Events() | Should -HaveCount 1
132140
}
133141

134142
It 'Java crash (<configuration>)' {
@@ -140,9 +148,9 @@ Describe 'MAUI app (<tfm>, <configuration>)' -ForEach @(
140148

141149
Dump-ServerErrors -Result $result
142150
$result.HasErrors() | Should -BeFalse
143-
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"RuntimeException`""
144-
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"System.\w+Exception`""
145-
$result.Envelopes() | Should -HaveCount 1
151+
$result.Events() | Should -AnyElementMatch "`"type`":`"RuntimeException`""
152+
$result.Events() | Should -Not -AnyElementMatch "`"type`":`"System.\w+Exception`""
153+
$result.Events() | Should -HaveCount 1
146154
}
147155

148156
It 'Native crash (<configuration>)' {
@@ -154,9 +162,9 @@ Describe 'MAUI app (<tfm>, <configuration>)' -ForEach @(
154162

155163
Dump-ServerErrors -Result $result
156164
$result.HasErrors() | Should -BeFalse
157-
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"SIG[A-Z]+`"" # SIGILL (x86_64), SIGTRAP (arm64-v8a)
158-
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"System.\w+Exception`""
159-
$result.Envelopes() | Should -HaveCount 1
165+
$result.Events() | Should -AnyElementMatch "`"type`":`"SIG[A-Z]+`"" # SIGILL (x86_64), SIGTRAP (arm64-v8a)
166+
$result.Events() | Should -Not -AnyElementMatch "`"type`":`"System.\w+Exception`""
167+
$result.Events() | Should -HaveCount 1
160168
}
161169

162170
It 'Null reference exception (<configuration>)' {
@@ -168,13 +176,13 @@ Describe 'MAUI app (<tfm>, <configuration>)' -ForEach @(
168176

169177
Dump-ServerErrors -Result $result
170178
$result.HasErrors() | Should -BeFalse
171-
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.NullReferenceException`""
179+
$result.Events() | Should -AnyElementMatch "`"type`":`"System.NullReferenceException`""
172180
# TODO: fix redundant SIGSEGV in Release (#3954)
173181
if ($configuration -eq "Release") {
174-
{ $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`"" } | Should -Throw
182+
{ $result.Events() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`"" } | Should -Throw
175183
} else {
176-
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`""
177-
$result.Envelopes() | Should -HaveCount 1
184+
$result.Events() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`""
185+
$result.Events() | Should -HaveCount 1
178186
}
179187
}
180188

@@ -186,8 +194,8 @@ Describe 'MAUI app (<tfm>, <configuration>)' -ForEach @(
186194

187195
Dump-ServerErrors -Result $result
188196
$result.HasErrors() | Should -BeFalse
189-
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"system`",`"thread_id`":`"1`",`"category`":`"device.event`",`"action`":`"BATTERY_CHANGED`""
190-
$result.Envelopes() | Should -HaveCount 1
197+
$result.Events() | Should -AnyElementMatch "`"type`":`"system`",`"thread_id`":`"1`",`"category`":`"device.event`",`"action`":`"BATTERY_CHANGED`""
198+
$result.Events() | Should -HaveCount 1
191199
}
192200

193201
It 'Delivers network breadcrumbs in main thread (<configuration>)' {
@@ -198,7 +206,7 @@ Describe 'MAUI app (<tfm>, <configuration>)' -ForEach @(
198206

199207
Dump-ServerErrors -Result $result
200208
$result.HasErrors() | Should -BeFalse
201-
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"system`",`"thread_id`":`"1`",`"category`":`"network.event`",`"action`":`"NETWORK_CAPABILITIES_CHANGED`""
202-
$result.Envelopes() | Should -HaveCount 1
209+
$result.Events() | Should -AnyElementMatch "`"type`":`"system`",`"thread_id`":`"1`",`"category`":`"network.event`",`"action`":`"NETWORK_CAPABILITIES_CHANGED`""
210+
$result.Events() | Should -HaveCount 1
203211
}
204212
}

integration-test/cli.Tests.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Describe 'Console apps (<framework>) - normal build' -ForEach @(
77
foreach ($fw in $currentFrameworks) { @{ framework = $fw } }
88
) {
99
BeforeAll {
10+
ResetLocalPackages
1011
DotnetNew 'console' 'console-app' $framework
1112
}
1213

@@ -43,6 +44,7 @@ Describe 'Console apps (<framework>) - native AOT publish' -ForEach @(
4344
foreach ($fw in $currentFrameworks) { @{ framework = $fw } }
4445
) {
4546
BeforeAll {
47+
ResetLocalPackages
4648
DotnetNew 'console' 'console-app' $framework
4749
}
4850

@@ -105,6 +107,7 @@ Describe 'MAUI (<framework>)' -ForEach @(
105107
@{ framework = $previousFramework }
106108
) -Skip:($env:NO_MOBILE -eq "true") {
107109
BeforeAll {
110+
ResetLocalPackages
108111
RegisterLocalPackage 'Sentry.Android.AssemblyReader'
109112
RegisterLocalPackage 'Sentry.Bindings.Android'
110113
RegisterLocalPackage 'Sentry.Extensions.Logging'

integration-test/common.ps1

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,12 @@ BeforeAll {
108108
Remove-Item -Path ~/.nuget/packages/$($name.ToLower())/$packageVersion -Recurse -Force -ErrorAction SilentlyContinue
109109
}
110110

111-
Remove-Item -Path "$PSScriptRoot/packages" -Recurse -Force -ErrorAction SilentlyContinue
112-
New-Item -ItemType Directory -Path "$PSScriptRoot/packages" | Out-Null
113-
RegisterLocalPackage 'Sentry'
111+
function ResetLocalPackages()
112+
{
113+
Remove-Item -Path "$PSScriptRoot/packages" -Recurse -Force -ErrorAction SilentlyContinue
114+
New-Item -ItemType Directory -Path "$PSScriptRoot/packages" | Out-Null
115+
RegisterLocalPackage 'Sentry'
116+
}
114117

115118
function RunDotnetWithSentryCLI([string] $action, [string]$project, [bool]$Symbols, [bool]$Sources, [string]$TargetFramework)
116119
{

integration-test/ios.Tests.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ BeforeDiscovery {
1212
}
1313

1414
Describe 'iOS app (<tfm>, <configuration>)' -ForEach @(
15-
@{ tfm = "net9.0-ios18.0"; configuration = "Release" }
16-
@{ tfm = "net9.0-ios18.0"; configuration = "Debug" }
15+
# Note: we can't run against net10 and net9 becaus .NET 10 requires Xcode 26.2 and .NET 9 requires Xcode 26.0.
16+
# The macOS GitHub Actions runners only have Xcode 26.1+ installed and no support for Xcode 26.2 is planned for
17+
# net9.0-ios: https://github.com/dotnet/macios/issues/24199#issuecomment-3819021247
18+
@{ tfm = "net10.0-ios26.2"; configuration = "Release" }
19+
@{ tfm = "net10.0-ios26.2"; configuration = "Debug" }
1720
) -Skip:(-not $script:simulator) {
1821
BeforeAll {
1922
. $PSScriptRoot/../scripts/device-test-utils.ps1

integration-test/msbuild.Tests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ $IsARM64 = "Arm64".Equals([System.Runtime.InteropServices.RuntimeInformation]::O
88
# NOTE: These .NET versions are used to build a test app that consumes the Sentry
99
# .NET SDK, and are not tied to the .NET version used to build the SDK itself.
1010
Describe 'MSBuild app' {
11+
BeforeAll {
12+
ResetLocalPackages
13+
}
14+
1115
BeforeDiscovery {
1216
$frameworks = @()
1317

integration-test/net9-maui/Sentry.Maui.Device.IntegrationTestApp.csproj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>$(TargetFrameworks);net9.0-android35.0</TargetFrameworks>
5-
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net9.0-ios18.0</TargetFrameworks>
4+
<TargetFrameworks>$(TargetFrameworks);net9.0-android35.0;net10.0-android36.0</TargetFrameworks>
5+
<!-- Pin target iOS version so that our tests don't break when new versions of Xcode are released.
6+
'netX.0-ios' resolves the latest version of the iOS SDK otherwise.
7+
-->
8+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net10.0-ios26.2</TargetFrameworks>
69

710
<OutputType>Exe</OutputType>
811
<RootNamespace>Sentry.Maui.Device.IntegrationTestApp</RootNamespace>
@@ -31,7 +34,7 @@
3134

3235
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
3336
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
34-
<TargetPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">18.0</TargetPlatformVersion>
37+
3538
</PropertyGroup>
3639

3740
<ItemGroup>

integration-test/runtime.Tests.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Describe 'Console app NativeAOT (<framework>)' -ForEach @(
77
foreach ($fw in $currentFrameworks) { @{ framework = $fw } }
88
) {
99
BeforeAll {
10+
ResetLocalPackages
1011
$path = './console-app'
1112
DotnetNew 'console' $path $framework
1213
@'
@@ -184,6 +185,10 @@ internal class FakeTransport : ITransport
184185

185186
# This ensures we don't have a regression for https://github.com/getsentry/sentry-dotnet/issues/2825
186187
Describe 'Console app regression (missing System.Reflection.Metadata)' {
188+
BeforeAll {
189+
ResetLocalPackages
190+
}
191+
187192
AfterAll {
188193
dotnet remove ./net4-console/console-app.csproj package Sentry
189194
}

0 commit comments

Comments
 (0)