From 7c84c297ed91f21d9047dfdec0112046281eedd3 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Fri, 12 Jan 2024 10:48:19 +0100 Subject: [PATCH 1/7] Publish Sentry debug-files Also updated the workflows to our new situation Contributes to CURA-11482 --- .github/workflows/conan-package.yml | 152 ++++-------------- .../workflows/requirements-conan-package.txt | 1 - .github/workflows/requirements-runner.txt | 0 conandata.yml | 1 + conanfile.py | 32 +++- 5 files changed, 57 insertions(+), 129 deletions(-) delete mode 100644 .github/workflows/requirements-conan-package.txt create mode 100644 .github/workflows/requirements-runner.txt create mode 100644 conandata.yml diff --git a/.github/workflows/conan-package.yml b/.github/workflows/conan-package.yml index ee36d113..212a49d5 100644 --- a/.github/workflows/conan-package.yml +++ b/.github/workflows/conan-package.yml @@ -1,155 +1,59 @@ ---- name: conan-package -# Exports the recipe, sources and binaries for Mac, Windows and Linux and upload these to the server such that these can -# be used downstream. -# -# It should run on pushes against main or CURA-* branches, but it will only create the binaries for main and release branches - on: - workflow_dispatch: - inputs: - # FIXME: Not yet implemented - conan_id: - required: false - type: string - description: 'The full conan package ID, e.g. "arcus/1.2.3@ultimaker/stable"' - create_latest_alias: - required: true - default: false - type: boolean - description: 'Create latest alias' - create_binaries_windows: - required: true - default: false - type: boolean - description: 'create binaries Windows' - create_binaries_linux: - required: true - default: false - type: boolean - description: 'create binaries Linux' - create_binaries_macos: - required: true - default: false - type: boolean - description: 'create binaries Macos' - - push: - paths: - - 'src/**' - - 'test_package/**' - - 'include/**' - - 'cmake/**' - - 'conanfile.py' - - 'CMakeLists.txt' - - '.github/workflows/conan-package.yml' - - '.github/workflows/requirements*' - - 'conandata.yml' - - '.gitattributes' - branches: - - 'main' - - 'CURA-*' - - '[1-9]+.[0-9]+' - tags: - - '[1-9]+.[0-9]+.[0-9]*' + push: + paths: + - 'src/**' + - 'test_package/**' + - 'include/**' + - 'cmake/**' + - 'conanfile.py' + - 'CMakeLists.txt' + - '.github/workflows/conan-package.yml' + - '.github/workflows/requirements*' + - 'conandata.yml' + - '.gitattributes' + branches: + - main + - 'CURA-*' + - 'PP-*' + - '[0-9].[0-9]*' + - '[0-9].[0-9][0-9]*' jobs: conan-recipe-version: - uses: ultimaker/cura/.github/workflows/conan-recipe-version.yml@main + uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-version.yml@main with: project_name: arcus conan-package-export: needs: [ conan-recipe-version ] - uses: ultimaker/cura/.github/workflows/conan-recipe-export.yml@main + uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-export.yml@main with: recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} recipe_id_latest: ${{ needs.conan-recipe-version.outputs.recipe_id_latest }} - runs_on: 'ubuntu-20.04' - python_version: '3.10.x' - conan_logging_level: 'info' - secrets: inherit - - conan-package-create-windows: - if: ${{ (github.event_name == 'push' && github.ref_name == 'main') || (github.event_name == 'workflow_dispatch' && inputs.create_binaries_windows) }} - needs: [ conan-recipe-version, conan-package-export ] - - uses: ultimaker/cura/.github/workflows/conan-package-create.yml@main - with: - project_name: ${{ needs.conan-recipe-version.outputs.project_name }} - recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} - build_id: 4 - runs_on: 'windows-2022' - python_version: '3.11.x' - conan_config_branch: '' - conan_logging_level: 'info' secrets: inherit conan-package-create-macos: - if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} needs: [ conan-recipe-version, conan-package-export ] - - uses: ultimaker/cura/.github/workflows/conan-package-create.yml@main + if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }} + uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-macos.yml@main with: - project_name: ${{ needs.conan-recipe-version.outputs.project_name }} recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} - build_id: 3 - runs_on: 'macos-11' - python_version: '3.11.x' - conan_logging_level: 'info' secrets: inherit - - conan-package-create-linux-modern: - if: ${{ (github.event_name == 'push' && github.ref_name == 'main') || (github.event_name == 'workflow_dispatch' && inputs.create_binaries_linux) }} - needs: [ conan-recipe-version, conan-package-export ] - uses: ultimaker/cura/.github/workflows/conan-package-create.yml@main + conan-package-create-windows: + needs: [ conan-recipe-version, conan-package-export ] + if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }} + uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-windows.yml@main with: - project_name: ${{ needs.conan-recipe-version.outputs.project_name }} recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} - build_id: 2 - runs_on: 'ubuntu-22.04' - python_version: '3.11.x' - conan_logging_level: 'info' secrets: inherit conan-package-create-linux: - if: ${{ (github.event_name == 'push' && github.ref_name == 'main') || (github.event_name == 'workflow_dispatch' && inputs.create_binaries_linux) }} needs: [ conan-recipe-version, conan-package-export ] - - uses: ultimaker/cura/.github/workflows/conan-package-create.yml@main + if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }} + uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-linux.yml@main with: - project_name: ${{ needs.conan-recipe-version.outputs.project_name }} recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} - build_id: 1 - runs_on: 'ubuntu-20.04' - python_version: '3.11.x' - conan_logging_level: 'info' - secrets: inherit - - notify-export: - if: ${{ always() }} - needs: [ conan-recipe-version, conan-package-export ] - - uses: ultimaker/cura/.github/workflows/notify.yml@main - with: - success: ${{ contains(join(needs.*.result, ','), 'success') }} - success_title: "New Conan recipe exported in ${{ github.repository }}" - success_body: "Exported ${{ needs.conan-recipe-version.outputs.recipe_id_full }}" - failure_title: "Failed to export Conan Export in ${{ github.repository }}" - failure_body: "Failed to exported ${{ needs.conan-recipe-version.outputs.recipe_id_full }}" - secrets: inherit - - notify-create: - if: ${{ always() && ((github.event_name == 'push' && github.ref_name == 'main') || (github.event_name == 'workflow_dispatch' && inputs.create_binaries_linux)) }} - needs: [ conan-recipe-version, conan-package-create-macos, conan-package-create-windows, conan-package-create-linux, conan-package-create-linux-modern ] - - uses: ultimaker/cura/.github/workflows/notify.yml@main - with: - success: ${{ contains(join(needs.*.result, ','), 'success') }} - success_title: "New binaries created in ${{ github.repository }}" - success_body: "Created binaries for ${{ needs.conan-recipe-version.outputs.recipe_id_full }}" - failure_title: "Failed to create binaries in ${{ github.repository }}" - failure_body: "Failed to created binaries for ${{ needs.conan-recipe-version.outputs.recipe_id_full }}" secrets: inherit diff --git a/.github/workflows/requirements-conan-package.txt b/.github/workflows/requirements-conan-package.txt deleted file mode 100644 index 42669ee3..00000000 --- a/.github/workflows/requirements-conan-package.txt +++ /dev/null @@ -1 +0,0 @@ -conan>=1.60.2,<2.0.0 diff --git a/.github/workflows/requirements-runner.txt b/.github/workflows/requirements-runner.txt new file mode 100644 index 00000000..e69de29b diff --git a/conandata.yml b/conandata.yml new file mode 100644 index 00000000..6feb46e5 --- /dev/null +++ b/conandata.yml @@ -0,0 +1 @@ +version: "5.4.0-alpha.0" \ No newline at end of file diff --git a/conanfile.py b/conanfile.py index 496b44d3..bc4fec44 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,3 +1,4 @@ +from io import StringIO from os import path from conan import ConanFile @@ -5,9 +6,10 @@ from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout from conan.tools.env import VirtualBuildEnv -from conan.tools.files import copy, AutoPackager +from conan.tools.files import copy, AutoPackager, update_conandata from conan.tools.microsoft import check_min_vs, is_msvc, is_msvc_static_runtime -from conan.tools.scm import Version +from conan.tools.scm import Version, Git +from conans.errors import ConanInvalidSystemRequirements required_conan_version = ">=1.55.0" @@ -24,16 +26,23 @@ class ArcusConan(ConanFile): options = { "shared": [True, False], - "fPIC": [True, False] + "fPIC": [True, False], + "enable_sentry": [True, False], } default_options = { "shared": True, "fPIC": True, + "enable_sentry": False, } def set_version(self): if not self.version: - self.version = "5.4.0-alpha" + build_meta = "" if self.develop else "+source" + self.version = self.conan_data["version"] + build_meta + + def export(self): + git = Git(self) + update_conandata(self, {"version": self.version, "commit": git.get_commit()}) @property def _min_cppstd(self): @@ -57,6 +66,8 @@ def export_sources(self): def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self.conf.get("user.curaengine:sentry_url", "", check_type=str) == "": + del self.options.enable_sentry def configure(self): if self.options.shared: @@ -108,6 +119,19 @@ def build(self): cmake.configure() 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") + self.run(f"sentry-cli debug-files upload --include-sources -o {sentry_project} -p curaengine .") + + def package(self): copy(self, pattern="LICENSE*", dst="licenses", src=self.source_folder) packager = AutoPackager(self) From 5299ec7fda935e19ad4285e4da12f74e8fc9371a Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Fri, 12 Jan 2024 11:02:12 +0100 Subject: [PATCH 2/7] Use Sentry org and project from conf Contributes to CURA-11482 --- conanfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index bc4fec44..1eb5857c 100644 --- a/conanfile.py +++ b/conanfile.py @@ -122,14 +122,15 @@ def build(self): 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 == "": + sentry_org = self.conf.get("user.curaengine:sentry_org", "", check_type=str) + if sentry_project == "" or sentry_org == "": 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") - self.run(f"sentry-cli debug-files upload --include-sources -o {sentry_project} -p curaengine .") + self.run(f"sentry-cli debug-files upload --include-sources -o {sentry_org} -p {sentry_project} .") def package(self): From f699c56b8a11dddb0ff60da35e9ffdc0a371a8c1 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Fri, 12 Jan 2024 13:25:14 +0100 Subject: [PATCH 3/7] Bundle sources Contributes to CURA-11482 --- CMakeLists.txt | 5 +++++ conanfile.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 32d537df..6cc1e397 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ cmake_minimum_required(VERSION 3.23) find_package(standardprojectsettings REQUIRED) find_package(protobuf REQUIRED) +option(ENABLE_SENTRY "Send crash data via Sentry" OFF) + set(arcus_SRCS src/Socket.cpp src/SocketListener.cpp @@ -37,4 +39,7 @@ if(WIN32) target_link_libraries(Arcus PUBLIC Ws2_32) set_target_properties(Arcus PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + if (ENABLE_SENTRY) + set_target_properties(CuraEngine PROPERTIES LINK_FLAGS "/DEBUG:FULL") + endif () endif() diff --git a/conanfile.py b/conanfile.py index 1eb5857c..7a97b7e3 100644 --- a/conanfile.py +++ b/conanfile.py @@ -103,6 +103,7 @@ def build_requirements(self): def generate(self): tc = CMakeToolchain(self) + tc.variables["ENABLE_SENTRY"] = self.options.get_safe("enable_sentry", False) if is_msvc(self): tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" @@ -129,8 +130,9 @@ def build(self): self.run(f"sentry-cli -V", output=output) if "sentry-cli" not in output.getvalue(): raise ConanInvalidSystemRequirements("sentry-cli is not installed") + build_source_dir = self.build_path.parent.parent.as_posix() self.output.info("Uploading debug symbols to sentry") - self.run(f"sentry-cli debug-files upload --include-sources -o {sentry_org} -p {sentry_project} .") + self.run(f"sentry-cli debug-files upload --include-sources -o {sentry_org} -p {sentry_project} {build_source_dir}") def package(self): From 0e3e87229bbe4b5328746dab1f225e64b398c82c Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Fri, 12 Jan 2024 15:00:23 +0100 Subject: [PATCH 4/7] target correct name Contributes to CURA-11482 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cc1e397..f8cf6360 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,6 @@ if(WIN32) target_link_libraries(Arcus PUBLIC Ws2_32) set_target_properties(Arcus PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) if (ENABLE_SENTRY) - set_target_properties(CuraEngine PROPERTIES LINK_FLAGS "/DEBUG:FULL") + set_target_properties(Arcus PROPERTIES LINK_FLAGS "/DEBUG:FULL") endif () endif() From 09f311447ed5d9038c159b198d520c8ae362e632 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Sat, 13 Jan 2024 14:12:03 +0100 Subject: [PATCH 5/7] strip debug symbols from binary Contributes to CURA-11482 --- conanfile.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/conanfile.py b/conanfile.py index 7a97b7e3..016c2401 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,7 +9,7 @@ from conan.tools.files import copy, AutoPackager, update_conandata from conan.tools.microsoft import check_min_vs, is_msvc, is_msvc_static_runtime from conan.tools.scm import Version, Git -from conans.errors import ConanInvalidSystemRequirements +from conans.tools import which required_conan_version = ">=1.55.0" @@ -125,11 +125,18 @@ def build(self): sentry_project = self.conf.get("user.curaengine:sentry_project", "", check_type=str) sentry_org = self.conf.get("user.curaengine:sentry_org", "", check_type=str) if sentry_project == "" or sentry_org == "": - 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") + raise ConanInvalidConfiguration("sentry_project or sentry_org is not set") + if which("sentry-cli") is None: + self.output.warn("sentry-cli is not installed, skipping uploading debug symbols") + return + + if self.settings.os == "Linux": + self.output.info("Stripping debug symbols from binary") + ext = ".so" if self.options.shared else ".a" + self.run(f"objcopy --only-keep-debug --compress-debug-sections=zlib libArcus{ext} libArcus.debug") + self.run(f"objcopy --strip-debug --strip-unneeded libArcus{ext}") + self.run("objcopy --add-gnu-debuglink=libArcus.debug libArcus{ext}") + build_source_dir = self.build_path.parent.parent.as_posix() self.output.info("Uploading debug symbols to sentry") self.run(f"sentry-cli debug-files upload --include-sources -o {sentry_org} -p {sentry_project} {build_source_dir}") From 783bbcc53ecac1e565f0eb27ab7ab79a5d48b02f Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Sat, 13 Jan 2024 14:16:38 +0100 Subject: [PATCH 6/7] Use f-string Contributes to CURA-11482 --- conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 016c2401..d8b85f56 100644 --- a/conanfile.py +++ b/conanfile.py @@ -135,7 +135,7 @@ def build(self): ext = ".so" if self.options.shared else ".a" self.run(f"objcopy --only-keep-debug --compress-debug-sections=zlib libArcus{ext} libArcus.debug") self.run(f"objcopy --strip-debug --strip-unneeded libArcus{ext}") - self.run("objcopy --add-gnu-debuglink=libArcus.debug libArcus{ext}") + self.run(f"objcopy --add-gnu-debuglink=libArcus.debug libArcus{ext}") build_source_dir = self.build_path.parent.parent.as_posix() self.output.info("Uploading debug symbols to sentry") From feb5978e8178d3e0f32146b7a8d8ebe06e11ab58 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Mon, 15 Jan 2024 16:38:00 +0100 Subject: [PATCH 7/7] Update conanfile.py Co-authored-by: Erwan MATHIEU --- conanfile.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/conanfile.py b/conanfile.py index d8b85f56..d83fe9aa 100644 --- a/conanfile.py +++ b/conanfile.py @@ -126,20 +126,20 @@ def build(self): sentry_org = self.conf.get("user.curaengine:sentry_org", "", check_type=str) if sentry_project == "" or sentry_org == "": raise ConanInvalidConfiguration("sentry_project or sentry_org is not set") + if which("sentry-cli") is None: self.output.warn("sentry-cli is not installed, skipping uploading debug symbols") - return - - if self.settings.os == "Linux": - self.output.info("Stripping debug symbols from binary") - ext = ".so" if self.options.shared else ".a" - self.run(f"objcopy --only-keep-debug --compress-debug-sections=zlib libArcus{ext} libArcus.debug") - self.run(f"objcopy --strip-debug --strip-unneeded libArcus{ext}") - self.run(f"objcopy --add-gnu-debuglink=libArcus.debug libArcus{ext}") - - build_source_dir = self.build_path.parent.parent.as_posix() - self.output.info("Uploading debug symbols to sentry") - self.run(f"sentry-cli debug-files upload --include-sources -o {sentry_org} -p {sentry_project} {build_source_dir}") + else: + if self.settings.os == "Linux": + self.output.info("Stripping debug symbols from binary") + ext = ".so" if self.options.shared else ".a" + self.run(f"objcopy --only-keep-debug --compress-debug-sections=zlib libArcus{ext} libArcus.debug") + self.run(f"objcopy --strip-debug --strip-unneeded libArcus{ext}") + self.run(f"objcopy --add-gnu-debuglink=libArcus.debug libArcus{ext}") + + build_source_dir = self.build_path.parent.parent.as_posix() + self.output.info("Uploading debug symbols to sentry") + self.run(f"sentry-cli debug-files upload --include-sources -o {sentry_org} -p {sentry_project} {build_source_dir}") def package(self):