From 99179b836ceb9c16f8664b33029386020493f76e Mon Sep 17 00:00:00 2001 From: bruno <97033386+bruno-at-orange@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:34:58 +0200 Subject: [PATCH 1/5] Deb + RPM + Zip + Conda packages (Linux Only) - Add install and CPack sections in CMakeLists.txt - Fix the conda build.sh (without preset: ninja multi config is not found on conda) --- .gitignore | 2 +- CMakeLists.txt | 109 +++++++++++++++++++++++++++++++++++++++++++++++- LICENSE | 32 ++++++++++++++ conda/build.sh | 11 ++--- conda/meta.yaml | 14 +------ 5 files changed, 148 insertions(+), 20 deletions(-) create mode 100644 LICENSE diff --git a/.gitignore b/.gitignore index 22bb128..dcd0210 100644 --- a/.gitignore +++ b/.gitignore @@ -38,4 +38,4 @@ /build **/CMakeFiles **/Makefile -*.cmake +.vscode diff --git a/CMakeLists.txt b/CMakeLists.txt index 80b8ccd..82c6a52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,10 +11,20 @@ if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) endif() cmake_minimum_required(VERSION 3.20) + # Enforce c++14 standard. set(CMAKE_CXX_STANDARD 14) -project(khiops-gcs LANGUAGES CXX) +project( + khiops-gcs + LANGUAGES CXX + VERSION 0.1.0) + +set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules/) + +# Exclude googletest from the installation and packages +set(INSTALL_GTEST OFF) +set(INSTALL_GMOCK OFF) include(GoogleTest) enable_testing() @@ -49,7 +59,6 @@ if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND NOT (CMAKE_BUILD_TYPE STREQUAL -fno-sanitize-recover=all) add_link_options(-fsanitize=undefined -fsanitize=address -fno-sanitize-recover=all) - set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules/) include(CodeCoverage) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_COVERAGE} ${CMAKE_CXX_FLAGS_DEBUG}") @@ -66,6 +75,11 @@ target_link_options(khiopsdriver_file_gcs PRIVATE $<$:-s> )# stripping target_link_libraries(khiopsdriver_file_gcs PRIVATE google-cloud-cpp::storage spdlog::spdlog) + +set_target_properties( + khiopsdriver_file_gcs PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} + VERSION ${PROJECT_VERSION}) + target_compile_options( khiopsdriver_file_gcs PRIVATE $<$:-Wall> @@ -82,3 +96,94 @@ if(BUILD_TESTS) endif(BUILD_TESTS) add_subdirectory(test) + +include(GNUInstallDirs) +install( + TARGETS khiopsdriver_file_gcs + LIBRARY DESTINATION ${CMAKE_INSTALL_LIB} + ARCHIVE # lib on windows + RUNTIME # dll on windows +) + +set(CPACK_PACKAGE_VENDOR Orange) +set(CPACK_PACKAGE_HOMEPAGE_URL https://khiops.org) +set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") +set(CPACK_PACKAGE_VENDOR "Orange") +set(CPACK_PACKAGE_CONTACT "Khiops Team ") +set(CPACK_SOURCE_IGNORE_FILES .git) +set(CPACK_PACKAGE_DESCRIPTION + "This driver allows Khiops to access the Google Cloud storage.") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "GCS driver for the Khiops tool") +set(CPACK_PACKAGE_NAME "khiops-driver-gcs") + +set(CPACK_VERBATIM_VARIABLES YES) +set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) +set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/packages") +# set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/") + +# ########### ARCHIVE Generator ############################# + +# One package per component +set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) + +# user friendly archive names +set(CPACK_ARCHIVE_FILE_NAME kkhiops-driver-gcs-${PROJECT_VERSION}) + +# ########### DEB Generator ############################# + +# Package release ("This is the numbering of the DEB package itself, i.e. the +# version of the packaging and not the version of the content") +set(CPACK_DEBIAN_PACKAGE_RELEASE 1) + +# package name for deb. +set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) + +# Packages version: the full KHIOPS_VERSION (N.N.N_aN) instead of the +# PROJECT_VERSION (N.N.N) set(CPACK_DEBIAN_PACKAGE_VERSION ${KHIOPS_VERSION}) + +set(CPACK_DEB_COMPONENT_INSTALL YES) +set(CPACK_DEBIAN_PACKAGE_SECTION "math") + +# runtime path setting +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) +set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) +# binaries in deb building will search shared library in the build tree. We +# should use directly CMAKE_LIBRARY_OUTPUT_DIRECTORY but it produces a bug in +# dpkg-shlibdeps +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS ${CMAKE_BINARY_DIR}/lib/) + +# packages recommends +set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "khiops") + +# packages posinst and triggers +set(CPACK_DEBIAN_KNI_PACKAGE_CONTROL_EXTRA + "${PROJECT_SOURCE_DIR}/packaging/linux/debian/kni/triggers") + +# set(CPACK_DEBIAN_PACKAGE_DEBUG ON) +set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE) + +# ########### RPM Generator ############################# + +set(CPACK_RPM_COMPONENT_INSTALL ON) +set(CPACK_RPM_PACKAGE_LICENSE BSD-3-Clause) +set(CPACK_RPM_PACKAGE_GROUP "Applications/Engineering") +set(CPACK_RPM_PACKAGE_VENDOR Orange) + +set(CPACK_RPM_KHIOPS_PACKAGE_AUTOREQ ON) + +# Packages version set(CPACK_RPM_PACKAGE_VERSION ${PROJECT_VERSION}) + +# packages names set(CPACK_RPM_PACKAGE_NAME khiops) + +# default file name e.g. khiops-10.0.0-1.x86_64.rpm +set(CPACK_RPM_FILE_NAME RPM-DEFAULT) + +# packages summary set(CPACK_RPM_PACKAGE_SUMMARY "Khiops tools") + +# packages post/postun install scripts +# set(CPACK_RPM_KNI_POST_INSTALL_SCRIPT_FILE +# "${PROJECT_SOURCE_DIR}/packaging/linux/redhat/kni.post") +# set(CPACK_RPM_KNI_POSTUN_INSTALL_SCRIPT_FILE +# "${PROJECT_SOURCE_DIR}/packaging/linux/redhat/kni.postun") + +include(CPack) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c58c9df --- /dev/null +++ b/LICENSE @@ -0,0 +1,32 @@ +The Clear BSD License + +Copyright (c) 2024 Orange S.A. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted (subject to the limitations in the disclaimer +below) provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY +THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/conda/build.sh b/conda/build.sh index 29f30d2..8d75f2d 100644 --- a/conda/build.sh +++ b/conda/build.sh @@ -4,14 +4,15 @@ set -euo pipefail # Configure project -cmake --fresh --preset ninja-multi +cmake --fresh -G Ninja -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake -B conda-build -S . -# Build -cmake --build --preset ninja-release --target khiopsdriver_file_gcs +# Build +cmake --build conda-build --target khiopsdriver_file_gcs # Copy binary to conda package -mkdir -p $PREFIX/bin -cp ./builds/ninja-multi/Release/libkhiopsdriver_file_gcs.so "$PREFIX/bin/" +#mkdir -p $PREFIX/bin +cmake --install conda-build --prefix $PREFIX + diff --git a/conda/meta.yaml b/conda/meta.yaml index 19676e0..bca29a1 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -12,19 +12,9 @@ requirements: - cmake - ninja - {{ compiler('cxx') }} - host: - - google-cloud-cpp - - spdlog - run: - - google-cloud-cpp - - spdlog -outputs: - - name: khiops-driver-gcs - # test: - # commands: - # - MODL -v - # - MODL_Coclustering -v +files: + - lib/libkhiopsdriver_file_gcs.so* about: home: https://khiops.org From f79e2c2b254361ab76aa0e127172832932881437 Mon Sep 17 00:00:00 2001 From: bruno <97033386+bruno-at-orange@users.noreply.github.com> Date: Tue, 17 Sep 2024 18:42:11 +0200 Subject: [PATCH 2/5] Add workflow to build deb packages Add cmake_format.py to improve cmake formatting in pre-commit: modify all cmake files --- .cmake-format.py | 7 +++ .github/workflows/pack-debian.yml | 59 +++++++++++++++++++ CMakeLists.txt | 76 ++++++++++-------------- cmake/modules/CodeCoverage.cmake | 96 +++++++++++-------------------- generate_tests.cmake | 13 +++-- test/CMakeLists.txt | 17 ++---- 6 files changed, 142 insertions(+), 126 deletions(-) create mode 100644 .cmake-format.py create mode 100644 .github/workflows/pack-debian.yml diff --git a/.cmake-format.py b/.cmake-format.py new file mode 100644 index 0000000..6082af2 --- /dev/null +++ b/.cmake-format.py @@ -0,0 +1,7 @@ +with section("format"): + line_width = 120 + tab_size = 2 + line_ending = "auto" + +with section("markup"): + bullet_char = "-" diff --git a/.github/workflows/pack-debian.yml b/.github/workflows/pack-debian.yml new file mode 100644 index 0000000..2351958 --- /dev/null +++ b/.github/workflows/pack-debian.yml @@ -0,0 +1,59 @@ +--- +name: DEB Packages +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + strategy: + fail-fast: false + matrix: + image: ['debian:10', 'debian:11', 'debian:12', 'ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:24.04'] + container: ${{ matrix.image }} + steps: + - name: Install packages + run: | + export DEBIAN_FRONTEND="noninteractive" + apt-get -y update + apt-get -y --no-install-recommends install build-essential coreutils debhelper git ca-certificates curl + apt-get -y install ninja-build + apt-get -y install zip pkg-config # for vcpkkg + curl -LO "https://github.com/Kitware/CMake/releases/download/v3.30.3/cmake-3.30.3-linux-x86_64.sh" + bash cmake-3.30.3-linux-x86_64.sh --prefix=/usr/local/ --exclude-subdir + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: true + - name: Configure CMake + run: | + cmake -B builds -S . -G Ninja -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake + - name: Build + run: | + cmake --build builds --target khiopsdriver_file_gcs + - name: Build package with CPack + run: cd builds/ && cpack -G DEB + - name: Set environment variables + run: | + source /etc/os-release + echo "ID=$ID" >> "$GITHUB_ENV" + echo "VERSION_CODENAME=$VERSION_CODENAME" >> "$GITHUB_ENV" + - name: Rename the packages to include the ubuntu codename + run: | + cd builds/packages/ + for filename in *.deb + do + mv -v $filename ${filename%_*}-${VERSION_CODENAME}.${filename##*_} + done + - name: Upload the packages as artifacts + uses: actions/upload-artifact@v4 + with: + # We add a `deb-` prefix so we can later recover all artifacts with the pattern `deb-*` + # Note: The more natural pattern `*-deb` or `*` does not work + name: deb-${{ env.ID }}-${{ env.VERSION_CODENAME }} + path: builds/packages/*.deb + if-no-files-found: error + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 82c6a52..d9dcf95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,8 @@ # CMakeLists.txt -# Ensure to pick up the default triplet from the environment if any. This helps -# driving the vcpkg triplet in the same way either when starting vcpkg directly, -# or when letting CMake start vcpkg at configure/generate time. Note: this logic -# must happen before PROJECT command. +# Ensure to pick up the default triplet from the environment if any. This helps driving the vcpkg triplet in the same +# way either when starting vcpkg directly, or when letting CMake start vcpkg at configure/generate time. Note: this +# logic must happen before PROJECT command. if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" @@ -40,11 +39,10 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) # Set the location of the built artifacts: # -# * Shared and static library target directory: lib -# * Executable target directory: bin -# * We must use these weird generator expressions to avoid the Debug and Release -# directories in VS -# * More info: https://stackoverflow.com/q/47175912 +# - Shared and static library target directory: lib +# - Executable target directory: bin +# - We must use these weird generator expressions to avoid the Debug and Release directories in VS +# - More info: https://stackoverflow.com/q/47175912 # set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY $<1:${CMAKE_BINARY_DIR}/lib/>) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY $<1:${CMAKE_BINARY_DIR}/lib/>) @@ -52,33 +50,23 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_BINARY_DIR}/bin/>) message(STATUS "Executables will be stored in ${CMAKE_BINARY_DIR}/bin/") message(STATUS "Libraries will be stored in ${CMAKE_BINARY_DIR}/lib/") -if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND NOT (CMAKE_BUILD_TYPE STREQUAL - "Release")) +if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND NOT (CMAKE_BUILD_TYPE STREQUAL "Release")) message("Build system == Linux, build with sanitizer tools") - add_compile_options(-fsanitize=undefined -fsanitize=address - -fno-sanitize-recover=all) - add_link_options(-fsanitize=undefined -fsanitize=address - -fno-sanitize-recover=all) + add_compile_options(-fsanitize=undefined -fsanitize=address -fno-sanitize-recover=all) + add_link_options(-fsanitize=undefined -fsanitize=address -fno-sanitize-recover=all) include(CodeCoverage) - set(CMAKE_CXX_FLAGS_DEBUG - "${CMAKE_CXX_FLAGS_COVERAGE} ${CMAKE_CXX_FLAGS_DEBUG}") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_COVERAGE} ${CMAKE_CXX_FLAGS_DEBUG}") setup_target_for_coverage(${PROJECT_NAME}_coverage basic_test coverage) - setup_target_for_coverage_cobertura( - ${PROJECT_NAME}_cobertura basic_test coverage - --gtest_output=xml:coverage.junit.xml) + setup_target_for_coverage_cobertura(${PROJECT_NAME}_cobertura basic_test coverage + --gtest_output=xml:coverage.junit.xml) endif() -add_library(khiopsdriver_file_gcs SHARED - src/gcsplugin.h src/gcsplugin_internal.h src/gcsplugin.cpp) +add_library(khiopsdriver_file_gcs SHARED src/gcsplugin.h src/gcsplugin_internal.h src/gcsplugin.cpp) -target_link_options(khiopsdriver_file_gcs PRIVATE $<$:-s> -)# stripping -target_link_libraries(khiopsdriver_file_gcs PRIVATE google-cloud-cpp::storage - spdlog::spdlog) +target_link_options(khiopsdriver_file_gcs PRIVATE $<$:-s>) # stripping +target_link_libraries(khiopsdriver_file_gcs PRIVATE google-cloud-cpp::storage spdlog::spdlog) -set_target_properties( - khiopsdriver_file_gcs PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} - VERSION ${PROJECT_VERSION}) +set_target_properties(khiopsdriver_file_gcs PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} VERSION ${PROJECT_VERSION}) target_compile_options( khiopsdriver_file_gcs @@ -91,8 +79,7 @@ if(BUILD_TESTS) add_executable(KhiopsPluginTest src/khiopsplugintest.cpp) target_link_libraries(KhiopsPluginTest PRIVATE fmt::fmt ${CMAKE_DL_LIBS}) add_executable(drivertest src/drivertest.cpp) - target_link_libraries(drivertest ${CMAKE_DL_LIBS} google-cloud-cpp::storage - )# Link to dl + target_link_libraries(drivertest ${CMAKE_DL_LIBS} google-cloud-cpp::storage) # Link to dl endif(BUILD_TESTS) add_subdirectory(test) @@ -111,8 +98,7 @@ set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") set(CPACK_PACKAGE_VENDOR "Orange") set(CPACK_PACKAGE_CONTACT "Khiops Team ") set(CPACK_SOURCE_IGNORE_FILES .git) -set(CPACK_PACKAGE_DESCRIPTION - "This driver allows Khiops to access the Google Cloud storage.") +set(CPACK_PACKAGE_DESCRIPTION "This driver allows Khiops to access the Google Cloud storage.") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "GCS driver for the Khiops tool") set(CPACK_PACKAGE_NAME "khiops-driver-gcs") @@ -131,15 +117,15 @@ set(CPACK_ARCHIVE_FILE_NAME kkhiops-driver-gcs-${PROJECT_VERSION}) # ########### DEB Generator ############################# -# Package release ("This is the numbering of the DEB package itself, i.e. the -# version of the packaging and not the version of the content") +# Package release ("This is the numbering of the DEB package itself, i.e. the version of the packaging and not the +# version of the content") set(CPACK_DEBIAN_PACKAGE_RELEASE 1) # package name for deb. set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) -# Packages version: the full KHIOPS_VERSION (N.N.N_aN) instead of the -# PROJECT_VERSION (N.N.N) set(CPACK_DEBIAN_PACKAGE_VERSION ${KHIOPS_VERSION}) +# Packages version: the full KHIOPS_VERSION (N.N.N_aN) instead of the PROJECT_VERSION (N.N.N) +# set(CPACK_DEBIAN_PACKAGE_VERSION ${KHIOPS_VERSION}) set(CPACK_DEB_COMPONENT_INSTALL YES) set(CPACK_DEBIAN_PACKAGE_SECTION "math") @@ -147,17 +133,15 @@ set(CPACK_DEBIAN_PACKAGE_SECTION "math") # runtime path setting set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) -# binaries in deb building will search shared library in the build tree. We -# should use directly CMAKE_LIBRARY_OUTPUT_DIRECTORY but it produces a bug in -# dpkg-shlibdeps +# binaries in deb building will search shared library in the build tree. We should use directly +# CMAKE_LIBRARY_OUTPUT_DIRECTORY but it produces a bug in dpkg-shlibdeps set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS ${CMAKE_BINARY_DIR}/lib/) # packages recommends set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "khiops") -# packages posinst and triggers -set(CPACK_DEBIAN_KNI_PACKAGE_CONTROL_EXTRA - "${PROJECT_SOURCE_DIR}/packaging/linux/debian/kni/triggers") +# packages posinst and triggers set(CPACK_DEBIAN_KNI_PACKAGE_CONTROL_EXTRA +# ${PROJECT_SOURCE_DIR}/packaging/linux/debian/kni/triggers") # set(CPACK_DEBIAN_PACKAGE_DEBUG ON) set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE) @@ -180,10 +164,8 @@ set(CPACK_RPM_FILE_NAME RPM-DEFAULT) # packages summary set(CPACK_RPM_PACKAGE_SUMMARY "Khiops tools") -# packages post/postun install scripts -# set(CPACK_RPM_KNI_POST_INSTALL_SCRIPT_FILE -# "${PROJECT_SOURCE_DIR}/packaging/linux/redhat/kni.post") -# set(CPACK_RPM_KNI_POSTUN_INSTALL_SCRIPT_FILE +# packages post/postun install scripts set(CPACK_RPM_KNI_POST_INSTALL_SCRIPT_FILE +# "${PROJECT_SOURCE_DIR}/packaging/linux/redhat/kni.post") set(CPACK_RPM_KNI_POSTUN_INSTALL_SCRIPT_FILE # "${PROJECT_SOURCE_DIR}/packaging/linux/redhat/kni.postun") include(CPack) diff --git a/cmake/modules/CodeCoverage.cmake b/cmake/modules/CodeCoverage.cmake index 0937143..9e9f419 100644 --- a/cmake/modules/CodeCoverage.cmake +++ b/cmake/modules/CodeCoverage.cmake @@ -1,32 +1,27 @@ # # 2012-01-31, Lars Bilke - Enable Code Coverage # -# 2013-09-17, Joakim Söderberg - Added support for Clang. - Some additional -# usage instructions. +# 2013-09-17, Joakim Söderberg - Added support for Clang. - Some additional usage instructions. # # USAGE: -# 1. (Mac only) If you use Xcode 5.1 make sure to patch geninfo as described -# here: http://stackoverflow.com/a/22404544/80480 +# 1. (Mac only) If you use Xcode 5.1 make sure to patch geninfo as described here: +# http://stackoverflow.com/a/22404544/80480 # # 1. Copy this file into your cmake modules path. # # 1. Add the following line to your CMakeLists.txt: INCLUDE(CodeCoverage) # -# 1. Set compiler flags to turn off optimization and enable coverage: -# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") -# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") +# 1. Set compiler flags to turn off optimization and enable coverage: SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs +# -ftest-coverage") SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") # -# 1. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target -# which runs your test executable and produces a lcov code coverage report: -# Example: SETUP_TARGET_FOR_COVERAGE( my_coverage_target # Name for custom -# target. test_driver # Name of the test driver executable that runs -# the tests. # NOTE! This should always have a ZERO as exit code # otherwise -# the coverage generation will not complete. coverage # Name of -# output directory. ) +# 1. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target which runs your test executable and +# produces a lcov code coverage report: Example: SETUP_TARGET_FOR_COVERAGE( my_coverage_target # Name for custom +# target. test_driver # Name of the test driver executable that runs the tests. # NOTE! This should always +# have a ZERO as exit code # otherwise the coverage generation will not complete. coverage # Name of output +# directory. ) # -# 1. Build a Debug build: cmake -DCMAKE_BUILD_TYPE=Debug .. make make -# my_coverage_target +# 1. Build a Debug build: cmake -DCMAKE_BUILD_TYPE=Debug .. make make my_coverage_target # # Check prereqs @@ -42,9 +37,7 @@ endif() # NOT GCOV_PATH if(NOT CMAKE_COMPILER_IS_GNUCXX) # Clang version 3.0.0 and greater now supports gcov as well. message( - WARNING - "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't." - ) + WARNING "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't.") if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") message(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") @@ -59,31 +52,21 @@ set(CMAKE_C_FLAGS_COVERAGE CACHE STRING "Flags used by the C compiler during coverage builds." FORCE) set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "" - CACHE STRING "Flags used for linking binaries during coverage builds." - FORCE) + CACHE STRING "Flags used for linking binaries during coverage builds." FORCE) set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "" - CACHE STRING - "Flags used by the shared libraries linker during coverage builds." - FORCE) -mark_as_advanced( - CMAKE_CXX_FLAGS_COVERAGE CMAKE_C_FLAGS_COVERAGE - CMAKE_EXE_LINKER_FLAGS_COVERAGE CMAKE_SHARED_LINKER_FLAGS_COVERAGE) - -if(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL - "Coverage")) - message( - WARNING - "Code coverage results with an optimized (non-Debug) build may be misleading" - ) + CACHE STRING "Flags used by the shared libraries linker during coverage builds." FORCE) +mark_as_advanced(CMAKE_CXX_FLAGS_COVERAGE CMAKE_C_FLAGS_COVERAGE CMAKE_EXE_LINKER_FLAGS_COVERAGE + CMAKE_SHARED_LINKER_FLAGS_COVERAGE) + +if(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "Coverage")) + message(WARNING "Code coverage results with an optimized (non-Debug) build may be misleading") endif() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug" -# Param _targetname The name of new the custom make target Param _testrunner -# The name of the target which runs the tests. MUST return ZERO always, even on -# errors. If not, no coverage report will be created! Param _outputname lcov -# output is generated as _outputname.info HTML report is generated in -# _outputname/index.html Optional fourth parameter is passed as arguments to -# _testrunner Pass them in list form, e.g.: "-j;2" for -j 2 +# Param _targetname The name of new the custom make target Param _testrunner The name of the target which runs the +# tests. MUST return ZERO always, even on errors. If not, no coverage report will be created! Param _outputname lcov +# output is generated as _outputname.info HTML report is generated in _outputname/index.html Optional fourth parameter +# is passed as arguments to _testrunner Pass them in list form, e.g.: "-j;2" for -j 2 function(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) if(NOT LCOV_PATH) @@ -102,37 +85,27 @@ function(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) # Run tests COMMAND ${_testrunner} ${ARGV3} # Capturing lcov counters and generating report - COMMAND ${LCOV_PATH} --directory . --capture --output-file - ${_outputname}.info - COMMAND - ${LCOV_PATH} --remove ${_outputname}.info '*/build/*' '*/tests/*' '/usr/*' - '*/vcpkg_installed/*' '*/_deps/*' --output-file - ${_outputname}.info.cleaned + COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info + COMMAND ${LCOV_PATH} --remove ${_outputname}.info '*/build/*' '*/tests/*' '/usr/*' '*/vcpkg_installed/*' '*/_deps/*' + --output-file ${_outputname}.info.cleaned COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned - COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info - ${_outputname}.info.cleaned + COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info ${_outputname}.info.cleaned WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT - "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report." - ) + COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report.") # Show info where to find the report add_custom_command( TARGET ${_targetname} POST_BUILD COMMAND ; - COMMENT - "Open ./${_outputname}/index.html in your browser to view the coverage report." - ) + COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report.") endfunction() # SETUP_TARGET_FOR_COVERAGE -# Param _targetname The name of new the custom make target Param _testrunner -# The name of the target which runs the tests Param _outputname cobertura -# output is generated as _outputname.xml Optional fourth parameter is passed as +# Param _targetname The name of new the custom make target Param _testrunner The name of the target which runs the +# tests Param _outputname cobertura output is generated as _outputname.xml Optional fourth parameter is passed as # arguments to _testrunner Pass them in list form, e.g.: "-j;2" for -j 2 -function(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner - _outputname) +function(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname) find_program(PYTHON_EXECUTABLE python) @@ -149,9 +122,8 @@ function(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner # Run tests ${_testrunner} ${ARGV3} # Running gcovr - COMMAND - ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/' -e - '${CMAKE_SOURCE_DIR}/build/' -o ${_outputname}.xml + COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/' -e '${CMAKE_SOURCE_DIR}/build/' -o + ${_outputname}.xml WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Running gcovr to produce Cobertura code coverage report.") diff --git a/generate_tests.cmake b/generate_tests.cmake index 1b6efc9..d1c4150 100644 --- a/generate_tests.cmake +++ b/generate_tests.cmake @@ -1,11 +1,12 @@ include(FetchContent) FetchContent_Declare( - googletest - GIT_REPOSITORY "https://github.com/google/googletest.git" - GIT_TAG "v1.14.0" -) + googletest + GIT_REPOSITORY "https://github.com/google/googletest.git" + GIT_TAG "v1.14.0") -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +set(gtest_force_shared_crt + ON + CACHE BOOL "" FORCE) #[==[ if(CMAKE_BUILD_TYPE STREQUAL "Release") set_property(TARGET gtest PROPERTY MSVC_RUNTIME_LIBRARY MultiThreaded) @@ -20,4 +21,4 @@ FetchContent_MakeAvailable(googletest) include(GoogleTest) enable_testing() -add_subdirectory(test) \ No newline at end of file +add_subdirectory(test) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a40cba0..bd48e0e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -22,14 +22,12 @@ target_compile_options( PRIVATE $<$:-Wall;-Wextra;-pedantic>) # MSVC requires /bigobj to build in debug config -target_compile_options( - basic_test PRIVATE $<$,$>:/bigobj>) +target_compile_options(basic_test PRIVATE $<$,$>:/bigobj>) target_include_directories(basic_test PRIVATE ${${PROJECT_NAME}_SOURCE_DIR}/src) -target_link_libraries( - basic_test PRIVATE GTest::gtest GTest::gmock GTest::gmock_main - google-cloud-cpp::storage khiopsdriver_file_gcs) +target_link_libraries(basic_test PRIVATE GTest::gtest GTest::gmock GTest::gmock_main google-cloud-cpp::storage + khiopsdriver_file_gcs) gtest_discover_tests(basic_test) @@ -40,15 +38,12 @@ target_compile_options( PRIVATE $<$:-Wall;-Wextra;-pedantic>) if(WIN32) # custom build and test execution for Windows - target_link_libraries(plugin_test PRIVATE gtest ${CMAKE_DL_LIBS} Shlwapi - )# Link to dl + target_link_libraries(plugin_test PRIVATE gtest ${CMAKE_DL_LIBS} Shlwapi) # Link to dl add_custom_command( TARGET plugin_test POST_BUILD - COMMAND - ${CMAKE_COMMAND} -E copy_if_different - $ - $ + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ + $ COMMAND_EXPAND_LISTS) else() target_link_libraries(plugin_test PRIVATE gtest ${CMAKE_DL_LIBS}) # Link to dl From 9c48428365ec4146f23a308fdc88a0c1d266ace9 Mon Sep 17 00:00:00 2001 From: bruno <97033386+bruno-at-orange@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:53:11 +0200 Subject: [PATCH 3/5] temporary commit to stop running workflows on PR --- .github/workflows/hosted-ninja-vcpkg_submod.yml | 11 ++++++----- .github/workflows/hosted-pure-workflow.yml | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/hosted-ninja-vcpkg_submod.yml b/.github/workflows/hosted-ninja-vcpkg_submod.yml index bcd76e9..09728e2 100644 --- a/.github/workflows/hosted-ninja-vcpkg_submod.yml +++ b/.github/workflows/hosted-ninja-vcpkg_submod.yml @@ -15,11 +15,12 @@ # - Finally builds the sources with Ninja, and tests as well. name: hosted-ninja-vcpkg_submod-autocache on: - push: - pull_request: - branches: - - v11 - - main + workflow_dispatch: + # push: + # pull_request: + # branches: + # - v11 + # - main jobs: job: diff --git a/.github/workflows/hosted-pure-workflow.yml b/.github/workflows/hosted-pure-workflow.yml index 24ede9b..769f50a 100644 --- a/.github/workflows/hosted-pure-workflow.yml +++ b/.github/workflows/hosted-pure-workflow.yml @@ -11,11 +11,12 @@ # build agents. name: hosted-pure-workflow on: - push: - pull_request: - branches: - - v11 - - main + workflow_dispatch: + # push: + # pull_request: + # branches: + # - v11 + # - main jobs: job: From 6c764ff81cb4c7192d790368d4d2093505726817 Mon Sep 17 00:00:00 2001 From: bruno <97033386+bruno-at-orange@users.noreply.github.com> Date: Wed, 18 Sep 2024 18:09:52 +0200 Subject: [PATCH 4/5] Add conda packaging worflow --- .github/workflows/pack-conda.yml | 164 +++++++++++++++++++++++++++++++ CMakeLists.txt | 2 +- conda/bld.bat | 18 ++++ conda/build.sh | 7 +- conda/conda_build_config.yaml | 20 ++++ 5 files changed, 206 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/pack-conda.yml create mode 100644 conda/bld.bat create mode 100644 conda/conda_build_config.yaml diff --git a/.github/workflows/pack-conda.yml b/.github/workflows/pack-conda.yml new file mode 100644 index 0000000..eb0ffb3 --- /dev/null +++ b/.github/workflows/pack-conda.yml @@ -0,0 +1,164 @@ +--- + name: Conda Packages + on: + workflow_dispatch: + defaults: + run: + shell: bash -el {0} + jobs: + build: + strategy: + fail-fast: false + matrix: + setup: + - {os: ubuntu-22.04, os-family: linux-x64} + - {os: windows-2022, os-family: win-x64} + - {os: macos-13, os-family: osx-x64} + - {os: macos-14, os-family: osx-arm64} + runs-on: ${{ matrix.setup.os }} + steps: + - name: Checkout Sources + uses: actions/checkout@v4 + with: + submodules: true + - name: Install Miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + miniforge-version: latest + python-version: '3.12' + - name: Install Dependency Requirements for Building Conda Packages + run: conda install -y conda-build + # We need MacOS SDK 10.10 to build for macOS Intel + # See: https://docs.conda.io/projects/conda-build/en/3.21.x/resources/compiler-tools.html#macos-sdk + - name: Install Mac OS SDK 10.10 + if: runner.os == 'macOS' + run: | + wget https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.10.sdk.tar.xz + sudo tar -zxvf MacOSX10.10.sdk.tar.xz -C /opt + - name: Build conda packages + run: | + conda build conda --output-folder ./builds/packages + - name: Upload conda packages artifact + uses: actions/upload-artifact@v4 + with: + name: khiops-conda-${{ matrix.setup.os-family }} + path: ./builds/packages + retention-days: 7 + # # Test Conda package on brand new environments + # test: + # needs: build + # strategy: + # fail-fast: false + # matrix: + # env: + # - {os: ubuntu-20.04, os-family: linux-64} + # - {os: ubuntu-22.04, os-family: linux-64} + # - {os: ubuntu-24.04, os-family: linux-64} + # - {os: windows-2019, os-family: win-64} + # - {os: windows-2022, os-family: win-64} + # - {os: macos-12, os-family: osx-64} + # - {os: macos-13, os-family: osx-64} + # - {os: macos-14, os-family: osx-arm64} + # runs-on: ${{ matrix.env.os }} + # steps: + # - name: Install Miniconda + # uses: conda-incubator/setup-miniconda@v3 + # with: + # miniconda-version: latest # needed for macOS 13 + # python-version: ${{ matrix.python-version }} + # - name: Download Conda Package Artifact + # uses: actions/download-artifact@v4 + # with: + # name: khiops-conda-${{ matrix.env.os-family }} + # path: ./build/conda + # - name: Install the Conda package (Windows) + # if: runner.os == 'Windows' + # run: conda install --channel ./build/conda khiops-core + # # In Linux/macOS we need the conda-forge channel to install their pinned versions + # - name: Install the Conda package (Linux/macOS) + # if: runner.os != 'Windows' + # run: | + # conda install --channel conda-forge --channel ./build/conda khiops-core + # - name: Add CONDA_PREFIX to shared PATH + # run: | + # echo "$CONDA_PREFIX/bin" >> $GITHUB_PATH + # - name: Checkout sources + # uses: actions/checkout@v4 + # - name: Test that the executables are installed + # uses: ./.github/actions/test-khiops-install + # - name: Test that khiops on Iris dataset + # uses: ./.github/actions/test-khiops-on-iris + + # # Release is only executed on tags + # # Note: For this job to work the secrets variables KHIOPS_ANACONDA_CHANNEL_TOKEN and + # # KHIOPS_DEV_ANACONDA_CHANNEL_TOKEN must be set with valid anaconda.org access tokens + # release: + # if: github.ref_type == 'tag' + # needs: test + # runs-on: ubuntu-22.04 + # permissions: + # contents: write + # steps: + # - name: Download package artifacts + # uses: actions/download-artifact@v4 + # with: + # # See the upload-artifact step in the build job for the explanation of this pattern + # path: ./build/conda + # pattern: khiops-conda-* + # merge-multiple: true + # - name: Install Miniconda + # uses: conda-incubator/setup-miniconda@v3 + # with: + # miniconda-version: latest + # python-version: '3.12' + # - name: Install requirement packages + # run: conda install -y anaconda-client conda-index + # - name: Reindex the package directory + # run: python -m conda_index ./build/conda + # - name: Upload the packages to anaconda.org + # run: | + # # Set the anaconda.org channel + # ANACONDA_CHANNEL="${{ inputs.release-channel || 'khiops-dev' }}" + + # # For the release channel: upload without forcing; do not upload kni-transfer + # if [[ "$ANACONDA_CHANNEL" == "khiops" ]] + # then + # rm -f -v ./build/conda/*/kni-transfer*.tar.bz2 + # anaconda --token "${{ secrets.KHIOPS_ANACONDA_CHANNEL_TOKEN }}" upload \ + # --user "$ANACONDA_CHANNEL" ./build/conda/*/*.tar.bz2 + # # For the dev channel: upload with forcing + # else + # anaconda --token "${{ secrets.KHIOPS_DEV_ANACONDA_CHANNEL_TOKEN }}" upload \ + # --user "$ANACONDA_CHANNEL" --force ./build/conda/*/*.tar.bz2 + # fi + # - name: Extract package version + # run: | + # PKG_VERSION=$(\ + # conda search --override-channels --channel ./build/conda/ khiops-core \ + # | awk '!/#|channels/ {print $2}' \ + # | sort -u \ + # ) + # echo "PKG_VERSION=$PKG_VERSION" >> "$GITHUB_ENV" + # - name: Create the release zip archive + # uses: thedoctor0/zip-release@0.7.6 + # with: + # type: zip + # path: ./build/conda + # filename: khiops-${{ env.PKG_VERSION }}-conda.zip + # - name: Upload conda package artifacts for all platforms + # uses: actions/upload-artifact@v4 + # with: + # name: khiops-conda-all + # path: ./khiops-${{ env.PKG_VERSION }}-conda.zip + # - name: Release the zip archive + # uses: ncipollo/release-action@v1 + # with: + # allowUpdates: true + # body: | + # **This release is for testing purposes only and there is no support for it.** + # **Go to https://khiops.org to install the latest supported version.** + # draft: false + # makeLatest: false + # prerelease: true + # updateOnlyUnreleased: true + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index d9dcf95..82b6df0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,7 +113,7 @@ set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/packages") set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) # user friendly archive names -set(CPACK_ARCHIVE_FILE_NAME kkhiops-driver-gcs-${PROJECT_VERSION}) +set(CPACK_ARCHIVE_FILE_NAME khiops-driver-gcs-${PROJECT_VERSION}) # ########### DEB Generator ############################# diff --git a/conda/bld.bat b/conda/bld.bat new file mode 100644 index 0000000..5f80123 --- /dev/null +++ b/conda/bld.bat @@ -0,0 +1,18 @@ +REM Echo all output +@echo on + +REM We need to use the subst command to shorten the paths: +REM "aws-sdk-cpp's buildsystem uses very long paths and may fail on your system. +REM We recommend moving vcpkg to a short path such as 'C:\src\vcpkg' or using the subst command." +subst W: %CD% +W: +vcpkg\vcpkg.exe install + +REM Configure project +cmake --fresh -G Ninja -D CMAKE_BUILD_TYPE=Release -D VCPKG_BUILD_TYPE=release -D CMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake -B builds/conda -S . + +REM Build +cmake --build builds/conda --target khiopsdriver_file_gcs + +REM Copy binary to conda package +cmake --install builds/conda --prefix $PREFIX \ No newline at end of file diff --git a/conda/build.sh b/conda/build.sh index 8d75f2d..95c0be9 100644 --- a/conda/build.sh +++ b/conda/build.sh @@ -4,14 +4,13 @@ set -euo pipefail # Configure project -cmake --fresh -G Ninja -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake -B conda-build -S . +cmake --fresh -G Ninja -D CMAKE_BUILD_TYPE=Release -D VCPKG_BUILD_TYPE=release -D CMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake -B builds/conda -S . # Build -cmake --build conda-build --target khiopsdriver_file_gcs +cmake --build builds/conda --target khiopsdriver_file_gcs # Copy binary to conda package -#mkdir -p $PREFIX/bin -cmake --install conda-build --prefix $PREFIX +cmake --install builds/conda --prefix $PREFIX diff --git a/conda/conda_build_config.yaml b/conda/conda_build_config.yaml new file mode 100644 index 0000000..9c810da --- /dev/null +++ b/conda/conda_build_config.yaml @@ -0,0 +1,20 @@ +--- +c_compiler: + - gcc # [linux] + - clang # [osx] + - vs2022 # [win] +c_compiler_version: + - 12 # [linux] + - 16 # [osx] +cxx_compiler: + - gxx # [linux] + - clangxx # [osx] + - vs2022 # [win] +cxx_compiler_version: + - 12 # [linux] + - 16 # [osx] +# We need MacOS SDK 10.10 to be able to build on macOS Intel +# Download: https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.10.sdk.tar.xz +# Decompress then to /opt: tar -zxvf MacOSX10.10.sdk.tar.xz -C /opt +CONDA_BUILD_SYSROOT: + - /opt/MacOSX10.10.sdk # [osx and not arm64] From bca633c9260d591a96b5cc549b874fb3abbe07db Mon Sep 17 00:00:00 2001 From: bruno <97033386+bruno-at-orange@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:10:56 +0200 Subject: [PATCH 5/5] Add action to build RPM packages --- .github/workflows/pack-rpm.yml | 62 ++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/pack-rpm.yml diff --git a/.github/workflows/pack-rpm.yml b/.github/workflows/pack-rpm.yml new file mode 100644 index 0000000..0e13f3c --- /dev/null +++ b/.github/workflows/pack-rpm.yml @@ -0,0 +1,62 @@ +--- +name: RPM Packages +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + strategy: + fail-fast: false + matrix: + image: ['rockylinux:8', 'rockylinux:9'] + container: + image: ${{ matrix.image }} + steps: + - name: Install packages + run: | + dnf upgrade -y + dnf install -y gcc-c++ make rpm-build # we do not use ninja because it is not in the dnf repo + dnf install -y git perl # for vcpkg + # Note: We install cmake from kitware's site to have a more recent version + curl -LO "https://github.com/Kitware/CMake/releases/download/v3.26.5/cmake-3.26.5-linux-x86_64.sh" + sh cmake-3.26.5-linux-x86_64.sh --prefix=/usr/local/ --exclude-subdir + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: true + + - name: Configure CMake + run: | + cmake -B builds -S . -G 'Unix Makefiles' -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake + - name: Build + run: | + cmake --build builds --target khiopsdriver_file_gcs + - name: Build package with CPack + run: cd builds/ && cpack -G RPM + - name: Set environment variables + run: | + source /etc/os-release + echo "ID=$ID" >> "$GITHUB_ENV" + VERSION_CODENAME=$(echo $PLATFORM_ID | cut -d":" -f2) + echo "VERSION_CODENAME=$VERSION_CODENAME" >> "$GITHUB_ENV" + - name: Rename packages with codename + run: | + source /etc/os-release + ARCH=$(arch) + cd builds/packages + for filename in *.rpm + do + mv -v $filename ${filename%.${ARCH}*}.${{ env.VERSION_CODENAME }}.${ARCH}.rpm + done + - name: Upload the packages as artifacts + uses: actions/upload-artifact@v4 + with: + # We add a `rpm-` prefix so we can later recover all artifacts with the pattern `rpm-*` + # Note: The more natural pattern `*-rpm` or `*` does not work + name: rpm-${{ env.ID }}-${{ env.VERSION_CODENAME }} + path: builds/packages/*.rpm + if-no-files-found: error