Skip to content

Commit

Permalink
fix: Removed SmokeTester from package (#798)
Browse files Browse the repository at this point in the history
* removed 'integration' from script names

* modified scripts to work with only one smoketester

* fixed iOS special casing

* fixed clause

* removed SmokeTester from snapshot

* Update test/Scripts.Integration.Test/common.ps1

Co-authored-by: Ivan Dlugos <6349682+vaind@users.noreply.github.com>

* fixed integration-test

* made integration-test work. build-project now works without sentry

* SmokeTestOptions cleanup

* removed .meta files

* added smoke test scene

* added -CheckSymbols to update-sentry.ps1

* removed 'integration-' from copy pasta

* copying .meta for native plugins

* added log to GetMessage

* removed log again

* fallback to copying everything from the samples

* fixed broken logs and added smoketest.unity

* tweaked ios smoke test logs

* revert xcrun

* ios smoke test log output

* enable sentry logging

* removed duplicate logging

* test: disable unity audio

* disable audio in builder and copy native plugins from sample

* integration.ps1 cleanup

* plugin cleanup

* added CppPlugin because it needs the meta anyway

* updated snapshot

* writing plugin no longer required

* Update test/Scripts.Integration.Test/Scripts/CppPlugin.cpp

Co-authored-by: Ivan Dlugos <6349682+vaind@users.noreply.github.com>

Co-authored-by: Ivan Dlugos <6349682+vaind@users.noreply.github.com>
  • Loading branch information
bitsandfoxes and vaind authored Jul 11, 2022
1 parent 1fb22e5 commit 004ef92
Show file tree
Hide file tree
Showing 34 changed files with 827 additions and 295 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ jobs:
echo '${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}' | docker exec -i unity sh -c "cat > /usr/share/unity3d/config/services-config.json"
- name: Create new Project
run: sudo pwsh ./test/Scripts.Integration.Test/integration-create-project.ps1 -UnityPath "${{ env.UNITY_PATH }}"
run: sudo pwsh ./test/Scripts.Integration.Test/create-project.ps1 -UnityPath "${{ env.UNITY_PATH }}"

- name: Build without Sentry SDK
# This hasn't broken for many months, so disabling on PRs to speed up CI. And also to test a clean build with Sentry SDK included.
if: ${{ github.ref_name == 'main' }}
run: sudo pwsh ./test/Scripts.Integration.Test/integration-build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform "${{ matrix.platform }}"
run: sudo pwsh ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform "${{ matrix.platform }}"

- name: Download UPM package
uses: vaind/download-artifact@989a39a417730897d098ab11c34e49ac4e13ed70
Expand All @@ -246,13 +246,13 @@ jobs:
wait-timeout: 3600

- name: Extract UPM package
run: sudo pwsh ./test/Scripts.Integration.Test/integration-extract-package.ps1
run: sudo pwsh ./test/Scripts.Integration.Test/extract-package.ps1

- name: Add Sentry to the project
run: sudo pwsh ./test/Scripts.Integration.Test/integration-update-sentry.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform "${{ matrix.platform }}"
run: sudo pwsh ./test/Scripts.Integration.Test/update-sentry.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform "${{ matrix.platform }}" -CheckSymbols

- name: Build with Sentry SDK
run: sudo pwsh ./test/Scripts.Integration.Test/integration-build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform "${{ matrix.platform }}" ${{ matrix.platform != 'iOS' && '-CheckSymbols' || '' }} -UnityVersion "${{ matrix.unity-version }}"
run: sudo pwsh ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform "${{ matrix.platform }}" ${{ matrix.platform != 'iOS' && '-CheckSymbols' || '' }} -UnityVersion "${{ matrix.unity-version }}"

- name: Prepare for upload
run: |
Expand Down Expand Up @@ -336,12 +336,12 @@ jobs:
Set-Content -Path '${{ matrix.unity-config-path }}services-config.json' -Value '${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}'
- name: Create new Project
run: ./test/Scripts.Integration.Test/integration-create-project.ps1 -UnityPath "${{ env.UNITY_PATH }}"
run: ./test/Scripts.Integration.Test/create-project.ps1 -UnityPath "${{ env.UNITY_PATH }}"

- name: Build without Sentry SDK
# This hasn't broken for many months, so disabling on PRs to speed up CI. And also to test a clean build with Sentry SDK included.
if: ${{ github.ref_name == 'main' }}
run: ./test/Scripts.Integration.Test/integration-build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}"
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}"

- name: Download UPM package
uses: vaind/download-artifact@989a39a417730897d098ab11c34e49ac4e13ed70
Expand All @@ -351,19 +351,19 @@ jobs:
wait-timeout: 3600

- name: Extract UPM package
run: ./test/Scripts.Integration.Test/integration-extract-package.ps1
run: ./test/Scripts.Integration.Test/extract-package.ps1

- name: Add Sentry to test project
run: ./test/Scripts.Integration.Test/integration-update-sentry.ps1 -UnityPath "${{ env.UNITY_PATH }}"
run: ./test/Scripts.Integration.Test/update-sentry.ps1 -UnityPath "${{ env.UNITY_PATH }}" -CheckSymbols

- name: Build with Sentry SDK
run: ./test/Scripts.Integration.Test/integration-build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -CheckSymbols -UnityVersion "${{ matrix.unity-version }}"
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -CheckSymbols -UnityVersion "${{ matrix.unity-version }}"

- name: Run Player - Smoke Test
run: ./test/Scripts.Integration.Test/integration-run-smoke-test.ps1 -Smoke
run: ./test/Scripts.Integration.Test/run-smoke-test.ps1 -Smoke

- name: Run Player - Crash Test
run: ./test/Scripts.Integration.Test/integration-run-smoke-test.ps1 -Crash
run: ./test/Scripts.Integration.Test/run-smoke-test.ps1 -Crash

android-smoke-test:
needs: [smoke-test-build]
Expand Down Expand Up @@ -590,4 +590,4 @@ jobs:
- name: Run (Linux)
if: ${{ matrix.platform == 'Linux' }}
run: pwsh ./test/Scripts.Integration.Test/integration-run-smoke-test.ps1 -Smoke -Crash
run: pwsh ./test/Scripts.Integration.Test/run-smoke-test.ps1 -Smoke -Crash
8 changes: 0 additions & 8 deletions samples/unity-of-bugs/Assets/Editor.meta

This file was deleted.

11 changes: 0 additions & 11 deletions samples/unity-of-bugs/Assets/Editor/AndroidManifestUpdater.cs.meta

This file was deleted.

11 changes: 0 additions & 11 deletions samples/unity-of-bugs/Assets/Editor/Builder.cs.meta

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions samples/unity-of-bugs/Assets/Scenes/1_Bugfarm.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,6 @@ GameObject:
- component: {fileID: 1665572492}
- component: {fileID: 1665572491}
- component: {fileID: 1665572490}
- component: {fileID: 1665572493}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
Expand Down Expand Up @@ -1963,18 +1962,6 @@ Canvas:
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!114 &1665572493
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1665572488}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: de93700b17c34b345805203463b7696c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1679107580
GameObject:
m_ObjectHideFlags: 0
Expand Down
11 changes: 0 additions & 11 deletions samples/unity-of-bugs/Assets/Scripts/SmokeTestOptions.cs.meta

This file was deleted.

11 changes: 0 additions & 11 deletions samples/unity-of-bugs/Assets/Scripts/SmokeTester.cs.meta

This file was deleted.

38 changes: 16 additions & 22 deletions scripts/smoke-test-ios.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,10 @@ $ErrorActionPreference = "Stop"
. $PSScriptRoot/../test/Scripts.Integration.Test/common.ps1

$ProjectName = "Unity-iPhone"
if ($IsIntegrationTest)
{
$XcodeArtifactPath = "samples/IntegrationTest/Build"
$ArchivePath = "$XcodeArtifactPath/archive"
$AppPath = "$ArchivePath/$ProjectName/Build/Products/Release-IphoneSimulator/IntegrationTest.app"
$AppName = "com.DefaultCompany.IntegrationTest"
}
else
{
$XcodeArtifactPath = "samples/artifacts/builds/iOS/Xcode"
$ArchivePath = "$XcodeArtifactPath/archive"
$AppPath = "$ArchivePath/$ProjectName/Build/Products/Release-IphoneSimulator/unity-of-bugs.app"
$AppName = "io.sentry.samples.unityofbugs"
}
$XcodeArtifactPath = "samples/IntegrationTest/Build"
$ArchivePath = "$XcodeArtifactPath/archive"
$AppPath = "$ArchivePath/$ProjectName/Build/Products/Release-IphoneSimulator/IntegrationTest.app"
$AppName = "com.DefaultCompany.IntegrationTest"

Class AppleDevice
{
Expand Down Expand Up @@ -69,11 +59,15 @@ function Build()

Write-Host "Building iOS project"

# We need to manually switch the CLI executable, because the artifact that came through GH actions'
# upload-artifact has it's permissions stripped. See https://github.com/actions/upload-artifact/issues/38
# Side note: The permissions are set by the SentryCli.cs so end-users aren't affected if we ship the CLI
# with the missing executable bit in the UPM package - it's fixed on build.
chmod +x "$XcodeArtifactPath/sentry-cli-Darwin-universal"
$sentryCli = "sentry-cli-Darwin-universal"
if(Test-Path -Path "$XcodeArtifactPath/$sentryCli")
{
# We need to manually switch the CLI executable, because the artifact that came through GH actions'
# upload-artifact has it's permissions stripped. See https://github.com/actions/upload-artifact/issues/38
# Side note: The permissions are set by the SentryCli.cs so end-users aren't affected if we ship the CLI
# with the missing executable bit in the UPM package - it's fixed on build.
chmod +x "$XcodeArtifactPath/$sentryCli"
}

$buildCallback = {
xcodebuild `
Expand Down Expand Up @@ -160,15 +154,15 @@ function Test

function RunTest([string] $Name, [string] $SuccessString)
{
Write-Host "Launching $Name test on $($device.Name)" -ForegroundColor Green
Write-Host "Launching '$Name' test on '$($device.Name)'" -ForegroundColor Green
$consoleOut = xcrun simctl launch --console-pty $($device.UUID) $AppName "--test" $Name

if ("$SuccessString" -eq "")
{
$SuccessString = "${$Name.ToUpper()} TEST: PASS"
}

Write-Host -NoNewline "$Name test STATUS: "
Write-Host -NoNewline "'$Name' test STATUS: "
$stdout = $consoleOut | Select-String $SuccessString
If ($null -ne $stdout)
{
Expand All @@ -178,7 +172,7 @@ function Test
{
$device.TestFailed = $True
Write-Host "FAILED" -ForegroundColor Red
Write-Host "$($device.Name) Console"
Write-Host "===== START OF '$($device.Name)' CONSOLE ====="
foreach ($consoleLine in $consoleOut)
{
Write-Host $consoleLine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private static void ConfigureOptions(Dictionary<string, string> args, [CallerMem
if (args.TryGetValue("diagnosticLevel", out value))
{
Debug.LogFormat("{0}: Configuring DiagnosticLevel to {1}", functionName, value);
options.DebugOnlyInEditor = false;
options.DiagnosticLevel = value switch
{
"debug" => SentryLevel.Debug,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ public static void BuildIl2CPPPlayer(BuildTarget target, BuildTargetGroup group)
// Make sure the configuration is right.
EditorUserBuildSettings.selectedBuildTargetGroup = group;
PlayerSettings.SetScriptingBackend(group, ScriptingImplementation.IL2CPP);

if (args.ContainsKey("sentryOptions.configure"))
{
SetupSentryOptions(args);
}
DisableUnityAudio();

var buildPlayerOptions = new BuildPlayerOptions
{
scenes = new[] { "Assets/Scenes/1_Bugfarm.unity" },
locationPathName = args["buildPath"],
target = target,
targetGroup = group,
options = BuildOptions.StrictMode,
};

if(File.Exists("Assets/Scenes/SmokeTest.unity"))
{
buildPlayerOptions.scenes = new[] { "Assets/Scenes/SmokeTest.unity" };
}

var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
var summary = report.summary;

Expand Down Expand Up @@ -62,61 +62,13 @@ public static void BuildIl2CPPPlayer(BuildTarget target, BuildTargetGroup group)
Debug.Log($"Build succeeded with {summary.totalWarnings} warning{(summary.totalWarnings > 1 ? "s" : "")}.");
}
}

public static void BuildWindowsIl2CPPPlayer() => BuildIl2CPPPlayer(BuildTarget.StandaloneWindows64, BuildTargetGroup.Standalone);
public static void BuildMacIl2CPPPlayer() => BuildIl2CPPPlayer(BuildTarget.StandaloneOSX, BuildTargetGroup.Standalone);
public static void BuildLinuxIl2CPPPlayer() => BuildIl2CPPPlayer(BuildTarget.StandaloneLinux64, BuildTargetGroup.Standalone);
public static void BuildAndroidIl2CPPPlayer() => BuildIl2CPPPlayer(BuildTarget.Android, BuildTargetGroup.Android);
public static void BuildIOSPlayer() => BuildIl2CPPPlayer(BuildTarget.iOS, BuildTargetGroup.iOS);
public static void BuildWebGLPlayer() => BuildIl2CPPPlayer(BuildTarget.WebGL, BuildTargetGroup.WebGL);

private static void SetupSentryOptions(Dictionary<string, string> args)
{
Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "SetupSentryOptions: Invoking SentryOptions");

if (!EditorApplication.ExecuteMenuItem("Tools/Sentry"))
{
throw new Exception("SetupSentryOptions: Menu item Tools -> Sentry was not found.");
}

var sentryWindowType = AppDomain.CurrentDomain.GetAssemblies()
?.FirstOrDefault(assembly => assembly.FullName.StartsWith("Sentry.Unity.Editor,"))
?.GetTypes()?.FirstOrDefault(type => type.FullName == "Sentry.Unity.Editor.SentryWindow");
if (sentryWindowType is null)
{
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies().Where(name => name.FullName.Contains("Sentry")))
{
foreach (var type in asm.GetTypes())
{
Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "SetupSentryOptions: Asm {0} Type {1}", asm.FullName, type.FullName);
}
}
throw new EntryPointNotFoundException("SetupSentryOptions: Type SentryWindow not found");
}

var optionsWindow = EditorWindow.GetWindow(sentryWindowType);
var options = optionsWindow.GetType().GetProperty("Options").GetValue(optionsWindow);

if (options is null)
{
throw new EntryPointNotFoundException("SetupSentryOptions: Method SentryOptions not found");
}
Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "SetupSentryOptions: Found SentryOptions");

var dsn = args["sentryOptions.Dsn"];
if (dsn != null)
{
Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null,
"SetupSentryOptions: Configuring Dsn to {0}", dsn);

var dnsPropertyInfo = options.GetType().GetProperty("Dsn");
dnsPropertyInfo.SetValue(options, dsn, null);
}

optionsWindow.Close();
Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "SetupSentryOptions: Sentry options Configured");
}

public static Dictionary<string, string> ParseCommandLineArguments()
{
var commandLineArguments = new Dictionary<string, string>();
Expand Down Expand Up @@ -146,4 +98,14 @@ private static void ValidateArguments(Dictionary<string, string> args)
throw new Exception("No valid '-buildPath' has been provided.");
}
}

// Audio created issues, especially for iOS simulator so we disable it.
private static void DisableUnityAudio()
{
var audioManager = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/AudioManager.asset")[0];
var serializedManager = new SerializedObject(audioManager);
var prop = serializedManager.FindProperty("m_DisableAudio");
prop.boolValue = true;
serializedManager.ApplyModifiedProperties();
}
}
Loading

0 comments on commit 004ef92

Please sign in to comment.