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

Add debug symbols upload #59

Merged
merged 30 commits into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d7eb257
Add CLI tools
tustanivsky Aug 9, 2022
4d7e4f9
Add debug symbols upload for iOS, Mac and Linux
tustanivsky Aug 9, 2022
38d5f0a
Add debug symbols upload script for Windows
tustanivsky Aug 10, 2022
fd2267b
Fix errors with debug symbols upload on Linux
tustanivsky Aug 11, 2022
7733ae7
Remove redundant script
tustanivsky Aug 16, 2022
22e4db0
Update location of symbols upload scripts
tustanivsky Aug 16, 2022
7023aea
Update .gitignore
tustanivsky Aug 16, 2022
6e7930a
Fix packaging issue on Linux
tustanivsky Aug 16, 2022
4e94707
Add plugin binaries symbols upload
tustanivsky Aug 17, 2022
efb1f73
Merge branch 'main' into feature/debug-symbols-upload
tustanivsky Aug 18, 2022
fdb6571
Remove Sentry CLI binaries
tustanivsky Aug 18, 2022
9e9b91f
Fix download script
tustanivsky Aug 18, 2022
414a8fa
Fix workflow
tustanivsky Aug 18, 2022
ebd3620
Fix script name
tustanivsky Aug 18, 2022
6dffe37
Fix workflow once again
tustanivsky Aug 18, 2022
83670c4
Fix empty line
tustanivsky Aug 18, 2022
af65898
Fix typo
tustanivsky Aug 18, 2022
c8a69b0
Fix CLI pathj
tustanivsky Aug 18, 2022
16058cf
Remo redundant message
tustanivsky Aug 18, 2022
9281127
Fix CLI download sript
tustanivsky Aug 19, 2022
e7ca053
Remo user credentials for debug symbols upload from plugin settings
tustanivsky Aug 19, 2022
5a91498
Update debug symbols upload script for win
tustanivsky Aug 19, 2022
eeebbe1
Fix regex
tustanivsky Aug 19, 2022
0c3d486
Update changelog
tustanivsky Aug 19, 2022
9ed8deb
Merge branch 'main' into feature/debug-symbols-upload
tustanivsky Aug 19, 2022
3a0d8a1
Merge branch 'main' into feature/debug-symbols-upload
vaind Aug 19, 2022
42bc2f3
chore: rename cli download script
vaind Aug 19, 2022
fc428cd
use sentry.properties as a relative path
vaind Aug 19, 2022
231dff6
fix: android debug symbol upload
vaind Aug 19, 2022
4fa854f
Fix issue with reading sentry.properties file path from settings on Mac
tustanivsky Aug 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
*.ipa

# Binary Files
Binaries/*
plugin-dev/Binaries/*

# Compiled source files for the engine to use
Intermediate/*
plugin-dev/Intermediate/*

# Other
.DS_Store
2 changes: 2 additions & 0 deletions plugin-dev/Config/FilterPlugin.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
; /README.txt
; /Extras/...
; /Binaries/ThirdParty/*.dll

/Scripts/...
90 changes: 90 additions & 0 deletions plugin-dev/Scripts/upload-debug-symbols-win.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
param([string] $TargetPlatform,[string] $TargetName,[string] $TargetType,[string] $ProjectPath,[string] $PluginPath)

$ProjectBinariesPath = "$ProjectPath\Binaries\$TargetPlatform"
$PluginBinariesPath = "$PluginPath\Source\ThirdParty\$TargetPlatform"
$ConfigPath = "$ProjectPath\Config"

Write-Host "Sentry: Start debug symbols upload"

If ($TargetType -eq "Editor")
{
Write-Host "Sentry: Automatic symbols upload is not required for Editor target. Terminating..."
Exit
}

If ($TargetPlatform -eq "Win64")
{
Set-Variable -Name "CliExec" -Value "$PluginPath\Source\ThirdParty\CLI\sentry-cli-Windows-x86_64.exe"
}
Else
{
Write-Host "Sentry: Unexpected platform $TargetPlatform. Terminating..."
Exit
}

function ParseIniFile
{
param([parameter(Mandatory = $true)] [string] $filePath)

$anonymous = "NoSection"

$ini = @{}
switch -regex -file $filePath
{
"^\[(.+)\]$" # Section
{
$section = $matches[1]
$ini[$section] = @{}
$CommentCount = 0
}

"^(;.*)$" # Comment
{
if (!($section))
{
$section = $anonymous
$ini[$section] = @{}
}
$value = $matches[1]
$CommentCount = $CommentCount + 1
$name = "Comment" + $CommentCount
$ini[$section][$name] = $value
}

"(.+?)\s*=\s*(.*)" # Key
{
if (!($section))
{
$section = $anonymous
$ini[$section] = @{}
}
$name,$value = $matches[1..2]
$ini[$section][$name] = $value
}
}

return $ini
}

$ConfigIni = ParseIniFile "$ConfigPath\DefaultEngine.ini"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file normally under version control? If so, we shouldn't use it for sentry CLI configuration (a.k.a sentry.properties) as that's supposed to be excluded from git due to the auth-token.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, DefaultEngine.ini is an essential part of any UE project that keeps all of its settings (including plugins) and usually it's under source control. Though I don't think it can cause any issues for plugin users since they are likely to take care of securing their project config files. Or did I get it wrong?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if it's in a private repo, unless it's a single-person project, it's best not to commit auth tokens into source control. Additionally, this disqualifies any open-source games.

Copy link
Collaborator

@vaind vaind Aug 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest sticking to a single sentry.propertiies file, regardless of the platform

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have the exact same issue with Unity then? AFAIK there auth token is stored in a separate asset (SentryCliOptions scriptible object) which apparently could be a part of the game as well

Copy link
Collaborator

@vaind vaind Aug 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we use the sentry.properties file on windows without an issue with Unity

Copy link
Collaborator

@vaind vaind Aug 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Practical illustration why we shouldn't store the settings in the same file as everything else - from the in-repo sample PR (#64):

image

How can we move that to a different location so the "shared" file doesn't change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we move that to a different location so the "shared" file doesn't change?

We can replace user credentials here with a path to sentry.properties file which won't be publicly accessible. Later we can add some editor tool that will automate the creation of this file. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, no more user credentials in DefaultEngine.ini. Now in order to obtain auth token and other stuff for Sentry CLI path to sentry.properties file has to be provided firs. Apparently not an ideal solution since it may vary on different machines, though at least we've removed the risk of compromising sensitive data

$SentrySettingsSection = "/Script/Sentry.SentrySettings"

$UploadSymbols = $ConfigIni.$SentrySettingsSection.UploadSymbolsAutomatically

If (("$UploadSymbols" -eq "") -or ("$UploadSymbols" -eq "False"))
{
Write-Host "Sentry: Automatic symbols upload is disabled in plugin settings. Terminating..."
Exit
}

Write-Host "Sentry: Parse project settings"

$SentryProjectName = $ConfigIni.$SentrySettingsSection.ProjectName
$SentryProjectOrg = $ConfigIni.$SentrySettingsSection.OrganisationName
$SentryAuthToken = $ConfigIni.$SentrySettingsSection.AuthToken

Write-Host "Sentry: Upload started"

& $CliExec upload-dif --include-sources --log-level info --org $SentryProjectOrg --project $SentryProjectName --auth-token $SentryAuthToken $ProjectBinariesPath $PluginBinariesPath

Write-Host "Sentry: Upload finished"
58 changes: 58 additions & 0 deletions plugin-dev/Scripts/upload-debug-symbols.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

export targetPlatform=$1
export targetName=$2
export targetType=$3
export projectPath=$4
export pluginPath=$5

PROJECT_BINARIES_PATH=$projectPath/Binaries/$targetPlatform
PLUGIN_BINARIES_PATH=$pluginPath/Source/ThirdParty/$targetPlatform
CONFIG_PATH=$projectPath/Config

echo "Sentry: Start debug symbols upload"

if [ $targetType = "Editor" ]; then
echo "Sentry: Automatic symbols upload is not required for Editor target. Terminating..."
exit
fi

if [ $targetPlatform = "IOS" ] || [ $targetPlatform = "Mac" ]; then
SENTRY_CLI_EXEC=$pluginPath/Source/ThirdParty/CLI/sentry-cli-Darwin-universal
elif [ $targetPlatform = "Linux" ]; then
SENTRY_CLI_EXEC=$pluginPath/Source/ThirdParty/CLI/sentry-cli-Linux-x86_64
else
echo "Sentry: Unexpected platform ${targetPlatform}. Terminating..."
exit
fi

UPLOAD_SYMBOLS=$(awk -F "=" '/UploadSymbolsAutomatically/ {print $2}' ${CONFIG_PATH}/DefaultEngine.ini)

if [ -z $UPLOAD_SYMBOLS ]; then
echo "Sentry: Automatic symbols upload is disabled in plugin settings. Terminating..."
exit
fi

if [ $UPLOAD_SYMBOLS != "True" ]; then
echo "Sentry: Automatic symbols upload is disabled in plugin settings. Terminating..."
exit
fi

echo "Sentry: parse project settings"

PROJECT_NAME=$(awk -F "=" '/ProjectName/ {print $2}' ${CONFIG_PATH}/DefaultEngine.ini)
ORG_NAME=$(awk -F "=" '/OrganisationName/ {print $2}' ${CONFIG_PATH}/DefaultEngine.ini)
AUTH_TOKEN=$(awk -F "=" '/AuthToken/ {print $2}' ${CONFIG_PATH}/DefaultEngine.ini)

echo "Sentry: Copy user credentials config file template to home directory"
cp $pluginPath/Resources/sentry.properties $PROJECT_BINARIES_PATH/sentry.properties

sed -i.backup 's/your-project/'$PROJECT_NAME'/g' $PROJECT_BINARIES_PATH/sentry.properties
sed -i.backup 's/your-org/'$ORG_NAME'/g' $PROJECT_BINARIES_PATH/sentry.properties
sed -i.backup 's/YOUR_AUTH_TOKEN/'$AUTH_TOKEN'/g' $PROJECT_BINARIES_PATH/sentry.properties

export SENTRY_PROPERTIES=$PROJECT_BINARIES_PATH/sentry.properties

chmod +x $SENTRY_CLI_EXEC

$SENTRY_CLI_EXEC upload-dif --include-sources $PROJECT_BINARIES_PATH $PLUGIN_BINARIES_PATH
14 changes: 13 additions & 1 deletion plugin-dev/Sentry.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,17 @@
"LoadingPhase": "Default",
"WhitelistPlatforms": [ "Win64", "Mac", "Android", "IOS", "Linux" ]
}
]
],
"PostBuildSteps":
{
"Mac": [
"sh $(PluginDir)/Scripts/upload-debug-symbols.sh $(TargetPlatform) $(TargetName) $(TargetType) $(ProjectDir) $(PluginDir)"
],
"Linux": [
"sh $(PluginDir)/Scripts/upload-debug-symbols.sh $(TargetPlatform) $(TargetName) $(TargetType) $(ProjectDir) $(PluginDir)"
],
"Win64": [
"powershell -ExecutionPolicy RemoteSigned -File $(PluginDir)/Scripts/upload-debug-symbols-win.ps1 $(TargetPlatform) $(TargetName) $(TargetType) $(ProjectDir) $(PluginDir)"
]
}
}
tustanivsky marked this conversation as resolved.
Show resolved Hide resolved
Binary file not shown.
Binary file not shown.
Binary file not shown.