Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/test-build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/test-build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/test-build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/test-build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/test-build-windows-mono.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/test-build-windows-x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/test-build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions test/Scripts.Integration.Test/Editor/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}'.");

Expand Down Expand Up @@ -273,6 +274,23 @@ private static void ValidateArguments(Dictionary<string, string> 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<string, string> 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
AssetDatabase.SaveAssets();
}

// Audio created issues, especially for iOS simulator so we disable it.
private static void DisableUnityAudio()
{
Expand Down
27 changes: 27 additions & 0 deletions test/Scripts.Integration.Test/Editor/CommandLineArguments.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;

public static class CommandLineArguments
{
public static Dictionary<string, string> Parse()
{
var commandLineArguments = new Dictionary<string, string>();
var args = Environment.GetCommandLineArgs();

for (int current = 0, next = 1; current < args.Length; current++, next++)
{
if (!args[current].StartsWith("-"))
{
continue;
}

var flag = args[current].TrimStart('-');
var flagHasValue = next < args.Length && !args[next].StartsWith("-");
var flagValue = flagHasValue ? args[next].TrimStart('-') : "";

commandLineArguments.Add(flag, flagValue);
}

return commandLineArguments;
}
}
130 changes: 0 additions & 130 deletions test/Scripts.Integration.Test/Editor/SentrySetup.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
23 changes: 9 additions & 14 deletions test/Scripts.Integration.Test/add-sentry.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,15 @@ 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 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
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
Expand Down
Loading
Loading