From 4be022af267d9596551912cfbf2e041fdb18db6b Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Sun, 25 Oct 2026 13:17:02 +0100 Subject: [PATCH 1/3] Add Sentry to the integration test manifest without launching Unity --- .../Editor/SentrySetup.cs | 103 ------------------ test/Scripts.Integration.Test/add-sentry.ps1 | 22 ++-- 2 files changed, 13 insertions(+), 112 deletions(-) diff --git a/test/Scripts.Integration.Test/Editor/SentrySetup.cs b/test/Scripts.Integration.Test/Editor/SentrySetup.cs index fc0294227..cdfe6a3da 100644 --- a/test/Scripts.Integration.Test/Editor/SentrySetup.cs +++ b/test/Scripts.Integration.Test/Editor/SentrySetup.cs @@ -1,11 +1,4 @@ -using UnityEditor; -using UnityEditor.PackageManager.Requests; -using UnityEditor.PackageManager; -using UnityEngine; using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using System.Collections.Generic; public static class CommandLineArguments @@ -32,99 +25,3 @@ public static Dictionary Parse() return commandLineArguments; } } -public class SentrySetup -{ - enum SentryInstallOrigin - { - None, - Disk - }; - - static void LogDebug(string message) - => Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "Sentry Package Installation: {0}", message); - - static void LogError(string message) - => Debug.LogFormat(LogType.Error, LogOption.NoStacktrace, null, "Sentry Package Installation: {0}", message); - - [InitializeOnLoadMethod] - static void InstallSentry() - { - var installOrigin = GetInstallOriginFromEnvironment(CommandLineArguments.Parse()); - - if (installOrigin == SentryInstallOrigin.None) - { - LogDebug("Sentry not requested to be installed."); - } - else - { - LogDebug("Checking if Sentry is installed"); - - var listRequest = Client.List(); - while (!listRequest.IsCompleted) - { - Thread.Sleep(1000); - } - if (listRequest.Status >= StatusCode.Failure) - { - LogError(listRequest.Error.message); - EditorApplication.Exit(-1); - } - else if (listRequest.Result.Any(p => p.name == "io.sentry.unity") == false) - { - LogDebug("Project does not contain Sentry."); - } - else - { - LogDebug("Project contains Sentry."); - } - - var args = CommandLineArguments.Parse(); - LogDebug($"Installing Sentry from {installOrigin}"); - var installCommand = GetInstallCommand(installOrigin, args); - var addRequest = Client.Add(installCommand); - while (!addRequest.IsCompleted) - { - Thread.Sleep(1000); - } - if (addRequest.Status == StatusCode.Success) - { - LogDebug("SUCCESS"); - EditorApplication.Exit(0); - } - else - { - LogError("FAILED"); - LogError(addRequest.Error?.message); - EditorApplication.Exit(-1); - } - } - } - - static string GetInstallCommand(SentryInstallOrigin origin, Dictionary args) - { - if (origin == SentryInstallOrigin.Disk) - { - if (!args.ContainsKey("sentryPackagePath")) - { - var errorMessage = "Disk install requires -sentryPackagePath argument"; - LogError(errorMessage); - EditorApplication.Exit(-1); - throw new ArgumentException(errorMessage); - } - var sentryPackageLocal = $"file:{args["sentryPackagePath"]}"; - LogDebug("Sentry package Path is " + sentryPackageLocal); - return sentryPackageLocal; - } - var errorMessage2 = $"Install command {origin} not supported"; - LogError(errorMessage2); - EditorApplication.Exit(-1); - throw new NotImplementedException(errorMessage2); - } - - static SentryInstallOrigin GetInstallOriginFromEnvironment(Dictionary args) - { - return args.ContainsKey("installSentry") - ? (SentryInstallOrigin)Enum.Parse(typeof(SentryInstallOrigin), args["installSentry"]) - : SentryInstallOrigin.None; - } -} diff --git a/test/Scripts.Integration.Test/add-sentry.ps1 b/test/Scripts.Integration.Test/add-sentry.ps1 index 926ba9ac0..8e628dcad 100644 --- a/test/Scripts.Integration.Test/add-sentry.ps1 +++ b/test/Scripts.Integration.Test/add-sentry.ps1 @@ -10,20 +10,24 @@ if (-not $Global:NewProjectPathCache) . $PSScriptRoot/common.ps1 -$UnityPath = FormatUnityPath $UnityPath - -# Convert relative paths to absolute (relative to ProjectRoot) -# This ensures the path works both locally and in Docker (where RunUnityCustom handles path translation) if (-not [System.IO.Path]::IsPathRooted($PackagePath)) { $PackagePath = "$(ProjectRoot)/$PackagePath" } -Write-Log "Installing Sentry package..." -RunUnityAndExpect $UnityPath "AddSentryPackage" "Sentry Package Installation: SUCCESS" @( ` - "-batchmode", "-projectPath", "$(GetNewProjectPath)", ` - "-installSentry", "Disk", ` - "-sentryPackagePath", $PackagePath) +# The path has to resolve for the editor, which in Docker sees the project root at /sentry-unity +If ($UnityPath.StartsWith("docker ")) +{ + $PackagePath = $PackagePath.Replace("$(ProjectRoot)", "/sentry-unity") +} + +# The next editor launch resolves and imports the package +Write-Log "Adding Sentry package to the project manifest..." +$manifestPath = "$(GetNewProjectPath)/Packages/manifest.json" +$manifest = Get-Content $manifestPath -Raw | ConvertFrom-Json +$manifest.dependencies | Add-Member -NotePropertyName "io.sentry.unity" -NotePropertyValue "file:$PackagePath" -Force +$manifest | ConvertTo-Json -Depth 10 | Set-Content $manifestPath +Write-Detail "io.sentry.unity: $($manifest.dependencies.'io.sentry.unity')" Write-Log "Copying Integration Test Files..." New-Item -Path "$(GetNewProjectAssetsPath)" -Name "Scripts" -ItemType "directory" | Out-Null From ea150485941b03a1a9496877a43a179231f8bbc7 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Sun, 25 Oct 2026 13:17:02 +0100 Subject: [PATCH 2/3] Configure Sentry options in the first integration test build --- .github/workflows/ci.yml | 9 +---- .github/workflows/test-build-android.yml | 7 +--- .github/workflows/test-build-ios.yml | 9 +---- .github/workflows/test-build-linux.yml | 7 +--- .github/workflows/test-build-macos.yml | 8 +--- .github/workflows/test-build-windows-mono.yml | 8 +--- .github/workflows/test-build-windows-x86.yml | 8 +--- .github/workflows/test-build-windows.yml | 8 +--- .../Editor/Builder.cs | 22 +++++++++++ .../IntegrationOptionsConfiguration.cs | 2 +- .../build-project.ps1 | 27 ++++++++++++- .../configure-sentry.ps1 | 39 ------------------- .../integration-test.ps1 | 10 ++--- 13 files changed, 69 insertions(+), 95 deletions(-) delete mode 100644 test/Scripts.Integration.Test/configure-sentry.ps1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffe88fe82..7a56cf6cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -242,17 +242,12 @@ jobs: if: ${{ startsWith(matrix.unity-version, '2021') }} run: ./test/Scripts.Integration.Test/add-dependency-conflict.ps1 -Disable - - name: Configure Sentry - run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" - env: - BUILD_PLATFORM: ${{ matrix.build_platform }} - SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} - - name: Build Project - run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" -UnityVersion "$env:UNITY_VERSION" + run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" -UnityVersion "$env:UNITY_VERSION" -ConfigureSentry env: BUILD_PLATFORM: ${{ matrix.build_platform }} UNITY_VERSION: ${{ matrix.unity-version }} + SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} - name: Compare build sizes run: ./test/Scripts.Integration.Test/measure-build-size.ps1 -Path1 "samples/IntegrationTest/Build-NoSentry" -Path2 "samples/IntegrationTest/Build" -Platform "$env:BUILD_PLATFORM" -UnityVersion "$env:UNITY_VERSION" diff --git a/.github/workflows/test-build-android.yml b/.github/workflows/test-build-android.yml index e9bdada9e..8a1bd24f6 100644 --- a/.github/workflows/test-build-android.yml +++ b/.github/workflows/test-build-android.yml @@ -100,14 +100,11 @@ jobs: - name: Add DependencyConflict to the project run: ./test/Scripts.Integration.Test/add-dependency-conflict.ps1 -PackagePath "dependency-conflict-package" - - name: Configure Sentry - run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform "Android" + - name: Export APK - Runtime Initialization + run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "Android" -UnityVersion "$env:UNITY_VERSION" -ConfigureSentry env: SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} - - name: Export APK - Runtime Initialization - run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "Android" -UnityVersion "$env:UNITY_VERSION" - - name: Assert symbols and sources were uploaded (Runtime) run: ./test/Scripts.Integration.Test/assert-symbol-upload.ps1 -LogPath samples/IntegrationTest/Logs/sentry-symbols-upload.log diff --git a/.github/workflows/test-build-ios.yml b/.github/workflows/test-build-ios.yml index 4fcc7b886..7e8b0896e 100644 --- a/.github/workflows/test-build-ios.yml +++ b/.github/workflows/test-build-ios.yml @@ -119,16 +119,11 @@ jobs: - name: Add DependencyConflict to the project run: ./test/Scripts.Integration.Test/add-dependency-conflict.ps1 -PackagePath "dependency-conflict-package" - - name: Configure Sentry - run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" - env: - BUILD_PLATFORM: ${{ matrix.build_platform }} - SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} - - name: Build Project with runtime initialization - run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" -UnityVersion "$env:UNITY_VERSION" + run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" -UnityVersion "$env:UNITY_VERSION" -ConfigureSentry env: BUILD_PLATFORM: ${{ matrix.build_platform }} + SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} # We create tar explicitly because upload-artifact is slow for many files. - name: Create archive (runtime initialization) diff --git a/.github/workflows/test-build-linux.yml b/.github/workflows/test-build-linux.yml index 375642a54..4b2ec5269 100644 --- a/.github/workflows/test-build-linux.yml +++ b/.github/workflows/test-build-linux.yml @@ -112,14 +112,11 @@ jobs: - name: Add DependencyConflict to the project run: ./test/Scripts.Integration.Test/add-dependency-conflict.ps1 -PackagePath "dependency-conflict-package" - - name: Configure Sentry - run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform Linux + - name: Build with Sentry SDK (Breakpad backend) + run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform Linux -UnityVersion "$env:UNITY_VERSION" -ConfigureSentry env: SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} - - name: Build with Sentry SDK (Breakpad backend) - run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform Linux -UnityVersion "$env:UNITY_VERSION" - - name: Assert symbols and sources were uploaded (Breakpad backend) run: ./test/Scripts.Integration.Test/assert-symbol-upload.ps1 -LogPath unity.log diff --git a/.github/workflows/test-build-macos.yml b/.github/workflows/test-build-macos.yml index bdb61a6d3..c51195da9 100644 --- a/.github/workflows/test-build-macos.yml +++ b/.github/workflows/test-build-macos.yml @@ -91,15 +91,11 @@ jobs: - name: Add DependencyConflict to the project run: ./test/Scripts.Integration.Test/add-dependency-conflict.ps1 -PackagePath "dependency-conflict-package" - - name: Configure Sentry - run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform MacOS - env: - SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} - - name: Build with Sentry SDK (Cocoa backend) - run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform MacOS -UnityVersion "$env:UNITY_VERSION" + run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform MacOS -UnityVersion "$env:UNITY_VERSION" -ConfigureSentry env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} - name: Assert symbols and sources were uploaded (Cocoa backend) run: ./test/Scripts.Integration.Test/assert-symbol-upload.ps1 -LogPath unity.log diff --git a/.github/workflows/test-build-windows-mono.yml b/.github/workflows/test-build-windows-mono.yml index dd7bdb763..dd446274d 100644 --- a/.github/workflows/test-build-windows-mono.yml +++ b/.github/workflows/test-build-windows-mono.yml @@ -67,19 +67,15 @@ jobs: - name: Disable DependencyConflict run: ./test/Scripts.Integration.Test/add-dependency-conflict.ps1 -Disable - - name: Configure Sentry - run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform Windows - env: - SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} - # Crashpad backend only. The point of this job is that a Mono player resolves the # P/Invokes to `sentry-native` instead of the managed `Sentry.dll` at all; both Windows # backends bind against the same library, and the IL2CPP matrix already covers the # backend spread. Crashpad is what players ship with by default. - name: Build with Sentry SDK - run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform Windows-Mono -UnityVersion "$env:UNITY_VERSION" + run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform Windows-Mono -UnityVersion "$env:UNITY_VERSION" -ConfigureSentry env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} - name: Assert symbols and sources were uploaded run: ./test/Scripts.Integration.Test/assert-symbol-upload.ps1 -LogPath unity.log diff --git a/.github/workflows/test-build-windows-x86.yml b/.github/workflows/test-build-windows-x86.yml index fe59f7125..e63d0daac 100644 --- a/.github/workflows/test-build-windows-x86.yml +++ b/.github/workflows/test-build-windows-x86.yml @@ -73,11 +73,6 @@ jobs: - name: Add DependencyConflict to the project run: ./test/Scripts.Integration.Test/add-dependency-conflict.ps1 -PackagePath "dependency-conflict-package" - - name: Configure Sentry - run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform Windows - env: - SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} - # Native backend only. The point of this job is that a 32-bit player loads a 32-bit # sentry-native at all; covering both backends here would double Unity licence usage # for no extra signal. The x64 matrix still covers crashpad. @@ -89,9 +84,10 @@ jobs: Set-Content $optionsPath $content - name: Build with Sentry SDK - run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform Windows-x86 -UnityVersion "$env:UNITY_VERSION" + run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform Windows-x86 -UnityVersion "$env:UNITY_VERSION" -ConfigureSentry env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} - name: Assert symbols and sources were uploaded run: ./test/Scripts.Integration.Test/assert-symbol-upload.ps1 -LogPath unity.log diff --git a/.github/workflows/test-build-windows.yml b/.github/workflows/test-build-windows.yml index ccaea085e..a773d233a 100644 --- a/.github/workflows/test-build-windows.yml +++ b/.github/workflows/test-build-windows.yml @@ -91,15 +91,11 @@ jobs: - name: Add DependencyConflict to the project run: ./test/Scripts.Integration.Test/add-dependency-conflict.ps1 -PackagePath "dependency-conflict-package" - - name: Configure Sentry - run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform Windows - env: - SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} - - name: Build with Sentry SDK (Crashpad backend) - run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform Windows -UnityVersion "$env:UNITY_VERSION" + run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform Windows -UnityVersion "$env:UNITY_VERSION" -ConfigureSentry env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} - name: Assert symbols and sources were uploaded (Crashpad backend) run: ./test/Scripts.Integration.Test/assert-symbol-upload.ps1 -LogPath unity.log diff --git a/test/Scripts.Integration.Test/Editor/Builder.cs b/test/Scripts.Integration.Test/Editor/Builder.cs index 410709fbc..c1a51dcc9 100644 --- a/test/Scripts.Integration.Test/Editor/Builder.cs +++ b/test/Scripts.Integration.Test/Editor/Builder.cs @@ -16,6 +16,7 @@ public static void BuildIl2CPPPlayer(BuildTarget target, BuildTargetGroup group, Debug.Log("Builder: Parsing command line arguments"); var args = CommandLineArguments.Parse(); ValidateArguments(args, defaultBuildPath); + ConfigureSentryOptions(args); Debug.Log($"Builder: Starting build. Output will be '{args["buildPath"]}'."); @@ -273,6 +274,27 @@ private static void ValidateArguments(Dictionary args, string de } } + // Same as `-executeMethod ...SentryEditorWindowInstrumentation.ConfigureOptions`. Called by reflection because + // the project is also built without the Sentry package. + private static void ConfigureSentryOptions(Dictionary args) + { + if (!args.ContainsKey("optionsScript")) + { + return; + } + + Debug.Log("Builder: Configuring Sentry options"); + var instrumentation = Type.GetType("Sentry.Unity.Editor.ConfigurationWindow.SentryEditorWindowInstrumentation, Sentry.Unity.Editor", throwOnError: true); + instrumentation.GetMethod("ConfigureOptions", Type.EmptyTypes).Invoke(null, null); + + // Persist the options for later builds of this project + foreach (var path in new[] { "Assets/Resources/Sentry/SentryOptions.asset", "Assets/Plugins/Sentry/SentryCliOptions.asset" }) + { + EditorUtility.SetDirty(AssetDatabase.LoadMainAssetAtPath(path)); + } + AssetDatabase.SaveAssets(); + } + // Audio created issues, especially for iOS simulator so we disable it. private static void DisableUnityAudio() { diff --git a/test/Scripts.Integration.Test/Scripts/IntegrationOptionsConfiguration.cs b/test/Scripts.Integration.Test/Scripts/IntegrationOptionsConfiguration.cs index e96f77b6f..87445174c 100644 --- a/test/Scripts.Integration.Test/Scripts/IntegrationOptionsConfiguration.cs +++ b/test/Scripts.Integration.Test/Scripts/IntegrationOptionsConfiguration.cs @@ -12,7 +12,7 @@ public override void Configure(SentryUnityOptions options) { Debug.Log("Sentry: IntegrationOptionsConfig::Configure() called"); - // DSN is baked into SentryOptions.asset at build time by configure-sentry.ps1 + // DSN is baked into SentryOptions.asset at build time by build-project.ps1 -ConfigureSentry // which passes the SENTRY_DSN env var to ConfigureOptions via the -dsn argument. // At test-run time, Integration.Tests.ps1 also reads SENTRY_DSN to verify events. diff --git a/test/Scripts.Integration.Test/build-project.ps1 b/test/Scripts.Integration.Test/build-project.ps1 index 01a0e5902..d9c4ef5df 100644 --- a/test/Scripts.Integration.Test/build-project.ps1 +++ b/test/Scripts.Integration.Test/build-project.ps1 @@ -2,7 +2,8 @@ param( [string] $UnityPath, [string] $Platform = "", [string] $UnityVersion = "", - [string] $BuildDirName = "Build" + [string] $BuildDirName = "Build", + [switch] $ConfigureSentry ) if (-not $Global:NewProjectPathCache) @@ -26,7 +27,29 @@ if ($Platform -eq "Switch") $unityArgs += @("-buildTarget", "Switch") } -RunUnityCustom $unityPath $unityArgs +if ($ConfigureSentry) +{ + Write-Log "Configuring Sentry options..." + $unityArgs += @("-optionsScript", "IntegrationOptionsConfiguration", "-cliOptionsScript", "CliConfiguration") + if ($env:SENTRY_DSN) + { + $unityArgs += @("-dsn", $env:SENTRY_DSN) + } + + RunUnityAndExpect $unityPath "ConfigureSentryOptions" "ConfigureOptions: SUCCESS" $unityArgs + + foreach ($path in @("$(GetNewProjectAssetsPath)/Plugins/Sentry/SentryCliOptions.asset", "$(GetNewProjectAssetsPath)/Resources/Sentry/SentryOptions.asset")) + { + if (!(Test-Path $path)) + { + Write-Error "Path is expected to exist but it doesn't: '$path'" + } + } +} +else +{ + RunUnityCustom $unityPath $unityArgs +} if ($Platform -eq "Android-Export") { diff --git a/test/Scripts.Integration.Test/configure-sentry.ps1 b/test/Scripts.Integration.Test/configure-sentry.ps1 deleted file mode 100644 index 21c04aa26..000000000 --- a/test/Scripts.Integration.Test/configure-sentry.ps1 +++ /dev/null @@ -1,39 +0,0 @@ -param( - [string] $UnityPath, - [string] $Platform = "" -) - -if (-not $Global:NewProjectPathCache) -{ - . $PSScriptRoot/globals.ps1 -} - -. $PSScriptRoot/common.ps1 - -$UnityPath = FormatUnityPath $UnityPath - -Write-Log "Configuring Sentry options..." - -$unityArgs = @( ` - "-quit", "-batchmode", "-nographics", "-disable-assembly-updater", "-projectPath ", $(GetNewProjectPath), ` - "-executeMethod", "Sentry.Unity.Editor.ConfigurationWindow.SentryEditorWindowInstrumentation.ConfigureOptions", ` - "-optionsScript", "IntegrationOptionsConfiguration", ` - "-cliOptionsScript", "CliConfiguration" ) - -if ($env:SENTRY_DSN) { - $unityArgs += @("-dsn", $env:SENTRY_DSN) -} - -RunUnityAndExpect $UnityPath "ConfigureSentryOptions" "ConfigureOptions: SUCCESS" $unityArgs - - -function AssertPathExists([string] $Path) -{ - if (!(Test-Path $Path)) - { - Write-Error "Path is expected to exist but it doesn't: '$Path'" - } -} - -AssertPathExists "$(GetNewProjectAssetsPath)/Plugins/Sentry/SentryCliOptions.asset" -AssertPathExists "$(GetNewProjectAssetsPath)/Resources/Sentry/SentryOptions.asset" diff --git a/test/Scripts.Integration.Test/integration-test.ps1 b/test/Scripts.Integration.Test/integration-test.ps1 index 2c9a6527f..926d555a1 100644 --- a/test/Scripts.Integration.Test/integration-test.ps1 +++ b/test/Scripts.Integration.Test/integration-test.ps1 @@ -34,6 +34,7 @@ if ($Recreate -and (Test-Path -Path $(GetNewProjectPath))) { Remove-Item -Path $(GetNewProjectPath) -Recurse -Force -Confirm:$false } +$configureSentry = $false If (-not(Test-Path -Path "$(GetNewProjectPath)")) { Write-PhaseHeader "Creating Project" Write-Log "Project path: $(GetNewProjectPath)" @@ -62,9 +63,8 @@ If (-not(Test-Path -Path "$(GetNewProjectPath)")) { Write-PhaseSuccess "DependencyConflict added" } - Write-PhaseHeader "Configuring Sentry" - ./test/Scripts.Integration.Test/configure-sentry.ps1 "$UnityPath" -Platform $Platform - Write-PhaseSuccess "Sentry configured" + # Sentry options get configured by the first build + $configureSentry = $true } # Copying the native SDK over to the expected directory. @@ -86,11 +86,11 @@ If ($Rebuild -or -not(Test-Path -Path $(GetNewProjectBuildPath))) { If ("iOS" -eq $Platform) { # We're exporting an Xcode project and building that in a separate step. - ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$UnityPath" -UnityVersion $UnityVersion -Platform $Platform + ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$UnityPath" -UnityVersion $UnityVersion -Platform $Platform -ConfigureSentry:$configureSentry & (Join-Path $PSScriptRoot "../../scripts/compile-xcode-project.ps1") } Else { - ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$UnityPath" -UnityVersion $UnityVersion -Platform $Platform + ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$UnityPath" -UnityVersion $UnityVersion -Platform $Platform -ConfigureSentry:$configureSentry } Write-PhaseSuccess "Project built" } From 5934f1ad5270a32b5235c0e298a1953d5368428b Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Sun, 25 Oct 2026 13:25:16 +0100 Subject: [PATCH 3/3] Reference the Sentry package relative to Packages and drop the duplicate options save --- test/Scripts.Integration.Test/Editor/Builder.cs | 4 ---- .../{SentrySetup.cs => CommandLineArguments.cs} | 0 test/Scripts.Integration.Test/add-sentry.ps1 | 13 ++----------- 3 files changed, 2 insertions(+), 15 deletions(-) rename test/Scripts.Integration.Test/Editor/{SentrySetup.cs => CommandLineArguments.cs} (100%) diff --git a/test/Scripts.Integration.Test/Editor/Builder.cs b/test/Scripts.Integration.Test/Editor/Builder.cs index c1a51dcc9..7ab311e9d 100644 --- a/test/Scripts.Integration.Test/Editor/Builder.cs +++ b/test/Scripts.Integration.Test/Editor/Builder.cs @@ -288,10 +288,6 @@ private static void ConfigureSentryOptions(Dictionary args) instrumentation.GetMethod("ConfigureOptions", Type.EmptyTypes).Invoke(null, null); // Persist the options for later builds of this project - foreach (var path in new[] { "Assets/Resources/Sentry/SentryOptions.asset", "Assets/Plugins/Sentry/SentryCliOptions.asset" }) - { - EditorUtility.SetDirty(AssetDatabase.LoadMainAssetAtPath(path)); - } AssetDatabase.SaveAssets(); } diff --git a/test/Scripts.Integration.Test/Editor/SentrySetup.cs b/test/Scripts.Integration.Test/Editor/CommandLineArguments.cs similarity index 100% rename from test/Scripts.Integration.Test/Editor/SentrySetup.cs rename to test/Scripts.Integration.Test/Editor/CommandLineArguments.cs diff --git a/test/Scripts.Integration.Test/add-sentry.ps1 b/test/Scripts.Integration.Test/add-sentry.ps1 index 8e628dcad..e7843a250 100644 --- a/test/Scripts.Integration.Test/add-sentry.ps1 +++ b/test/Scripts.Integration.Test/add-sentry.ps1 @@ -10,20 +10,11 @@ if (-not $Global:NewProjectPathCache) . $PSScriptRoot/common.ps1 -if (-not [System.IO.Path]::IsPathRooted($PackagePath)) -{ - $PackagePath = "$(ProjectRoot)/$PackagePath" -} - -# The path has to resolve for the editor, which in Docker sees the project root at /sentry-unity -If ($UnityPath.StartsWith("docker ")) -{ - $PackagePath = $PackagePath.Replace("$(ProjectRoot)", "/sentry-unity") -} - # The next editor launch resolves and imports the package Write-Log "Adding Sentry package to the project manifest..." $manifestPath = "$(GetNewProjectPath)/Packages/manifest.json" +# Relative to Packages/, so the path resolves on the host and in Docker alike +$PackagePath = [System.IO.Path]::GetRelativePath("$(GetNewProjectPath)/Packages", [System.IO.Path]::GetFullPath($PackagePath, "$(ProjectRoot)")).Replace("\", "/") $manifest = Get-Content $manifestPath -Raw | ConvertFrom-Json $manifest.dependencies | Add-Member -NotePropertyName "io.sentry.unity" -NotePropertyValue "file:$PackagePath" -Force $manifest | ConvertTo-Json -Depth 10 | Set-Content $manifestPath