Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Updated Android debug symbol upload #1995

Merged
merged 8 commits into from
Feb 10, 2025

Conversation

bitsandfoxes
Copy link
Contributor

@bitsandfoxes bitsandfoxes commented Jan 28, 2025

Working on improving CI last week had me scratch my head with what's going on with out build logs when targeting Android. Same while dogfooding sentry-defenses today.

Missing logs in CI

In CI, when Android builds fail, the gradle build logs would point me towards a logfile (that obviously was not getting uploaded). Breaking builds with no logs is a complete waste of time.

Cause

We're exclusively pipe the logs into a logfile to have them available for diagnostics outside of the editor console.

Fix

Using the TeeOutputStream we can still write to the logfile - to have it available during trouble shooting outside of running the editor - and still leave the gradle build logs intact.

We can also remove the PostBuildCheck that validated the CLI logs and now we don't need to unnecessarily dump the logs in the editor console. Because we're leaving the build logs intact, Unity correctly picks up the failed task and prints it for us. I.e. a build with an invalid auth-token:

Screenshot 2025-02-07 at 12 51 02

Replaced Ignore CLI Errors hackiness

We're providing a Ignore CLI Errors checkbox on the upload options that only applies to Android right now.

Cause

When this was added, Sentry CLI did not provide a --allow-failure yet and we've had numerous user reporting their builds getting stuck in CI with no way forward. We've wrapped the upload exec in a try-catch and validated the output by parsing the logfile.

Fix

We're getting rid of the try-catch and pass the --allow-failure flag to the exec instead. This makes the task a lot less complex and easier to reason. Additionally, we've logging a big fat warning when users are using this flag as it's potentially a mayor footgun.

The new gradle task for uploading debug symbols and proguard mappings looks like this:

// Autogenerated Sentry symbol upload task [start]
// Credentials and project settings information are stored in the sentry.properties file
afterEvaluate {
task sentryUploadSymbols {
    doLast {
        println 'Uploading symbols to Sentry.'
        def logFilePath = '/Users/bitfox/Workspace/sentry-unity/samples/unity-of-bugs/Logs/sentry-symbols-upload.log'
        def sentryLogFile = new FileOutputStream(logFilePath)
        def outputStream = new org.apache.tools.ant.util.TeeOutputStream(System.out, sentryLogFile)
        def errorStream = new org.apache.tools.ant.util.TeeOutputStream(System.err, sentryLogFile)
        exec {
            environment 'SENTRY_PROPERTIES', './sentry.properties'
            executable '/Users/bitfox/Workspace/sentry-unity/package-dev/Editor/sentry-cli/sentry-cli-Darwin-universal'
            args = ['debug-files', 'upload', '--il2cpp-mapping', '/Users/bitfox/Workspace/sentry-unity/samples/unity-of-bugs/Library/Bee/artifacts/Android', '/Users/bitfox/Workspace/sentry-unity/samples/unity-of-bugs/Library/Bee/Android']
            standardOutput outputStream
            errorOutput errorStream
        }
        println 'Uploading mapping file to Sentry.'
        def mappingLogFilePath = '/Users/bitfox/Workspace/sentry-unity/samples/unity-of-bugs/Logs/sentry-mapping-upload.log'
        def mappingLogFile = new FileOutputStream(mappingLogFilePath)
        def mappingOutputStream = new org.apache.tools.ant.util.TeeOutputStream(System.out, mappingLogFile)
        def mappingErrorStream = new org.apache.tools.ant.util.TeeOutputStream(System.err, mappingLogFile)
        exec {
            environment 'SENTRY_PROPERTIES', './sentry.properties'
            executable '/Users/bitfox/Workspace/sentry-unity/package-dev/Editor/sentry-cli/sentry-cli-Darwin-universal'
            args = ['upload-proguard', '/Users/bitfox/Workspace/sentry-unity/samples/unity-of-bugs/Library/Bee/Android/Prj/IL2CPP/Gradle/launcher/build/outputs/mapping/release/mapping.txt']
            standardOutput mappingOutputStream
            errorOutput mappingErrorStream
        }
    }
}

tasks.assembleDebug.finalizedBy sentryUploadSymbols
tasks.assembleRelease.finalizedBy sentryUploadSymbols
tasks.bundleDebug.finalizedBy sentryUploadSymbols
tasks.bundleRelease.finalizedBy sentryUploadSymbols
}
// Autogenerated Sentry symbol upload task [end]

@bitsandfoxes bitsandfoxes changed the title fix: Android debug symbol upload logging fix: Updated Android debug symbol upload Feb 7, 2025
@bitsandfoxes bitsandfoxes marked this pull request as ready for review February 7, 2025 15:40
@bitsandfoxes bitsandfoxes requested a review from vaind February 7, 2025 15:52
@bitsandfoxes bitsandfoxes merged commit 25a73d6 into main Feb 10, 2025
31 checks passed
@bitsandfoxes bitsandfoxes deleted the fix/android-symbol-upload-logging branch February 10, 2025 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants