From 6eb44bca4619ea62fb3162f29f9e599b334eef76 Mon Sep 17 00:00:00 2001 From: Richard Elms Date: Tue, 21 Jan 2025 21:55:48 +0100 Subject: [PATCH] auto symbol upload testing (#870) --- .buildkite/unity.2020.yml | 36 ++-------- .buildkite/unity.2021.yml | 39 ++--------- .buildkite/unity.2022.yml | 36 ++-------- .buildkite/unity.6000.yml | 36 ++-------- .gitignore | 2 + .../Bugsnag/Editor/SymbolUpload/BugsnagCLI.cs | 16 ++--- .../SymbolUpload/BugsnagSymbolUploader.cs | 24 ++++--- .../Bugsnag/Runtime/BugsnagSettingsObject.cs | 9 ++- Gemfile | 1 - features/build/build_android.feature | 24 +++++++ features/build/build_ios.feature | 9 +++ features/csharp/csharp_events.feature | 2 +- .../maze_runner/Assets/Editor/Builder.cs | 48 ++++++++++--- .../maze_runner/Assets/Resources.meta | 8 +++ .../Bugsnag/BugsnagSettingsObject.asset | 68 +++++++++++++++++++ .../Bugsnag/BugsnagSettingsObject.asset.meta | 8 +++ features/scripts/build_android.sh | 2 +- features/scripts/build_ios.sh | 53 ++++++++------- features/scripts/generate_xcode_project.sh | 2 +- features/steps/unity_steps.rb | 25 ++++++- features/support/env.rb | 14 +++- 21 files changed, 280 insertions(+), 182 deletions(-) create mode 100644 features/build/build_android.feature create mode 100644 features/build/build_ios.feature create mode 100644 features/fixtures/maze_runner/Assets/Resources.meta create mode 100644 features/fixtures/maze_runner/Assets/Resources/Bugsnag/BugsnagSettingsObject.asset create mode 100644 features/fixtures/maze_runner/Assets/Resources/Bugsnag/BugsnagSettingsObject.asset.meta diff --git a/.buildkite/unity.2020.yml b/.buildkite/unity.2020.yml index d69060fc8..c3d3032d2 100644 --- a/.buildkite/unity.2020.yml +++ b/.buildkite/unity.2020.yml @@ -19,9 +19,9 @@ steps: upload: - features/fixtures/maze_runner/mazerunner_2020.apk - features/fixtures/build_android_apk.log - commands: - - bundle install - - rake test:android:build + command: + - "bundle install" + - "bundle exec maze-runner --os macos features/build/build_android.feature" retry: automatic: - exit_status: "*" @@ -30,31 +30,9 @@ steps: # # Build iOS test fixtures # - - label: ":ios: Generate Xcode project - Unity 2020" - timeout_in_minutes: 20 - key: "generate-fixture-project-2020" - env: - UNITY_VERSION: *2020 - plugins: - artifacts#v1.9.0: - download: - - Bugsnag.unitypackage - upload: - - features/fixtures/unity.log - - project_2020.tgz - commands: - - bundle install - - rake test:ios:generate_xcode - - tar -zvcf project_2020.tgz features/fixtures/maze_runner/mazerunner_xcode - retry: - automatic: - - exit_status: "*" - limit: 1 - - label: ":ios: Build iOS test fixture for Unity 2020" timeout_in_minutes: 10 key: "build-ios-fixture-2020" - depends_on: "generate-fixture-project-2020" env: XCODE_VERSION: "15.3.0" UNITY_VERSION: *2020 @@ -62,14 +40,12 @@ steps: artifacts#v1.9.0: download: - Bugsnag.unitypackage - - project_2020.tgz upload: - features/fixtures/maze_runner/mazerunner_2020.ipa - features/fixtures/unity.log - commands: - - bundle install - - tar -zxf project_2020.tgz features/fixtures/maze_runner - - rake test:ios:build_xcode + command: + - "bundle install" + - "bundle exec maze-runner --os macos features/build/build_ios.feature" retry: automatic: - exit_status: "*" diff --git a/.buildkite/unity.2021.yml b/.buildkite/unity.2021.yml index 59528c7b0..8c3c78b6d 100644 --- a/.buildkite/unity.2021.yml +++ b/.buildkite/unity.2021.yml @@ -19,33 +19,9 @@ steps: upload: - features/fixtures/maze_runner/mazerunner_2021.apk - features/fixtures/build_android_apk.log - commands: - - bundle install - - rake test:android:build - retry: - automatic: - - exit_status: "*" - limit: 1 - - # - # Build iOS test fixtures - # - - label: ":ios: Generate Xcode project - Unity 2021" - timeout_in_minutes: 20 - key: "generate-fixture-project-2021" - env: - UNITY_VERSION: *2021 - plugins: - artifacts#v1.5.0: - download: - - Bugsnag.unitypackage - upload: - - features/fixtures/unity.log - - project_2021.tgz - commands: - - bundle install - - rake test:ios:generate_xcode - - tar -zvcf project_2021.tgz features/fixtures/maze_runner/mazerunner_xcode + command: + - "bundle install" + - "bundle exec maze-runner --os macos features/build/build_android.feature" retry: automatic: - exit_status: "*" @@ -54,7 +30,6 @@ steps: - label: ":ios: Build iOS test fixture for Unity 2021" timeout_in_minutes: 10 key: "build-ios-fixture-2021" - depends_on: "generate-fixture-project-2021" env: UNITY_VERSION: *2021 XCODE_VERSION: "15.3.0" @@ -62,14 +37,12 @@ steps: artifacts#v1.5.0: download: - Bugsnag.unitypackage - - project_2021.tgz upload: - features/fixtures/maze_runner/mazerunner_2021.ipa - features/fixtures/unity.log - commands: - - bundle install - - tar -zxf project_2021.tgz features/fixtures/maze_runner - - rake test:ios:build_xcode + command: + - "bundle install" + - "bundle exec maze-runner --os macos features/build/build_ios.feature" retry: automatic: - exit_status: "*" diff --git a/.buildkite/unity.2022.yml b/.buildkite/unity.2022.yml index 99c2b40ee..65004ac98 100644 --- a/.buildkite/unity.2022.yml +++ b/.buildkite/unity.2022.yml @@ -19,30 +19,9 @@ steps: upload: - features/fixtures/maze_runner/mazerunner_2022.apk - features/fixtures/build_android_apk.log - commands: - - bundle install - - rake test:android:build - retry: - automatic: - - exit_status: "*" - limit: 1 - - - label: ":ios: Generate Xcode project - Unity 2022" - timeout_in_minutes: 10 - key: "generate-fixture-project-2022" - env: - UNITY_VERSION: *2022 - plugins: - artifacts#v1.9.0: - download: - - Bugsnag.unitypackage - upload: - - features/fixtures/unity.log - - project_2022.tgz - commands: - - bundle install - - rake test:ios:generate_xcode - - tar -zvcf project_2022.tgz features/fixtures/maze_runner/mazerunner_xcode + command: + - "bundle install" + - "bundle exec maze-runner --os macos features/build/build_android.feature" retry: automatic: - exit_status: "*" @@ -51,7 +30,6 @@ steps: - label: ":ios: Build iOS test fixture for Unity 2022" timeout_in_minutes: 10 key: "build-ios-fixture-2022" - depends_on: "generate-fixture-project-2022" env: UNITY_VERSION: *2022 XCODE_VERSION: "15.3.0" @@ -59,14 +37,12 @@ steps: artifacts#v1.9.0: download: - Bugsnag.unitypackage - - project_2022.tgz upload: - features/fixtures/maze_runner/mazerunner_2022.ipa - features/fixtures/unity.log - commands: - - bundle install - - tar -zxf project_2022.tgz features/fixtures/maze_runner - - rake test:ios:build_xcode + command: + - "bundle install" + - "bundle exec maze-runner --os macos features/build/build_ios.feature" retry: automatic: - exit_status: "*" diff --git a/.buildkite/unity.6000.yml b/.buildkite/unity.6000.yml index 17abbcd98..2659b9ec7 100644 --- a/.buildkite/unity.6000.yml +++ b/.buildkite/unity.6000.yml @@ -19,30 +19,9 @@ steps: upload: - features/fixtures/maze_runner/mazerunner_6000.apk - features/fixtures/build_android_apk.log - commands: - - bundle install - - rake test:android:build - retry: - automatic: - - exit_status: "*" - limit: 1 - - - label: ":ios: Generate Xcode project - Unity 6000" - timeout_in_minutes: 10 - key: "generate-fixture-project-6000" - env: - UNITY_VERSION: *6000 - plugins: - artifacts#v1.9.0: - download: - - Bugsnag.unitypackage - upload: - - features/fixtures/unity.log - - project_6000.tgz - commands: - - bundle install - - rake test:ios:generate_xcode - - tar -zvcf project_6000.tgz features/fixtures/maze_runner/mazerunner_xcode + command: + - "bundle install" + - "bundle exec maze-runner --os macos features/build/build_android.feature" retry: automatic: - exit_status: "*" @@ -51,7 +30,6 @@ steps: - label: ":ios: Build iOS test fixture for Unity 6000" timeout_in_minutes: 10 key: "build-ios-fixture-6000" - depends_on: "generate-fixture-project-6000" env: UNITY_VERSION: *6000 XCODE_VERSION: "16.0.0" @@ -59,14 +37,12 @@ steps: artifacts#v1.9.0: download: - Bugsnag.unitypackage - - project_6000.tgz upload: - features/fixtures/maze_runner/mazerunner_6000.ipa - features/fixtures/unity.log - commands: - - bundle install - - tar -zxf project_6000.tgz features/fixtures/maze_runner - - rake test:ios:build_xcode + command: + - "bundle install" + - "bundle exec maze-runner --os macos features/build/build_ios.feature" retry: automatic: - exit_status: "*" diff --git a/.gitignore b/.gitignore index 739813160..e6d5de1e5 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,5 @@ upm/UPMImportProject/Library upm-package upm/UPMImportProject/.vscode UPMImportProject.sln +!features/build/ + diff --git a/Bugsnag/Assets/Bugsnag/Editor/SymbolUpload/BugsnagCLI.cs b/Bugsnag/Assets/Bugsnag/Editor/SymbolUpload/BugsnagCLI.cs index ec4d064d7..88aaeed73 100644 --- a/Bugsnag/Assets/Bugsnag/Editor/SymbolUpload/BugsnagCLI.cs +++ b/Bugsnag/Assets/Bugsnag/Editor/SymbolUpload/BugsnagCLI.cs @@ -8,13 +8,13 @@ namespace BugsnagUnity.Editor { internal class BugsnagCLI { - private const string DOWNLOADED_CLI_VERSION = "2.7.0"; + private const string DOWNLOADED_CLI_VERSION = "2.8.0"; private readonly string DOWNLOADED_CLI_PATH = Path.Combine(Application.dataPath, "../bugsnag/bin/bugsnag_cli"); private readonly string DOWNLOADED_CLI_URL = $"https://github.com/bugsnag/bugsnag-cli/releases/download/v{DOWNLOADED_CLI_VERSION}/"; private readonly string _cliExecutablePath; public BugsnagCLI() { - var config = BugsnagSettingsObject.GetSettingsObject(); + var config = BugsnagSettingsObject.LoadBuildTimeSettingsObject(); if (string.IsNullOrEmpty(config.BugsnagCLIExecutablePath)) { @@ -30,7 +30,7 @@ public BugsnagCLI() } } - public void UploadAndroidSymbols(string buildOutputPath, string apiKey, string versionName, int versionCode, string uploadEndpoint) + public void UploadAndroidSymbols(string buildOutputPath, string apiKey, string versionName, int versionCode, string uploadEndpoint, string bundleId) { string args = $"upload unity-android --api-key={apiKey} --verbose --project-root={Application.dataPath} {buildOutputPath}"; @@ -46,6 +46,10 @@ public void UploadAndroidSymbols(string buildOutputPath, string apiKey, string v { args += $" --upload-api-root-url={uploadEndpoint}"; } + if (!string.IsNullOrEmpty(bundleId)) + { + args += $" --application-id={bundleId}"; + } int exitCode = StartProcess(_cliExecutablePath, args, out string output, out string error); if (exitCode != 0) @@ -187,17 +191,13 @@ private int StartProcess(string fileName, string arguments, out string standardO return process.ExitCode; } - public string GetIosDsymUploadCommand(string apiKey, string uploadEndpoint, string versionName) + public string GetIosDsymUploadCommand(string apiKey, string uploadEndpoint) { var command = $"{_cliExecutablePath} upload xcode-build --api-key={apiKey} $DWARF_DSYM_FOLDER_PATH"; if (!string.IsNullOrEmpty(uploadEndpoint)) { command += $" --upload-api-root-url={uploadEndpoint}"; } - if (!string.IsNullOrEmpty(versionName)) - { - command += $" --app-version={versionName}"; - } return command; } diff --git a/Bugsnag/Assets/Bugsnag/Editor/SymbolUpload/BugsnagSymbolUploader.cs b/Bugsnag/Assets/Bugsnag/Editor/SymbolUpload/BugsnagSymbolUploader.cs index 6eae27871..f7312ded5 100644 --- a/Bugsnag/Assets/Bugsnag/Editor/SymbolUpload/BugsnagSymbolUploader.cs +++ b/Bugsnag/Assets/Bugsnag/Editor/SymbolUpload/BugsnagSymbolUploader.cs @@ -5,6 +5,9 @@ #if UNITY_IOS || UNITY_STANDALONE_OSX using UnityEditor.iOS.Xcode; #endif +#if UNITY_6000_0_OR_NEWER && UNITY_ANDROID +using UnityEditor.Android; +#endif using UnityEngine; namespace BugsnagUnity.Editor @@ -34,7 +37,7 @@ public void OnPostprocessBuild(BuildReport report) return; } - var config = BugsnagSettingsObject.GetSettingsObject(); + var config = BugsnagSettingsObject.LoadBuildTimeSettingsObject(); if (config == null || !config.AutoUploadSymbols) { return; @@ -45,7 +48,8 @@ public void OnPostprocessBuild(BuildReport report) EditorUtility.DisplayProgressBar("BugSnag Symbol Upload", "Uploading Android symbol files", 0.0f); try { - UploadAndroidSymbols(buildOutputPath, config); + var bundleId = PlayerSettings.GetApplicationIdentifier(report.summary.platformGroup); + UploadAndroidSymbols(buildOutputPath, config, bundleId); } catch (System.Exception e) { @@ -63,7 +67,7 @@ private bool IsSupportedPlatform(BuildTarget platform) return platform == BuildTarget.Android || platform == BuildTarget.iOS || platform == BuildTarget.StandaloneOSX; } - private void UploadAndroidSymbols(string buildOutputPath, BugsnagSettingsObject config) + private void UploadAndroidSymbols(string buildOutputPath, BugsnagSettingsObject config, string bundleId) { if (!IsAndroidSymbolCreationEnabled()) { @@ -71,14 +75,16 @@ private void UploadAndroidSymbols(string buildOutputPath, BugsnagSettingsObject return; } var cli = new BugsnagCLI(); - cli.UploadAndroidSymbols(buildOutputPath, config.ApiKey, config.AppVersion, config.VersionCode, config.UploadEndpoint); + cli.UploadAndroidSymbols(buildOutputPath, config.ApiKey, config.AppVersion, config.VersionCode, config.UploadEndpoint, bundleId); } private bool IsAndroidSymbolCreationEnabled() { #if UNITY_ANDROID - -#if UNITY_2021_1_OR_NEWER +#if UNITY_6000_0_OR_NEWER + return UserBuildSettings.DebugSymbols.level == Unity.Android.Types.DebugSymbolLevel.SymbolTable || + UserBuildSettings.DebugSymbols.level == Unity.Android.Types.DebugSymbolLevel.Full; +#elif UNITY_2021_1_OR_NEWER return EditorUserBuildSettings.androidCreateSymbols == AndroidCreateSymbols.Public || EditorUserBuildSettings.androidCreateSymbols == AndroidCreateSymbols.Debugging; #else @@ -134,10 +140,10 @@ private void AddXcodePostBuildScript(string pathToBuiltProject, BugsnagSettingsO string GetMacosXcodeProjectPath(string outputPath) { string[] parts = outputPath.Split('/'); - string xcprojFile = parts[^1] + ".xcodeproj"; + string xcprojFile = parts[parts.Length - 1] + ".xcodeproj"; return outputPath + "/" + xcprojFile + "/project.pbxproj"; } - + private string RemoveShellScriptPhase(string project, string guid) { // Search for and remove the phase object from the XML. only match the guid followed by the braces @@ -155,7 +161,7 @@ private string RemoveShellScriptPhase(string project, string guid) private string GetDsymUploadCommand(BugsnagSettingsObject config) { var cli = new BugsnagCLI(); - var command = cli.GetIosDsymUploadCommand(config.ApiKey, config.UploadEndpoint, config.AppVersion); + var command = cli.GetIosDsymUploadCommand(config.ApiKey, config.UploadEndpoint); return DSYM_UPLOAD_SCRIPT_TEMPLATE.Replace("", command); } } diff --git a/Bugsnag/Assets/Bugsnag/Runtime/BugsnagSettingsObject.cs b/Bugsnag/Assets/Bugsnag/Runtime/BugsnagSettingsObject.cs index c29c5e629..4b9f70361 100644 --- a/Bugsnag/Assets/Bugsnag/Runtime/BugsnagSettingsObject.cs +++ b/Bugsnag/Assets/Bugsnag/Runtime/BugsnagSettingsObject.cs @@ -58,9 +58,14 @@ public class BugsnagSettingsObject : ScriptableObject public int SwitchCacheIndex = 0; public int SwitchCacheMaxSize = 10485760; - internal static BugsnagSettingsObject GetSettingsObject() + public static BugsnagSettingsObject LoadBuildTimeSettingsObject() { - return Resources.Load("Bugsnag/BugsnagSettingsObject"); + var settings = Resources.Load("Bugsnag/BugsnagSettingsObject"); + if (settings == null) + { + throw new Exception("No BugsnagSettingsObject found."); + } + return settings; } public static Configuration LoadConfiguration() diff --git a/Gemfile b/Gemfile index 51eb06ffb..717dfe443 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,6 @@ gem 'rake' gem 'xcpretty' gem 'xcodeproj' gem 'cocoapods' -gem 'rake' gem 'danger' unless Gem.win_platform? diff --git a/features/build/build_android.feature b/features/build/build_android.feature new file mode 100644 index 000000000..ed988ef78 --- /dev/null +++ b/features/build/build_android.feature @@ -0,0 +1,24 @@ +Feature: Build Android + + @skip_unity_2020 # Unity 2020 only produces 4 symbol files + Scenario: Auto Symbol Upload + When I run the script "features/scripts/prepare_fixture.sh" synchronously + When I run the script "features/scripts/build_android.sh release" synchronously + Then I wait to receive 6 sourcemaps + Then the sourcemaps Content-Type header is valid multipart form-data + And the sourcemap payload field "apiKey" equals "a35a2a72bd230ac0aa0f52715bbdc6aa" + And the sourcemap payload field "versionCode" equals "123" + And the sourcemap payload field "versionName" equals "1.2.3" + And the sourcemap payload field "appId" equals "com.bugsnag.fixtures.unity.notifier.android" + + + @unity_2020_only + Scenario: Auto Symbol Upload Unity 2020 + When I run the script "features/scripts/prepare_fixture.sh" synchronously + When I run the script "features/scripts/build_android.sh release" synchronously + Then I wait to receive 4 sourcemaps + Then the sourcemaps Content-Type header is valid multipart form-data + And the sourcemap payload field "apiKey" equals "a35a2a72bd230ac0aa0f52715bbdc6aa" + And the sourcemap payload field "versionCode" equals "123" + And the sourcemap payload field "versionName" equals "1.2.3" + And the sourcemap payload field "appId" equals "com.bugsnag.fixtures.unity.notifier.android" diff --git a/features/build/build_ios.feature b/features/build/build_ios.feature new file mode 100644 index 000000000..ac9eb3a38 --- /dev/null +++ b/features/build/build_ios.feature @@ -0,0 +1,9 @@ +Feature: Build iOS + + Scenario: Auto Symbol Upload + When I run the script "features/scripts/prepare_fixture.sh" synchronously + When I run the script "features/scripts/generate_xcode_project.sh release" synchronously + When I run the script "features/scripts/build_ios.sh release" synchronously + Then I wait to receive 2 sourcemaps + Then the sourcemaps Content-Type header is valid multipart form-data + And the sourcemap payload field "apiKey" equals "a35a2a72bd230ac0aa0f52715bbdc6aa" diff --git a/features/csharp/csharp_events.feature b/features/csharp/csharp_events.feature index d59918e0d..9ce1a2010 100644 --- a/features/csharp/csharp_events.feature +++ b/features/csharp/csharp_events.feature @@ -12,7 +12,7 @@ Feature: csharp events And the event "unhandled" is false And custom metadata is included in the event And the stack frame methods should match: - | NotifySmokeTest.Run() | Main+d__8.MoveNext() | + | NotifySmokeTest.Run() | Main+d__8.MoveNext() | BugsnagUnity.Client.Notify(Exception exception, HandledState handledState, Func callback) | And expected device metadata is included in the event And expected app metadata is included in the event And the error payload field "events.0.severityReason.unhandledOverridden" is false diff --git a/features/fixtures/maze_runner/Assets/Editor/Builder.cs b/features/fixtures/maze_runner/Assets/Editor/Builder.cs index 59eea7505..7c37d4467 100644 --- a/features/fixtures/maze_runner/Assets/Editor/Builder.cs +++ b/features/fixtures/maze_runner/Assets/Editor/Builder.cs @@ -1,12 +1,9 @@ using System.Linq; using UnityEngine; -using BugsnagUnity.Editor; - -#if UNITY_EDITOR +using BugsnagUnity; using UnityEditor; -using UnityEditor.Callbacks; - -public class Builder : MonoBehaviour { +public class Builder : MonoBehaviour +{ static void BuildStandalone(string folder, BuildTarget target, bool dev) { @@ -72,14 +69,37 @@ public static void AndroidDev() BuildAndroid(true); } + private static void EnableAndroidSymbolUpload() + { +#if UNITY_ANDROID + #if UNITY_2020_1_OR_NEWER + EditorUserBuildSettings.androidCreateSymbolsZip = true; + #else + EditorUserBuildSettings.androidCreateSymbols = AndroidCreateSymbols.Public; + #endif +#endif + var settingsObject = BugsnagSettingsObject.LoadBuildTimeSettingsObject(); + settingsObject.ApiKey = "a35a2a72bd230ac0aa0f52715bbdc6aa"; + settingsObject.StartAutomaticallyAtLaunch = false; + settingsObject.AutoUploadSymbols = true; + settingsObject.UploadEndpoint = "http://localhost:9339"; + settingsObject.AppVersion = "1.2.3"; + settingsObject.VersionCode = 123; + EditorUtility.SetDirty(settingsObject); + } + public static void AndroidRelease() { + EnableAndroidSymbolUpload(); BuildAndroid(false); } // Generates the Mazerunner APK static void BuildAndroid(bool dev) { +#if UNITY_ANDROID + Debug.Log("Building Android app..."); + PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARMv7 | AndroidArchitecture.ARM64; PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, "com.bugsnag.fixtures.unity.notifier.android"); var opts = CommonMobileBuildOptions(dev ? "mazerunner_dev.apk" : "mazerunner.apk", dev); opts.target = BuildTarget.Android; @@ -90,6 +110,7 @@ static void BuildAndroid(bool dev) var result = BuildPipeline.BuildPlayer(opts); Debug.Log("Result: " + result); +#endif } @@ -102,8 +123,20 @@ public static void IosDev() public static void IosRelease() { + EnableIosSymbolUpload(); IosBuild(false); } + + private static void EnableIosSymbolUpload() + { + var settingsObject = BugsnagSettingsObject.LoadBuildTimeSettingsObject(); + settingsObject.ApiKey = "a35a2a72bd230ac0aa0f52715bbdc6aa"; + settingsObject.StartAutomaticallyAtLaunch = false; + settingsObject.AutoUploadSymbols = true; + settingsObject.UploadEndpoint = "http://localhost:9339"; + settingsObject.AppVersion = "1.2.3"; + EditorUtility.SetDirty(settingsObject); + } static void IosBuild(bool dev) { Debug.Log("Building iOS app..."); @@ -121,7 +154,7 @@ public static void SwitchBuild() { Debug.Log("Building Switch app..."); PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Switch, "com.bugsnag.fixtures.unity.notifier.ios"); - var opts = CommonMobileBuildOptions("mazerunner.nspd",false); + var opts = CommonMobileBuildOptions("mazerunner.nspd", false); opts.target = BuildTarget.Switch; opts.options = BuildOptions.Development; @@ -145,4 +178,3 @@ private static BuildPlayerOptions CommonMobileBuildOptions(string outputFile, bo return opts; } } -#endif diff --git a/features/fixtures/maze_runner/Assets/Resources.meta b/features/fixtures/maze_runner/Assets/Resources.meta new file mode 100644 index 000000000..037476e64 --- /dev/null +++ b/features/fixtures/maze_runner/Assets/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ecdc2c24362b642e49c8f2cc8485e7d7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/features/fixtures/maze_runner/Assets/Resources/Bugsnag/BugsnagSettingsObject.asset b/features/fixtures/maze_runner/Assets/Resources/Bugsnag/BugsnagSettingsObject.asset new file mode 100644 index 000000000..dbdac0529 --- /dev/null +++ b/features/fixtures/maze_runner/Assets/Resources/Bugsnag/BugsnagSettingsObject.asset @@ -0,0 +1,68 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3e0efee821abb422baf5bb3728925f09, type: 3} + m_Name: BugsnagSettingsObject + m_EditorClassIdentifier: + AutoUploadSymbols: 0 + BugsnagCLIExecutablePath: + UploadEndpoint: + StartAutomaticallyAtLaunch: 1 + AutoDetectErrors: 1 + AutoTrackSessions: 1 + ApiKey: + AppType: + AppHangThresholdMillis: 0 + AppVersion: + BundleVersion: + BreadcrumbLogLevel: 4 + Context: + DiscardClasses: [] + EnabledReleaseStages: [] + EnabledErrorTypes: + ANRs: 1 + AppHangs: 1 + OOMs: 1 + Crashes: 1 + ThermalKills: 1 + UnityLog: 1 + EnabledBreadcrumbTypes: + Error: 1 + Log: 1 + Navigation: 1 + Process: 1 + Request: 1 + State: 1 + User: 1 + LaunchDurationMillis: 5000 + MaximumBreadcrumbs: 100 + MaxPersistedEvents: 32 + MaxPersistedSessions: 128 + MaxReportedThreads: 200 + MaxStringValueLength: 10000 + NotifyEndpoint: https://notify.bugsnag.com + NotifyLogLevel: 0 + PersistUser: 1 + SessionEndpoint: https://sessions.bugsnag.com + SendThreads: 1 + RedactedKeys: + - .*password.* + ReleaseStage: + ReportExceptionLogsAsHandled: 1 + SendLaunchCrashesSynchronously: 1 + SecondsPerUniqueLog: 5 + Telemetry: 0000000001000000 + VersionCode: -1 + GenerateAnonymousId: 1 + SwitchCacheType: 1 + SwitchCacheMountName: BugsnagCache + SwitchCacheIndex: 0 + SwitchCacheMaxSize: 10485760 diff --git a/features/fixtures/maze_runner/Assets/Resources/Bugsnag/BugsnagSettingsObject.asset.meta b/features/fixtures/maze_runner/Assets/Resources/Bugsnag/BugsnagSettingsObject.asset.meta new file mode 100644 index 000000000..05532b6d7 --- /dev/null +++ b/features/fixtures/maze_runner/Assets/Resources/Bugsnag/BugsnagSettingsObject.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 46b8a9d872bd745bfb19dfdd85908faa +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/features/scripts/build_android.sh b/features/scripts/build_android.sh index 0fcad6229..4c1417a33 100755 --- a/features/scripts/build_android.sh +++ b/features/scripts/build_android.sh @@ -23,7 +23,7 @@ popd pushd "$script_path/../fixtures" # Run unity and immediately exit afterwards, log all output -DEFAULT_CLI_ARGS="-quit -batchmode -nographics -logFile build_android_apk.log" +DEFAULT_CLI_ARGS="-quit -batchmode -nographics -logFile build_android_apk.log -buildTarget Android" project_path=`pwd`/maze_runner diff --git a/features/scripts/build_ios.sh b/features/scripts/build_ios.sh index bece9a7b1..95ed299f6 100755 --- a/features/scripts/build_ios.sh +++ b/features/scripts/build_ios.sh @@ -14,15 +14,17 @@ fi BUILD_TYPE=$1 -pushd "${0%/*}" - script_path=`pwd` -popd -pushd "$script_path/../fixtures" -project_path=`pwd`/maze_runner +pushd "${0%/*}" >/dev/null + script_path=$(pwd) +popd >/dev/null +pushd "$script_path/../fixtures" >/dev/null + project_path="$(pwd)/maze_runner" +popd >/dev/null # Clean any previous builds -find $project_path/output/ -name "*.ipa" -exec rm '{}' \; +find "$project_path/output/" -name "*.ipa" -exec rm '{}' \; +# Determine which Xcode project and IPA name to use if [ "$BUILD_TYPE" == "dev" ]; then XCODE_PROJECT="mazerunner_dev_xcode/Unity-iPhone.xcodeproj" OUTPUT_IPA="mazerunner_dev_${UNITY_VERSION:0:4}.ipa" @@ -34,33 +36,36 @@ else exit 1 fi -# Archive and export the project -xcrun xcodebuild -project $project_path/$XCODE_PROJECT \ - -scheme Unity-iPhone \ - -configuration Debug \ - -archivePath $project_path/archive/Unity-iPhone.xcarchive \ - -allowProvisioningUpdates \ - -allowProvisioningDeviceRegistration \ - -quiet \ - GCC_WARN_INHIBIT_ALL_WARNINGS=YES \ - archive +# ARCHIVE (equivalent to Product > Archive) +xcrun xcodebuild \ + -project "$project_path/$XCODE_PROJECT" \ + -scheme Unity-iPhone \ + -configuration Release \ + clean archive \ + -archivePath "$project_path/archive/Unity-iPhone.xcarchive" \ + -allowProvisioningUpdates \ + -allowProvisioningDeviceRegistration \ + -quiet \ + GCC_WARN_INHIBIT_ALL_WARNINGS=YES -if [ $? -ne 0 ] -then +if [ $? -ne 0 ]; then echo "Failed to archive project" exit 1 fi +# EXPORT ARCHIVE xcrun xcodebuild -exportArchive \ - -archivePath $project_path/archive/Unity-iPhone.xcarchive \ - -exportPath $project_path/output/ \ - -quiet \ - -exportOptionsPlist $script_path/exportOptions.plist + -archivePath "$project_path/archive/Unity-iPhone.xcarchive" \ + -exportPath "$project_path/output/" \ + -exportOptionsPlist "$script_path/exportOptions.plist" \ + -quiet if [ $? -ne 0 ]; then echo "Failed to export app" exit 1 fi -# Move to known location for running (note - the name of the .ipa differs between Xcode versions) -find $project_path/output/ -name "*.ipa" -exec mv '{}' $project_path/$OUTPUT_IPA \; +# MOVE IPA TO A KNOWN LOCATION +find "$project_path/output/" -name "*.ipa" -exec mv '{}' "$project_path/$OUTPUT_IPA" \; + +echo "Successfully built and exported: $OUTPUT_IPA" \ No newline at end of file diff --git a/features/scripts/generate_xcode_project.sh b/features/scripts/generate_xcode_project.sh index 6dc9462af..cb637e697 100755 --- a/features/scripts/generate_xcode_project.sh +++ b/features/scripts/generate_xcode_project.sh @@ -22,7 +22,7 @@ popd pushd "$script_path/../fixtures" -DEFAULT_CLI_ARGS="-quit -nographics -batchmode -logFile unity.log" +DEFAULT_CLI_ARGS="-quit -nographics -batchmode -logFile unity.log -buildTarget iOS" project_path=`pwd`/maze_runner diff --git a/features/steps/unity_steps.rb b/features/steps/unity_steps.rb index 45b7bb6d5..aea18add7 100644 --- a/features/steps/unity_steps.rb +++ b/features/steps/unity_steps.rb @@ -19,6 +19,12 @@ def execute_command(action, scenario_name = '') raise 'Test fixture did not GET /command' unless Maze::Server.commands.remaining.empty? end +Then('the sourcemaps Content-Type header is valid multipart form-data') do + expected = /^multipart\/form-data; boundary=([^;]+)/ + actual = Maze::Server.sourcemaps.current[:request]['content-type'] + Maze.check.match(expected, actual) +end + When('I clear the Bugsnag cache') do case Maze::Helper.get_current_platform when 'macos', 'webgl' @@ -151,18 +157,33 @@ def check_error_reporting_api(notifier_name) stacktrace = Maze::Helper.read_key_path(Maze::Server.errors.current[:body], 'events.0.exceptions.0.stacktrace') expected_frame_values = expected_values.raw - flunk('The stacktrace is empty') if stacktrace.length == 0 + flunk('The stacktrace is empty') if stacktrace.empty? + # Extract just the method names from the stacktrace methods = stacktrace.map { |item| item['method'] } + # For each set of expected frames, check if at least one method matches expected_frame_values.each do |expected_frames| method_index = 0 frame_matches = false + + # Keep iterating over `methods` until we find a match or exhaust all until frame_matches || method_index.eql?(methods.size) method = methods[method_index] - frame_matches = expected_frames.any? { |frame| frame == method } + + # Sanitize the actual method to ignore any numeric portion in 'd__' + sanitized_method = method.gsub(/d__\d+/, 'd__REPLACEMENT') + + # Check each expected frame for a match by also sanitizing it + frame_matches = expected_frames.any? do |frame| + sanitized_frame = frame.gsub(/d__\d+/, 'd__REPLACEMENT') + sanitized_method == sanitized_frame + end + method_index += 1 end + + # Fail if we didn't find a match for this set of expected frames Maze.check.true(frame_matches, "None of the methods match the expected frames #{expected_frames}") end end diff --git a/features/support/env.rb b/features/support/env.rb index ded754708..343e58aed 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -18,6 +18,14 @@ end end +Before('@unity_2020_only') do + if ENV['UNITY_VERSION'] + unity_version = ENV['UNITY_VERSION'][0..3].to_i + if unity_version != 2020 + skip_this_scenario('Skipping scenario, this scenario is only for Unity 2020') + end + end +end Before('@skip_webgl') do |_scenario| skip_this_scenario('Skipping scenario') unless Maze.config.browser.nil? @@ -180,7 +188,9 @@ AfterAll do case Maze::Helper.get_current_platform when 'macos' - app_name = Maze.config.app.gsub /\.app$/, '' - Maze::Runner.run_command("log show --predicate '(process == \"#{app_name}\")' --style syslog --start '#{Maze.start_time}' > #{app_name}.log") + if !Maze.config.app.nil? + app_name = Maze.config.app.gsub /\.app$/, '' + Maze::Runner.run_command("log show --predicate '(process == \"#{app_name}\")' --style syslog --start '#{Maze.start_time}' > #{app_name}.log") + end end end