bugsnag / bugsnag-dsym-upload

Scripts and Fastlane tasks for uploading dSYM files to BugSnag
https://docs.bugsnag.com/build-integrations/fastlane/
MIT License
36 stars 13 forks source link

fix(cli tool): Check for 0 byte dSYM file, and throw a warning if found #52

Closed xljones closed 3 years ago

xljones commented 3 years ago

Goal

Due to an (unconfirmed) bug in Xcode (https://developer.apple.com/forums/thread/659187), 0 byte dSYMs can be generated by Xcode. These show up as filename.dSYM files rather than dirname.dSYM directories (which contain the DWARF data of interest, normally).

Design

Changeset

Further consideration

Testing

CLI

Manually tested with 4 different dSYM folders:

1 file(s) uploaded successfully

Checking exit code of last command run (expecting `0`):

echo $? 0


* `dsym_test_warning`: contains one dSYM file that's 0 bytes

$ ./bugsnag-dsym-upload --verbose --api-key 0c0ea7242a829310a625f599db2e5752 ./dsyms_test_warning Uploading files to https://upload.bugsnag.com Preparing to upload ./dsyms_test_warning/REDACTED.framework.ios-x86_64-maccatalyst.dSYM Skipping ./dsyms_test_warning/REDACTED.framework.ios-x86_64-maccatalyst.dSYM as it's is a file (0 bytes), not a directory with DWARF data 1 file(s) failed to upload with warnings Re-run the bugsnag-dsym-upload tool with the --verbose option for more information

Checking exit code of last command run (expecting `0`):

echo $? 0


* `dsym_test_error`: contains one dSYM with DWARF data removed (manually deleted)

$ ./bugsnag-dsym-upload --verbose --api-key 0c0ea7242a829310a625f599db2e5752 ./dsyms_test_error
Uploading files to https://upload.bugsnag.com Preparing to upload ./dsyms_test_error/bugsnag-example.app.dSYM Skipping file without UUID: ./dsyms_test_error/bugsnag-example.app.dSYM/Contents/Resources/DWARF/* 1 file(s) failed to upload with errors Re-run the bugsnag-dsym-upload tool with the --verbose option for more information

Checking exit code of last command run (expecting `1`):

echo $? 1


* `dsym_test`: contains 3 dSYMS from each of the directories above

$ ./bugsnag-dsym-upload --verbose --api-key 0c0ea7242a829310a625f599db2e5752 ./dsyms_test
Uploading files to https://upload.bugsnag.com Preparing to upload ./dsyms_test/Bugsnag.framework.dSYM Uploading UUID: E599CF69-D848-3ED2-9093-68A44234CFCF (armv7) ./dsyms_test/Bugsnag.framework.dSYM/Contents/Resources/DWARF/Bugsnag UUID: 40112A5E-4A23-37EC-9A5D-95AF2C18AE39 (arm64) ./dsyms_test/Bugsnag.framework.dSYM/Contents/Resources/DWARF/Bugsnag

Preparing to upload ./dsyms_test/REDACTED.framework.ios-x86_64-maccatalyst.dSYM Skipping ./dsyms_test/REDACTED.framework.ios-x86_64-maccatalyst.dSYM as it's is a file (0 bytes), not a directory with DWARF data Preparing to upload ./dsyms_test/bugsnag-example.app.dSYM Skipping file without UUID: ./dsyms_test/bugsnag-example.app.dSYM/Contents/Resources/DWARF/* 1 file(s) uploaded successfully 1 file(s) failed to upload with warnings 1 file(s) failed to upload with errors Re-run the bugsnag-dsym-upload tool with the --verbose option for more information

Checking exit code of last command run  (expecting `1`):

echo $? 1


### Fastlane

This change affects Fastlane as the exit code is being manipulated. Using the same directories as above, and pointing the `Fastfile` to each directory independently:

* `dsym_test_ok`: contains one dSYM with known acceptable DWARF data

$ bundle exec fastlane ios release --verbose ... DEBUG [2021-04-06 15:41:45.63]: Uploading dSYMs to Bugsnag with the following parameters: DEBUG [2021-04-06 15:41:45.63]: api_key: 0c0ea7242a829310a625f599db2e5752 DEBUG [2021-04-06 15:41:45.63]: dsym_path: ["./dsyms_test_ok"] ... Uploading files to https://upload.bugsnag.com Preparing to upload ./dsyms_test_ok/Bugsnag.framework.dSYM Uploading UUID: E599CF69-D848-3ED2-9093-68A44234CFCF (armv7) ./dsyms_test_ok/Bugsnag.framework.dSYM/Contents/Resources/DWARF/Bugsnag UUID: 40112A5E-4A23-37EC-9A5D-95AF2C18AE39 (arm64) ./dsyms_test_ok/Bugsnag.framework.dSYM/Contents/Resources/DWARF/Bugsnag

1 file(s) uploaded successfully INFO [2021-04-06 15:41:48.21]: Uploaded dSYMs in ./dsyms_test_ok ... INFO [2021-04-06 15:41:48.21]: fastlane.tools finished successfully πŸŽ‰ DEBUG [2021-04-06 15:41:48.21]: All plugins are up to date


* `dsym_test_warning`: contains one dSYM file that's 0 bytes

$ bundle exec fastlane ios release --verbose ... DEBUG [2021-04-06 15:43:57.28]: Uploading dSYMs to Bugsnag with the following parameters: DEBUG [2021-04-06 15:43:57.28]: api_key: 0c0ea7242a829310a625f599db2e5752 DEBUG [2021-04-06 15:43:57.28]: dsym_path: ["./dsyms_test_warning"] ... Uploading files to https://upload.bugsnag.com Preparing to upload ./dsyms_test_warning/REDACTED.framework.ios-x86_64-maccatalyst.dSYM [WARNING] Skipping ./dsyms_test_warning/REDACTED.framework.ios-x86_64-maccatalyst.dSYM as it's is a file (0 bytes), not a directory with DWARF data 1 file(s) failed to upload with warnings Re-run the bugsnag-dsym-upload tool with the --verbose option for more information ... INFO [2021-04-06 15:43:57.30]: fastlane.tools finished successfully πŸŽ‰


* `dsym_test_error`: contains one dSYM with DWARF data removed (manually deleted)

$ bundle exec fastlane ios release --verbose ... DEBUG [2021-04-06 15:47:12.39]: Uploading dSYMs to Bugsnag with the following parameters: DEBUG [2021-04-06 15:47:12.39]: api_key: 0c0ea7242a829310a625f599db2e5752 DEBUG [2021-04-06 15:47:12.39]: dsym_path: ["./dsyms_test_error"] ... Uploading files to https://upload.bugsnag.com Preparing to upload ./dsyms_test_error/bugsnag-example.app.dSYM [ERROR] Skipping file without UUID: ./dsyms_test_error/bugsnag-example.app.dSYM/Contents/Resources/DWARF/* 1 file(s) failed to upload with errors Re-run the bugsnag-dsym-upload tool with the --verbose option for more information ... ERROR [2021-04-06 15:47:12.41]: Failed uploading ./dsyms_test_error ... FastlaneCore::Interface::FastlaneError: [!] Failed uploading ./dsyms_test_error


* `dsym_test`: contains 3 dSYMS from each of the directories above

$ bundle exec fastlane ios release --verbose ... DEBUG [2021-04-06 15:50:34.36]: Uploading dSYMs to Bugsnag with the following parameters: DEBUG [2021-04-06 15:50:34.36]: api_key: 0c0ea7242a829310a625f599db2e5752 DEBUG [2021-04-06 15:50:34.36]: dsym_path: ["./dsyms_test"] ... Uploading files to https://upload.bugsnag.com Preparing to upload ./dsyms_test/Bugsnag.framework.dSYM Uploading UUID: E599CF69-D848-3ED2-9093-68A44234CFCF (armv7) ./dsyms_test/Bugsnag.framework.dSYM/Contents/Resources/DWARF/Bugsnag UUID: 40112A5E-4A23-37EC-9A5D-95AF2C18AE39 (arm64) ./dsyms_test/Bugsnag.framework.dSYM/Contents/Resources/DWARF/Bugsnag

Preparing to upload ./dsyms_test/REDACTED.framework.ios-x86_64-maccatalyst.dSYM [WARNING] Skipping ./dsyms_test/REDACTED.framework.ios-x86_64-maccatalyst.dSYM as it's is a file (0 bytes), not a directory with DWARF data Preparing to upload ./dsyms_test/bugsnag-example.app.dSYM [ERROR] Skipping file without UUID: ./dsyms_test/bugsnag-example.app.dSYM/Contents/Resources/DWARF/* 1 file(s) uploaded successfully 1 file(s) failed to upload with warnings 1 file(s) failed to upload with errors Re-run the bugsnag-dsym-upload tool with the --verbose option for more information ... FastlaneCore::Interface::FastlaneError: [!] Failed uploading ./dsyms_test

xljones commented 3 years ago

Closing PR to perform changes, and then re-PR with all changes on one branch for consistency.