diff --git a/.github/workflows/conan-package.yml b/.github/workflows/conan-package.yml index 191fa18..816f2ef 100644 --- a/.github/workflows/conan-package.yml +++ b/.github/workflows/conan-package.yml @@ -1,158 +1,28 @@ ---- 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. "libnest2d/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/**' - - 'include/**' - - 'test_package/**' - - 'tests/**' - - 'cmake/**' - - 'conanfile.py' - - 'conandata.yml' - - 'CMakeLists.txt' - - '.github/workflows/conan-package.yml' - - '.github/workflows/requirements*' - branches: - - main - - master - - 'CURA-*' - - '[0-9].[0-9]' - - '[0-9].[0-9][0-9]' - tags: - - '[0-9].[0-9].[0-9]*' - - '[0-9].[0-9][0-9].[0-9]*' + push: + paths: + - 'src/**' + - 'include/**' + - 'test_package/**' + - 'tests/**' + - 'conanfile.py' + - 'conandata.yml' + - 'CMakeLists.txt' + - '.github/workflows/conan-package.yml' + branches: + - main + - master + - 'CURA-*' + - 'PP-*' + - '[0-9].[0-9]*' + - '[0-9].[0-9][0-9]*' + tags: + - '[0-9].[0-9].[0-9]*' + - '[0-9].[0-9][0-9].[0-9]*' jobs: - conan-recipe-version: - uses: ultimaker/cura/.github/workflows/conan-recipe-version.yml@main - with: - project_name: savitar - - conan-package-export: - needs: [ conan-recipe-version ] - uses: ultimaker/cura/.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.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true' )) || (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.10.x' - conan_config_branch: '' - conan_logging_level: 'info' - secrets: inherit - - conan-package-create-macos: - if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) || (github.event_name == 'workflow_dispatch' && inputs.create_binaries_macos) }} - 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: 3 - runs_on: 'macos-11' - python_version: '3.10.x' - conan_logging_level: 'info' - secrets: inherit - - conan-package-create-linux-modern: - if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) || (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 - with: - recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} - project_name: ${{ needs.conan-recipe-version.outputs.project_name }} - build_id: 2 - runs_on: 'ubuntu-22.04' - python_version: '3.10.x' - conan_logging_level: 'info' - secrets: inherit - - conan-package-create-linux: - if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) || (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 - with: - recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} - project_name: ${{ needs.conan-recipe-version.outputs.project_name }} - build_id: 1 - runs_on: 'ubuntu-20.04' - python_version: '3.10.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.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) || (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 + conan-package: + uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@main + secrets: inherit diff --git a/.github/workflows/requirements-conan-package.txt b/.github/workflows/requirements-conan-package.txt deleted file mode 100644 index cf67557..0000000 --- a/.github/workflows/requirements-conan-package.txt +++ /dev/null @@ -1 +0,0 @@ -conan>=1.56.0,<2.0.0 \ No newline at end of file diff --git a/.github/workflows/unit-test-post.yml b/.github/workflows/unit-test-post.yml new file mode 100644 index 0000000..3926841 --- /dev/null +++ b/.github/workflows/unit-test-post.yml @@ -0,0 +1,14 @@ +name: unit-test-post + +on: + workflow_run: + workflows: [ unit-test ] + types: [ completed ] + +jobs: + publish-test-results: + uses: ultimaker/cura-workflows/.github/workflows/unit-test-post.yml@main + with: + event: ${{ github.event.workflow_run.event }} + conclusion: ${{ github.event.workflow_run.conclusion }} + secrets: inherit diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 4140004..30fdb83 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -1,137 +1,52 @@ ---- name: unit-test -# FIXME: This should be a reusable workflow on: - push: - paths: - - 'src/**' - - 'include/**' - - 'test_package/**' - - 'tests/**' - - 'cmake/**' - - 'conanfile.py' - - 'conandata.yml' - - 'CMakeLists.txt' - - '.github/workflows/unit-test.yml' - - '.github/workflows/requirements*' - branches: - - main - - master - - 'CURA-*' - - '[0-9].[0-9]' - - '[0-9].[0-9][0-9]' - tags: - - '[0-9].[0-9].[0-9]' - - '[0-9].[0-9][0-9].[0-9]' - pull_request: - paths: - - 'src/**' - - 'include/**' - - 'test_package/**' - - 'tests/**' - - 'cmake/**' - - 'conanfile.py' - - 'conandata.yml' - - 'CMakeLists.txt' - - '.github/workflows/unit-test.yml' - - '.github/workflows/requirements*' - branches: - - main - - master - - '[0-9].[0-9]' - - '[0-9].[0-9][0-9]' - tags: - - '[0-9].[0-9].[0-9]' - - '[0-9].[0-9][0-9].[0-9]' - -env: - CONAN_LOGIN_USERNAME_CURA: ${{ secrets.CONAN_USER }} - CONAN_PASSWORD_CURA: ${{ secrets.CONAN_PASS }} - CONAN_LOGIN_USERNAME_CURA_CE: ${{ secrets.CONAN_USER }} - CONAN_PASSWORD_CURA_CE: ${{ secrets.CONAN_PASS }} - CONAN_LOG_RUN_TO_OUTPUT: 1 - CONAN_LOGGING_LEVEL: info - CONAN_NON_INTERACTIVE: 1 + push: + paths: + - 'src/**' + - 'include/**' + - 'test_package/**' + - 'tests/**' + - 'cmake/**' + - 'conanfile.py' + - 'conandata.yml' + - 'CMakeLists.txt' + - '.github/workflows/unit-test.yml' + - '.github/workflows/requirements*' + branches: + - main + - master + - 'CURA-*' + - '[0-9].[0-9]*' + - '[0-9].[0-9][0-9]*' + tags: + - '[0-9].[0-9].[0-9]' + - '[0-9].[0-9][0-9].[0-9]' + pull_request: + paths: + - 'src/**' + - 'include/**' + - 'test_package/**' + - 'tests/**' + - 'cmake/**' + - 'conanfile.py' + - 'conandata.yml' + - 'CMakeLists.txt' + - '.github/workflows/unit-test.yml' + - '.github/workflows/requirements*' + branches: + - main + - master + - 'CURA-*' + - '[0-9].[0-9]*' + - '[0-9].[0-9][0-9]*' + tags: + - '[0-9].[0-9].[0-9]' + - '[0-9].[0-9][0-9].[0-9]' jobs: - conan-recipe-version: - uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-version.yml@main - with: - project_name: savitar - - testing: - runs-on: ubuntu-20.04 - needs: [ conan-recipe-version ] - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Python and pip - uses: actions/setup-python@v4 - with: - python-version: '3.10.x' - architecture: 'x64' - cache: 'pip' - cache-dependency-path: .github/workflows/requirements-conan-package.txt - - - name: Install Python requirements and Create default Conan profile - run: | - pip install -r requirements-conan-package.txt - conan profile new default --detect - working-directory: .github/workflows/ - - - name: Use Conan download cache (Bash) - if: ${{ runner.os != 'Windows' }} - run: conan config set storage.download_cache="$HOME/.conan/conan_download_cache" - - - name: Cache Conan local repository packages (Bash) - uses: actions/cache@v3 - if: ${{ runner.os != 'Windows' }} - with: - path: | - $HOME/.conan/data - $HOME/.conan/conan_download_cache - key: conan-${{ runner.os }}-${{ runner.arch }} - - - name: Install Linux system requirements - if: ${{ runner.os == 'Linux' }} - run: sudo apt install build-essential checkinstall zlib1g-dev libssl-dev ninja-build autoconf libx11-dev libx11-xcb-dev libfontenc-dev libice-dev libsm-dev libxau-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev xtrans-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev xkb-data libxcb-dri3-dev uuid-dev libxcb-util-dev libxkbcommon-x11-dev -y - - - name: Get Conan configuration - run: conan config install https://github.com/Ultimaker/conan-config.git - - - name: Install dependencies - run: conan install . ${{ needs.conan-recipe-version.outputs.recipe_id_full }} -o enable_testing=True -s build_type=Release --build=missing --update -g GitHubActionsRunEnv -g GitHubActionsBuildEnv - - - name: Upload the Dependency package(s) - run: conan upload "*" -r cura --all -c - - - name: Set Environment variables from Conan install (bash) - if: ${{ runner.os != 'Windows' }} - run: | - . ./activate_github_actions_runenv.sh - . ./activate_github_actions_buildenv.sh - working-directory: build/Release/generators/ - - - name: Build Unit Test - run: | - cmake --preset release - cmake --build --preset release - - - name: Run Unit Test - id: run-test - run: ctest --output-junit engine_test.xml - working-directory: build/Release/ - - - name: Publish Unit Test Results - id: test-results - uses: EnricoMi/publish-unit-test-result-action@v1 - if: ${{ always() }} - with: - files: | - **/*.xml - - - name: Conclusion - run: echo "Conclusion is ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}" + testing: + name: Run unit tests + uses: ultimaker/cura-workflows/.github/workflows/unit-test.yml@main + with: + test_use_ctest: true diff --git a/.gitignore b/.gitignore index 1567381..5c47ed2 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,33 @@ CMakeUserPresets.json /conaninfo.txt build/ test_package/build +/test_package/savitar-config.cmake +/test_package/pugixml-config.cmake +/test_package/CMakeFiles/ +/test_package/CMakePresets.json +/test_package/test +/test_package/metadata/ +/test_package/pugixml-config-version.cmake +/test_package/conanrunenv-release-x86_64.sh +/test_package/deactivate_conanrunenv-release-x86_64.sh +/test_package/deactivate_conanbuildenv-release-x86_64.sh +/test_package/deactivate_conanrun.sh +/test_package/savitar-config-version.cmake +/test_package/deactivate_conanbuild.sh +/test_package/.ninja_log +/test_package/build.ninja +/test_package/cmakedeps_macros.cmake +/test_package/savitarTargets.cmake +/test_package/pugixml-release-x86_64-data.cmake +/test_package/conandeps_legacy.cmake +/test_package/savitar-Target-release.cmake +/test_package/pugixml-Target-release.cmake +/test_package/conanbuild.sh +/test_package/conan_toolchain.cmake +/test_package/conanrun.sh +/test_package/pugixmlTargets.cmake +/test_package/CMakeCache.txt +/test_package/conanbuildenv-release-x86_64.sh +/test_package/cmake_install.cmake +/test_package/.ninja_deps +/test_package/savitar-release-x86_64-data.cmake diff --git a/conandata.yml b/conandata.yml new file mode 100644 index 0000000..ef488b6 --- /dev/null +++ b/conandata.yml @@ -0,0 +1 @@ +version: "5.4.0-alpha.0" diff --git a/conanfile.py b/conanfile.py index 41a3bd8..2c2bcef 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,17 +1,15 @@ -from os import path - +import os from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout from conan.tools.env import VirtualBuildEnv -from conan.tools.files import AutoPackager, copy +from conan.tools.files import AutoPackager, copy, update_conandata from conan.tools.build import check_min_cppstd 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 -required_conan_version = ">=1.56.0" +required_conan_version = ">=2.7.0" class SavitarConan(ConanFile): @@ -22,24 +20,26 @@ class SavitarConan(ConanFile): description = "libSavitar is a c++ implementation of 3mf loading with SIP python bindings" topics = ("conan", "cura", "3mf", "c++") settings = "os", "compiler", "build_type", "arch" - revision_mode = "scm" exports = "LICENSE*" - generators = "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv" + generators = "VirtualRunEnv" + package_type = "library" options = { "shared": [True, False], - "fPIC": [True, False], - "enable_testing": [True, False] + "fPIC": [True, False] } default_options = { "shared": True, - "fPIC": True, - "enable_testing": False + "fPIC": True } def set_version(self): - if self.version is None: - self.version = "5.4.0-alpha" + if not self.version: + self.version = self.conan_data["version"] + + def export(self): + git = Git(self) + update_conandata(self, {"version": self.version, "commit": git.get_commit()}) @property def _min_cppstd(self): @@ -57,9 +57,9 @@ def _compilers_minimum_version(self): def export_sources(self): copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) - copy(self, "*", path.join(self.recipe_folder, "src"), path.join(self.export_sources_folder, "src")) - copy(self, "*", path.join(self.recipe_folder, "include"), path.join(self.export_sources_folder, "include")) - copy(self, "*", path.join(self.recipe_folder, "tests"), path.join(self.export_sources_folder, "tests")) + copy(self, "*", os.path.join(self.recipe_folder, "src"), os.path.join(self.export_sources_folder, "src")) + copy(self, "*", os.path.join(self.recipe_folder, "include"), os.path.join(self.export_sources_folder, "include")) + copy(self, "*", os.path.join(self.recipe_folder, "tests"), os.path.join(self.export_sources_folder, "tests")) def layout(self): cmake_layout(self) @@ -69,7 +69,7 @@ def layout(self): self.cpp.package.defines = ["SAVITAR_DEBUG"] def requirements(self): - self.requires("pugixml/1.12.1", transitive_headers=True) + self.requires("pugixml/1.14", transitive_headers=True) def validate(self): if self.settings.compiler.cppstd: @@ -83,9 +83,9 @@ def validate(self): ) def build_requirements(self): - self.test_requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable") - if self.options.enable_testing: - self.test_requires("gtest/1.12.1") + self.test_requires("standardprojectsettings/[>=0.2.0]@ultimaker/stable") + if not self.conf.get("tools.build:skip_test", False, check_type=bool): + self.test_requires("gtest/1.14.0") def config_options(self): if self.settings.os == "Windows": @@ -100,7 +100,7 @@ def generate(self): 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" - tc.variables["ENABLE_TESTING"] = self.options.enable_testing + tc.variables["ENABLE_TESTING"] = not self.conf.get("tools.build:skip_test", False, check_type=bool) tc.generate() tc = CMakeDeps(self) diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 3ea5fe5..c96cc67 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -9,6 +9,4 @@ add_executable(test test.cpp) target_link_libraries(test PUBLIC savitar::savitar - ) - -#target_include_directories(test PRIVATE ${Savitar_INCLUDE_DIRS}) \ No newline at end of file + ) \ No newline at end of file diff --git a/test_package/conanfile.py b/test_package/conanfile.py index 5c532db..ccab548 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -7,7 +7,6 @@ class SavitarTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "VirtualRunEnv" test_type = "explicit" def requirements(self): @@ -25,16 +24,15 @@ def generate(self): for dep in self.dependencies.values(): for bin_dir in dep.cpp_info.bindirs: - copy(self, "*.dll", src = bin_dir, dst = self.build_folder) + copy(self, "*.dll", src=bin_dir, dst=self.build_folder) def build(self): cmake = CMake(self) cmake.configure() cmake.build() - def test(self): if can_run(self): ext = ".exe" if self.settings.os == "Windows" else "" prefix_path = "" if self.settings.os == "Windows" else "./" - self.run(f"{prefix_path}test{ext}", env = "conanrun") + self.run(f"{prefix_path}test{ext}", env="conanrun")