Skip to content

Commit

Permalink
auto symbol upload testing (#870)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardelms authored Jan 21, 2025
1 parent a639498 commit 6eb44bc
Show file tree
Hide file tree
Showing 21 changed files with 280 additions and 182 deletions.
36 changes: 6 additions & 30 deletions .buildkite/unity.2020.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "*"
Expand All @@ -30,46 +30,22 @@ 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
plugins:
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: "*"
Expand Down
39 changes: 6 additions & 33 deletions .buildkite/unity.2021.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "*"
Expand All @@ -54,22 +30,19 @@ 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"
plugins:
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: "*"
Expand Down
36 changes: 6 additions & 30 deletions .buildkite/unity.2022.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "*"
Expand All @@ -51,22 +30,19 @@ 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"
plugins:
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: "*"
Expand Down
36 changes: 6 additions & 30 deletions .buildkite/unity.6000.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "*"
Expand All @@ -51,22 +30,19 @@ 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"
plugins:
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: "*"
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ upm/UPMImportProject/Library
upm-package
upm/UPMImportProject/.vscode
UPMImportProject.sln
!features/build/

16 changes: 8 additions & 8 deletions Bugsnag/Assets/Bugsnag/Editor/SymbolUpload/BugsnagCLI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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}";

Expand All @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -34,7 +37,7 @@ public void OnPostprocessBuild(BuildReport report)
return;
}

var config = BugsnagSettingsObject.GetSettingsObject();
var config = BugsnagSettingsObject.LoadBuildTimeSettingsObject();
if (config == null || !config.AutoUploadSymbols)
{
return;
Expand All @@ -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)
{
Expand All @@ -63,22 +67,24 @@ 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())
{
Debug.LogError("Cannot upload Android symbols to BugSnag because Android symbol creation is disabled in the Unity Build Settings.");
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
Expand Down Expand Up @@ -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
Expand All @@ -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("<CLI_COMMAND>", command);
}
}
Expand Down
Loading

0 comments on commit 6eb44bc

Please sign in to comment.