Skip to content

Commit

Permalink
feat: enable symsrv uploads for dSYMs (#96)
Browse files Browse the repository at this point in the history
* feat: enable symsrv uploads for dSYMs

* fix: use dwarf file name as module name

Fixes #86
  • Loading branch information
bobbyg603 authored Feb 14, 2024
1 parent 9c95888 commit 2cf4654
Show file tree
Hide file tree
Showing 33 changed files with 629 additions and 16 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"start": "ts-node -r dotenv/config ./bin/index.ts -d ./dist -f \"**/*.js.map\"",
"start:sym": "ts-node -r dotenv/config ./bin/index.ts -d ./spec -f \"**/*.sym\"",
"start:pdb": "ts-node -r dotenv/config ./bin/index.ts -d ./spec -f \"**/*.+(exe|dll|pdb)\"",
"start:dsym": "ts-node -r dotenv/config ./bin/index.ts -d ./spec -f \"**/*.dSYM\" -a BugSplatTester -v \"1.0 (1)\"",
"start:dsym": "ts-node -r dotenv/config ./bin/index.ts -d ./spec/support -f \"*.dSYM\" -a BugSplatTester -v \"1.0 (1)\"",
"start:xcarchive": "ts-node -r dotenv/config ./bin/index.ts -d ./spec/support -f \"*.xcarchive/**/*.dSYM\" -v \"4.5.6 (1)\"",
"test": "ts-node node_modules/jasmine/bin/jasmine",
"help": "ts-node ./bin/index.ts -h",
"clean": "rimraf ./dist",
Expand Down
12 changes: 6 additions & 6 deletions spec/dsym.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ describe('dsym', () => {
it('should return path, relativePath, dbgIds, module names for macho files', () => {
return expectAsync(getDSymFileInfos('spec/support/bugsplat.app.dSYM')).toBeResolvedTo(jasmine.arrayContaining([
{
path: jasmine.stringContaining('/symbol-upload/tmp/2dd1bd2706fa384da5a3a8265921cf9a/bugsplat'),
relativePath: '2dd1bd2706fa384da5a3a8265921cf9a/bugsplat',
path: jasmine.stringContaining('/symbol-upload/tmp/2dd1bd2706fa384da5a3a8265921cf9a/BugsplatTester'),
relativePath: '2dd1bd2706fa384da5a3a8265921cf9a/BugsplatTester',
dbgId: '2dd1bd2706fa384da5a3a8265921cf9a',
moduleName: 'bugsplat',
moduleName: 'BugsplatTester',
},
{
path: jasmine.stringContaining('/Users/bobby/Desktop/bugsplat/symbol-upload/tmp/2ce192f6c5963e66b06aa22bde5756a0/bugsplat'),
relativePath: '2ce192f6c5963e66b06aa22bde5756a0/bugsplat',
path: jasmine.stringContaining('/Users/bobby/Desktop/bugsplat/symbol-upload/tmp/2ce192f6c5963e66b06aa22bde5756a0/BugsplatTester'),
relativePath: '2ce192f6c5963e66b06aa22bde5756a0/BugsplatTester',
dbgId: '2ce192f6c5963e66b06aa22bde5756a0',
moduleName: 'bugsplat',
moduleName: 'BugsplatTester',
}
]));
});
Expand Down
34 changes: 34 additions & 0 deletions spec/support/bugsplat.xcarchive/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ApplicationProperties</key>
<dict>
<key>ApplicationPath</key>
<string>Applications/BugsplatTester.app</string>
<key>Architectures</key>
<array>
<string>x86_64</string>
<string>arm64</string>
</array>
<key>CFBundleIdentifier</key>
<string>com.bugsplat.BugsplatTester</string>
<key>CFBundleShortVersionString</key>
<string>4.5.6</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>SigningIdentity</key>
<string></string>
<key>Team</key>
<string></string>
</dict>
<key>ArchiveVersion</key>
<integer>2</integer>
<key>CreationDate</key>
<date>2024-02-12T21:52:50Z</date>
<key>Name</key>
<string>BugsplatTester</string>
<key>SchemeName</key>
<string>BugsplatTester</string>
</dict>
</plist>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>21G72</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>BugsplatMac</string>
<key>CFBundleIdentifier</key>
<string>com.bugsplat.BugsplatMac</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>BugsplatMac</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.1.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>14A400</string>
<key>DTPlatformName</key>
<string>macosx</string>
<key>DTPlatformVersion</key>
<string>12.3</string>
<key>DTSDKBuild</key>
<string>21E226</string>
<key>DTSDKName</key>
<string>macosx12.3</string>
<key>DTXcode</key>
<string>1401</string>
<key>DTXcodeBuild</key>
<string>14A400</string>
<key>LSMinimumSystemVersion</key>
<string>10.9</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Bugsplat. All rights reserved.</string>
</dict>
</plist>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#

LOG="/tmp/bugsplat-upload.log"

if [ ! -f "${HOME}/.bugsplat.conf" ]
then
echo "Missing bugsplat config file: ~/.bugsplat.conf" >> $LOG 2>&1
exit
fi

source "${HOME}/.bugsplat.conf"

if [ -z "${BUGSPLAT_USER}" ]
then
echo "BUGSPLAT_USER must be set in ~/.bugsplat.conf" >> $LOG 2>&1
exit
fi

if [ -z "${BUGSPLAT_PASS}" ]
then
echo "BUGSPLAT_PASS must be set in ~/.bugsplat.conf" >> $LOG 2>&1
exit
fi

DATE=$( /bin/date +"%Y-%m-%d" )
ARCHIVE_DIR="${HOME}/Library/Developer/Xcode/Archives/${DATE}"
ARCHIVE=$( /bin/ls -t "${ARCHIVE_DIR}" | /usr/bin/grep xcarchive | /usr/bin/sed -n 1p )

echo "Archive: ${ARCHIVE}" >> $LOG 2>&1

APP_DIR="${ARCHIVE_DIR}/${ARCHIVE}/Products/usr/local/bin"
APP="${APP_DIR}/${PRODUCT_NAME}"
echo "APP: ${APP}" >> $LOG 2>&1
pushd "${APP_DIR}"

INFO_PLIST="/tmp/${PRODUCT_NAME}-Info.plist"
rm ${INFO_PLIST}
otool -X -s __TEXT __info_plist ${PRODUCT_NAME} | sed 's/Contents.*//' | xxd -r >> $INFO_PLIST 2>&1

APP_MARKETING_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${INFO_PLIST}")
APP_BUNDLE_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFO_PLIST}")

echo "App marketing version: ${APP_MARKETING_VERSION}" >> $LOG 2>&1
echo "App bundle version: ${APP_BUNDLE_VERSION}" >> $LOG 2>&1

APP_VERSION="${APP_MARKETING_VERSION}"

if [ -n "${APP_BUNDLE_VERSION}" ]
then
APP_VERSION="${APP_VERSION} (${APP_BUNDLE_VERSION})"
fi

BUGSPLAT_SERVER_URL=$(/usr/libexec/PlistBuddy -c "Print BugsplatServerURL" "${INFO_PLIST}")
BUGSPLAT_SERVER_URL=${BUGSPLAT_SERVER_URL%/}

UPLOAD_URL="${BUGSPLAT_SERVER_URL}/post/plCrashReporter/symbol/"

echo "App version: ${APP_VERSION}" >> $LOG 2>&1
echo "Zipping ${ARCHIVE}" >> $LOG 2>&1

/bin/rm "/tmp/${PRODUCT_NAME}.xcarchive.zip"
cd "${ARCHIVE_DIR}/${ARCHIVE}"
/usr/bin/zip -r "/tmp/${PRODUCT_NAME}.xcarchive.zip" *
cd -

UUID_CMD_OUT=$(xcrun dwarfdump --uuid "${APP}")
UUID_CMD_OUT=$([[ "${UUID_CMD_OUT}" =~ ^(UUID: )([0-9a-zA-Z\-]+) ]] && echo ${BASH_REMATCH[2]})
echo "UUID found: ${UUID_CMD_OUT}" >> $LOG 2>&1

echo "Signing into bugsplat and storing session cookie for use in upload" >> $LOG 2>&1

COOKIEPATH="/tmp/bugsplat-cookie.txt"
rm "${COOKIEPATH}"
curl -b "${COOKIEPATH}" -c "${COOKIEPATH}" --data-urlencode "currusername=${BUGSPLAT_USER}" --data-urlencode "currpasswd=${BUGSPLAT_PASS}" "${BUGSPLAT_SERVER_URL}/browse/login.php"

echo "Uploading /tmp/${PRODUCT_NAME}.xcarchive.zip to ${UPLOAD_URL}" >> $LOG 2>&1

curl -i -b "${COOKIEPATH}" -c "${COOKIEPATH}" -F filedata=@"/tmp/${PRODUCT_NAME}.xcarchive.zip" -F appName="${PRODUCT_NAME}" -F appVer="${APP_VERSION}" -F buildId="${UUID_CMD_OUT}" $UPLOAD_URL >> $LOG 2>&1
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#

LOG="/tmp/bugsplat-upload.log"

if [ ! -f "${HOME}/.bugsplat.conf" ]
then
echo "Missing bugsplat config file: ~/.bugsplat.conf" >> $LOG 2>&1
exit
fi

source "${HOME}/.bugsplat.conf"

if [ -z "${BUGSPLAT_USER}" ]
then
echo "BUGSPLAT_USER must be set in ~/.bugsplat.conf" >> $LOG 2>&1
exit
fi

if [ -z "${BUGSPLAT_PASS}" ]
then
echo "BUGSPLAT_PASS must be set in ~/.bugsplat.conf" >> $LOG 2>&1
exit
fi

DATE=$( /bin/date +"%Y-%m-%d" )
ARCHIVE_DIR="${HOME}/Library/Developer/Xcode/Archives/${DATE}"
ARCHIVE=$( /bin/ls -t "${ARCHIVE_DIR}" | /usr/bin/grep xcarchive | /usr/bin/sed -n 1p )

echo "Archive: ${ARCHIVE}" > $LOG 2>&1

APP="${ARCHIVE_DIR}/${ARCHIVE}/Products/Applications/${PRODUCT_NAME}.app"
APP_MARKETING_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${APP}/Contents/Info.plist")
APP_BUNDLE_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${APP}/Contents/Info.plist")

echo "App marketing version: ${APP_MARKETING_VERSION}" >> $LOG 2>&1
echo "App bundle version: ${APP_BUNDLE_VERSION}" >> $LOG 2>&1

APP_VERSION="${APP_MARKETING_VERSION}"

if [ -n "${APP_BUNDLE_VERSION}" ]
then
APP_VERSION="${APP_VERSION} (${APP_BUNDLE_VERSION})"
fi

BUGSPLAT_SERVER_URL=$(/usr/libexec/PlistBuddy -c "Print BugsplatServerURL" "${APP}/Contents/Info.plist")
BUGSPLAT_SERVER_URL=${BUGSPLAT_SERVER_URL%/}

UPLOAD_URL="${BUGSPLAT_SERVER_URL}/post/plCrashReporter/symbol/"

echo "App version: ${APP_VERSION}" >> $LOG 2>&1
echo "Zipping ${ARCHIVE}" >> $LOG 2>&1

/bin/rm "/tmp/${PRODUCT_NAME}.xcarchive.zip"
cd "${ARCHIVE_DIR}/${ARCHIVE}"
/usr/bin/zip -r "/tmp/${PRODUCT_NAME}.xcarchive.zip" *
cd -

UUID_CMD_OUT=$(xcrun dwarfdump --uuid "${APP}/Contents/MacOS/${PRODUCT_NAME}")
UUID_CMD_OUT=$([[ "${UUID_CMD_OUT}" =~ ^(UUID: )([0-9a-zA-Z\-]+) ]] && echo ${BASH_REMATCH[2]})
echo "UUID found: ${UUID_CMD_OUT}" > $LOG 2>&1

echo "Signing into bugsplat and storing session cookie for use in upload" >> $LOG 2>&1

COOKIEPATH="/tmp/bugsplat-cookie.txt"
LOGIN_URL="${BUGSPLAT_SERVER_URL}/browse/login.php"
echo "Login URL: ${LOGIN_URL}"
rm "${COOKIEPATH}"
curl -b "${COOKIEPATH}" -c "${COOKIEPATH}" --data-urlencode "currusername=${BUGSPLAT_USER}" --data-urlencode "currpasswd=${BUGSPLAT_PASS}" "${LOGIN_URL}"

echo "Uploading /tmp/${PRODUCT_NAME}.xcarchive.zip to ${UPLOAD_URL}" >> $LOG 2>&1

curl -i -b "${COOKIEPATH}" -c "${COOKIEPATH}" -F filedata=@"/tmp/${PRODUCT_NAME}.xcarchive.zip" -F appName="${PRODUCT_NAME}" -F appVer="${APP_VERSION}" -F buildId="${UUID_CMD_OUT}" $UPLOAD_URL >> $LOG 2>&1
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BugsplatServerURL</key>
<string>https://bobby_testing_2.bugsplat.com/</string>
<key>BuildMachineOSBuild</key>
<string>23D56</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>BugsplatTester</string>
<key>CFBundleIdentifier</key>
<string>com.bugsplat.BugsplatTester</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>BugsplatTester</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>4.5.6</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string></string>
<key>DTPlatformName</key>
<string>macosx</string>
<key>DTPlatformVersion</key>
<string>14.2</string>
<key>DTSDKBuild</key>
<string>23C53</string>
<key>DTSDKName</key>
<string>macosx14.2</string>
<key>DTXcode</key>
<string>1520</string>
<key>DTXcodeBuild</key>
<string>15C500b</string>
<key>LSMinimumSystemVersion</key>
<string>10.13</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018 BugSplat. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APPL????
Binary file not shown.
Loading

0 comments on commit 2cf4654

Please sign in to comment.