Skip to content

Commit

Permalink
Use a Sentry release
Browse files Browse the repository at this point in the history
Contribute to CURA-11482
  • Loading branch information
jellespijker committed Jan 11, 2024
1 parent 170345f commit 84e9a07
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 13 additions & 4 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from conan.tools.files import copy, mkdir, update_conandata
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.tools.scm import Version, Git
from conans.errors import ConanInvalidSystemRequirements

required_conan_version = ">=1.58.0 <2.0.0"
Expand Down Expand Up @@ -47,7 +47,8 @@ def set_version(self):
self.version = self.conan_data["version"] + build_meta

def export(self):
update_conandata(self, {"version": self.version})
git = Git(self)
update_conandata(self, {"version": self.version, "commit": git.get_commit()})

def export_sources(self):
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
Expand Down Expand Up @@ -163,17 +164,25 @@ def build(self):
cmake.build()

if self.options.get_safe("enable_sentry", False):
# Upload debug symbols to sentry
sentry_project = self.conf.get("user.curaengine:sentry_project", "", check_type=str)
if sentry_project == "":
raise ConanInvalidConfiguration("sentry_project is not set")
output = StringIO()
self.run(f"sentry-cli -V", output=output)
if "sentry-cli" not in output.getvalue():
raise ConanInvalidSystemRequirements("sentry-cli is not installed")
self.output.info("Uploading debug symbols to sentry")
ext = ".exe" if self.settings.os == "Windows" else ""
self.run(f"sentry-cli debug-files upload --include-sources ../../ -o {sentry_project} -p curaengine CuraEngine{ext}")
self.run(f"sentry-cli debug-files upload --include-sources {self.source_folder} -o {sentry_project} -p curaengine CuraEngine{ext}")
if self.settings.os == "Windows" and self.settings.build_type == "RelWithDebInfo":
self.run(f"sentry-cli upload-dif --include-sources ../../ -o {sentry_project} -p curaengine CuraEngine.pdb")
self.run(f"sentry-cli upload-dif --include-sources {self.build_folder} -o {sentry_project} -p curaengine CuraEngine.pdb")

# create a sentry release and link it to the commit this is based upon
self.output.info(f"Creating a new release {self.version} in Sentry and linking it to the current commit {self.conan_data['commit']}")
self.run(f"sentry-cli releases new -o {sentry_project} -p curaengine {self.version}")
self.run(f"sentry-cli releases set-commits -o {sentry_project} -p curaengine --commit \"Ultimaker/CuraEngine@{self.conan_data['commit']}\" {self.version}")
self.run(f"sentry-cli releases finalize -o {sentry_project} -p curaengine {self.version}")

def package(self):
ext = ".exe" if self.settings.os == "Windows" else ""
Expand Down
4 changes: 3 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 UltiMaker
// Copyright (c) 2024 UltiMaker
// CuraEngine is released under the terms of the AGPLv3 or higher

#include <iostream> //To change the formatting of std::cerr.
Expand Down Expand Up @@ -93,6 +93,7 @@ int main(int argc, char** argv)

// Set the actual CuraEngine version
sentry_options_set_release(options, fmt::format("curaengine@{}", cura_engine_version).c_str());
spdlog::info("Starting sentry");
sentry_init(options);
}
#endif
Expand All @@ -102,6 +103,7 @@ int main(int argc, char** argv)
#ifdef SENTRY_URL
if (const auto use_sentry = spdlog::details::os::getenv("use_sentry"); ! use_sentry.empty() && use_sentry == "1")
{
spdlog::info("Closing sentry");
sentry_close();
}
#endif
Expand Down

0 comments on commit 84e9a07

Please sign in to comment.