From 903e020c17d587193c6da5ae36cf5c279cca154a Mon Sep 17 00:00:00 2001 From: alandefreitas <alandefreitas@gmail.com> Date: Fri, 26 May 2023 18:17:03 -0300 Subject: [PATCH] ci: all workflows support libxml2 --- .github/actions/boost_clone/action.yml | 120 ------------------- .github/actions/cmake_run/action.yml | 132 --------------------- .github/actions/package_install/action.yml | 112 ----------------- .github/workflows/ci.yml | 9 +- 4 files changed, 6 insertions(+), 367 deletions(-) delete mode 100644 .github/actions/boost_clone/action.yml delete mode 100644 .github/actions/cmake_run/action.yml delete mode 100644 .github/actions/package_install/action.yml diff --git a/.github/actions/boost_clone/action.yml b/.github/actions/boost_clone/action.yml deleted file mode 100644 index 2bca90cfe..000000000 --- a/.github/actions/boost_clone/action.yml +++ /dev/null @@ -1,120 +0,0 @@ -name: 'Boost Clone' -description: 'This workflow clones the boost source directory, attempting to get it from the cache first' -inputs: - boost_dir: - description: 'The boost directory. The default value assumes boost is in-source.' - required: false - default: 'boost' - branch: - description: 'Branch of the super-project' - required: false - default: 'master' - patches: - description: 'Libraries used to patch the boost installation' - required: true - default: '' - modules: - description: 'The boost submodules we need to clone' - required: false - default: '' - -runs: - using: "composite" - steps: - - name: Environment - id: ctx - shell: bash - run: | - boost_hash=$(git ls-remote https://github.com/boostorg/boost.git ${{ inputs.branch }} | awk '{ print $1 }') - echo "boost_hash=$boost_hash" >> $GITHUB_OUTPUT - - # Create cache hash - cache_hash=${{ runner.os }}-boost-$boost_hash - # Add modules names to hash - modules=${{ inputs.modules }} - for module in ${modules//,/ } - do - module_filename=${module##*/} - cache_hash=$cache_hash-$module_filename - done - # Add patch names and hashes to hash - patches=${{ inputs.patches }} - for patch in ${patches//,/ } - do - patch_hash=$(git ls-remote $patch ${{ inputs.branch }} | awk '{ print $1 }') - cache_hash=$cache_hash-$patch-$patch_hash - done - echo "cache_hash=$cache_hash" >> $GITHUB_OUTPUT - - # attempt to get boost from the cache before cloning it - - name: boost cache - id: cache-boost - uses: actions/cache@v3 - with: - path: boost - key: ${{ steps.ctx.outputs.cache_hash }} - - # clone (if boost not found in cache) - - name: boost clone - if: steps.cache-boost.outputs.cache-hit != 'true' - shell: bash - run: | - git clone https://github.com/boostorg/boost.git -b ${{ inputs.branch }} ${{ inputs.boost_dir }} - - # apply patches (if boost not found in cache) - - name: boost patches - if: steps.cache-boost.outputs.cache-hit != 'true' && inputs.patches != '' - shell: bash - working-directory: ${{ inputs.boost_dir }}/libs - run: | - # Apply boost patches ${{ inputs.patches }} - patches=${{ inputs.patches }} - for patch in ${patches//,/ } - do - git clone $patch -b ${{ inputs.branch }} - done - - # Init all submodules (if boost not found in cache + no specific modules specified) - - name: boost init submodules - if: (steps.cache-boost.outputs.cache-hit != 'true' && inputs.modules == '') - working-directory: ${{ inputs.boost_dir }} - shell: bash - run: | - # Init all boost submodules - git submodule update --init --recursive - - # Init specified submodules (if boost not found in cache + modules specified) - - name: boost patches - if: (steps.cache-boost.outputs.cache-hit != 'true' && inputs.modules != '') - working-directory: ${{ inputs.boost_dir }} - shell: bash - run: | - # Init required boost submodules - echo "Look for python" - if command -v python &> /dev/null; then - python_executable="python" - elif command -v python3 &> /dev/null; then - python_executable="python3" - elif command -v python2 &> /dev/null; then - python_executable="python2" - else - echo "Please install Python!" >&2 - false - fi - echo "python_executable=$python_executable" - - echo "Init boostdep" - git submodule update -q --init tools/boostdep - - echo "Run boostdep for required modules: ${{ inputs.modules }}" - modules=${{ inputs.modules }} - for module in ${modules//,/ } - do - echo "Init submodule $module" - git submodule update -q --init libs/$module || true - done - for module in ${modules//,/ } - do - echo "Run boostdep for required module $module" - $python_executable tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --include source $module - done diff --git a/.github/actions/cmake_run/action.yml b/.github/actions/cmake_run/action.yml deleted file mode 100644 index 048fc8daf..000000000 --- a/.github/actions/cmake_run/action.yml +++ /dev/null @@ -1,132 +0,0 @@ -name: 'Install dependencies' -description: 'This workflow installs dependencies from multiple package managers' -inputs: - cmake_exec: - description: 'The cmake executable' - required: false - default: 'cmake' - cc: - description: 'Path to C compiler.' - required: false - default: '' - cxx: - description: 'Path to C++ compiler.' - required: false - default: '' - cxxstd: - description: 'List of standards with which cmake will build and test the program.' - required: false - default: '' - source_dir: - description: 'Path to the source directory.' - required: false - default: '' - toolchain: - description: 'Path to toolchain.' - required: false - default: '' - build-type: - description: 'Build type.' - required: false - default: 'Release' - build-target: - description: 'Targets to build instead of the default target' - required: false - default: '' - install-prefix: - description: 'Path where the library should be installed.' - required: false - default: '.local/usr' - run-tests: - description: 'Whether we should run tests.' - required: false - default: 'true' - extra-args: - description: 'Extra arguments to cmake configure command.' - required: false - default: '' - -runs: - using: "composite" - steps: - - name: Get CPU cores - uses: SimenB/github-actions-cpu-cores@v1 - id: cpu-cores - - - name: Setup msvc dev-cmd - if: runner.os == 'Windows' - uses: ilammy/msvc-dev-cmd@v1 - - - name: CMake Build C++${{ inputs.cxxstd }} - shell: bash - working-directory: ${{ inputs.source_dir }} - run: | - set -xe - - # cmake args - cc=${{ matrix.cc }} - if [ "$cc" != "" ]; then - if command -v $cc &> /dev/null; then - cc="$(which $cc)" - elif command -v /usr/bin/$cc &> /dev/null; then - cc="/usr/bin/$cc" - fi - cmake_cc_path_args="-D CMAKE_C_COMPILER=$cc" - else - cmake_cc_path_args= - fi - - cxx=${{ matrix.cxx }} - if [ "$cxx" != "" ]; then - if command -v $cxx &> /dev/null; then - cxx="$(which $cxx)" - elif command -v /usr/bin/$cxx &> /dev/null; then - cxx="/usr/bin/$cxx" - fi - cmake_cxx_path_args="-D CMAKE_CXX_COMPILER=$cxx" - else - cmake_cxx_path_args= - fi - - cxxstds=${{ inputs.cxxstd }} - if [ "$cxxstds" == "" ]; then - cxxstds=defaultcxx - fi - - cmake_toolchain=${{ inputs.toolchain }} - if [ "$cmake_toolchain" != "" ]; then - cmake_toolchain_arg="-D CMAKE_TOOLCHAIN_FILE=$cmake_toolchain" - else - cmake_toolchain_arg= - fi - - run_tests=${{ inputs.run-tests }} - if [ "$run_tests" == "true" ]; then - cmake_enable_test_args="-D BUILD_TESTING=ON" - fi - - build_target=${{ inputs.build-target }} - if [ "$build_target" != "" ]; then - target_args="--target $build_target" - else; then - target_args="--target all" - fi - - # iterate stds - for cxxstd in ${cxxstds//,/ } - do - echo "==================================> CMAKE: C++$cxxstd" - if [ "$cxxstd" == "defaultcxx" ]; then - cmake_cxxstd_arg="" - build_dir="build" - else - cmake_cxxstd_arg="-D CMAKE_CXX_STANDARD=$cxxstd" - build_dir="build-$cxxstd" - fi - cmake -S . -B $build_dir -D CMAKE_BUILD_TYPE=${{ inputs.build-type }} $cmake_toolchain_arg $cmake_cxxstd_arg ${{ inputs.extra-args }} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -D CMAKE_INSTALL_PREFIX=${{ inputs.install-prefix }} $cmake_cc_path_args $cmake_cxx_path_args $cmake_enable_test_args - cmake --build $build_dir --config ${{ inputs.build-type }} -j ${{ steps.cpu-cores.outputs.count }} $target_args - cmake --install $build_dir --config ${{ inputs.build-type }} --prefix prefix - if [ "$run_tests" == "true" ]; then - ctest --test-dir "$build_dir" -j ${{ steps.cpu-cores.outputs.count }} -C ${{ inputs.build-type }} --no-tests=error --progress --output-on-failure - fi - done diff --git a/.github/actions/package_install/action.yml b/.github/actions/package_install/action.yml deleted file mode 100644 index 7c5a4d5c6..000000000 --- a/.github/actions/package_install/action.yml +++ /dev/null @@ -1,112 +0,0 @@ -name: 'Install dependencies' -description: 'This workflow installs dependencies from multiple package managers' -inputs: - vcpkg: - description: 'List of packages we should install with vcpkg.' - required: false - default: '' - apt-get: - description: 'List of packages we should install with apt-get.' - required: false - default: '' - vcpkg_triplet: - description: 'The triplet used by vcpkg to install packages.' - required: false - default: '' - vcpkg_dir: - description: 'The directory where vcpkg should be cloned and installed.' - required: false - default: 'vcpkg' - vcpkg_branch: - description: 'vcpkg branch we should use' - required: false - default: 'master' -outputs: - vcpkg_toolchain: - description: "vcpkg toolchain file" - value: ${{ steps.ctx.outputs.vcpkg_toolchain }} - -runs: - using: "composite" - steps: - - name: Environment - id: ctx - shell: bash - run: | - set -xe - - # vcpkg hash - vcpkg_hash="$(git ls-remote https://github.com/microsoft/vcpkg.git ${{ inputs.vcpkg_branch }} | awk '{ print $1 }')" - echo "vcpkg_hash=$vcpkg_hash" >> $GITHUB_OUTPUT - - # vcpkg triplet - default_triplet="${{ (runner.os == 'Windows' && 'x64-windows') || (runner.os == 'Linux' && 'x64-linux') || (runner.os == 'macOS' && 'x64-osx') || '' }}" - input_triplet=${{ inputs.vcpkg_triplet }} - if [ "$input_triplet" == "" ]; then - triplet=$default_triplet - else - triplet=$input_triplet - fi - echo "triplet=$triplet" >> $GITHUB_OUTPUT - if [ "$triplet" == "" ]; then - triplet_suffix="" - else - triplet_suffix=":$triplet" - fi - echo "triplet_suffix=$triplet_suffix" >> $GITHUB_OUTPUT - - # vcpkg executable - vcpkg_target_dir=${{ inputs.vcpkg_dir }} - if [[ $vcpkg_target_dir == /* ]]; then - vcpkg_exec_dir=$vcpkg_target_dir - else - vcpkg_exec_dir=./$vcpkg_target_dir - fi - vcpkg_bs_exe="${{ (runner.os == 'Windows' && '$vcpkg_exec_dir/bootstrap-vcpkg.bat') || '$vcpkg_exec_dir/bootstrap-vcpkg.sh' }}" - echo "vcpkg_bs_exe=$vcpkg_bs_exe" >> $GITHUB_OUTPUT - - # vcpkg toolchain - vcpkg_toolchain=$vcpkg_exec_dir/scripts/buildsystems/vcpkg.cmake - echo "vcpkg_toolchain=$vcpkg_toolchain" >> $GITHUB_OUTPUT - - # vcpkg cache hash - vcpkg_cache_hash="${{ runner.os }}-$vcpkg_hash$triplet_suffix" - vcpkg_packages=${{ inputs.vcpkg }} - for package in ${vcpkg_packages//,/ } - do - vcpkg_cache_hash=$vcpkg_cache_hash-$package - done - echo "vcpkg_cache_hash=$vcpkg_cache_hash" >> $GITHUB_OUTPUT - - # Install packages on ubuntu - # https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context - - name: apt-get packages - shell: bash - if: ${{ runner.os == 'Linux' && inputs.apt-get }} - run: | - sudo apt-get update - sudo apt-get install -y ${{ inputs.apt-get }} - - # Attempt to get vcpkg with its packages from the cache before cloning it - # The cache key includes the vcpkg version, os, packages and triplet - - name: vcpkg cache - if: ${{ inputs.vcpkg }} - id: cache-vcpkg - uses: actions/cache@v3 - with: - path: ${{ inputs.vcpkg_dir }} - key: ${{ steps.ctx.outputs.vcpkg_cache_hash }} - - - name: vcpkg install - if: steps.cache-vcpkg.outputs.cache-hit != 'true' && inputs.vcpkg != '' - shell: bash - run: | - set -xe - git clone https://github.com/microsoft/vcpkg.git -b ${{ inputs.vcpkg_branch }} ${{ inputs.vcpkg_dir }} - ${{ steps.ctx.outputs.vcpkg_bs_exe }} - cd ${{ inputs.vcpkg_dir }} - packages=${{ inputs.vcpkg }} - for package in ${packages//,/ } - do - vcpkg install $package${{ steps.ctx.outputs.triplet_suffix }} - done diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81608d347..154e494f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,8 +24,8 @@ jobs: matrix: include: - { name: "MSVC 14.3 - C++20", os: windows-2022, std: '20', cmake_args: -G "Visual Studio 17 2022" -A x64, github_release: true } - - { name: "GCC 13 - C++20", os: ubuntu-22.04, compiler: gcc, version: 13.1, std: '20', github_release: true, install: "ninja-build"} - - { name: "Clang 16 - C++20", os: ubuntu-22.04, compiler: clang, version: 16, std: 20, install: "libxml2-utils ninja-build" } + - { name: "GCC 13 - C++20", os: ubuntu-22.04, compiler: gcc, version: 13.1, std: '20', github_release: true, install: "openjdk-11-jdk ninja-build" } + - { name: "Clang 16 - C++20", os: ubuntu-22.04, compiler: clang, version: 16, std: 20, install: "openjdk-11-jdk ninja-build" } name: ${{ matrix.name }} runs-on: ${{ matrix.os }} @@ -61,11 +61,13 @@ jobs: update-ld-library-path: true - name: Install packages - if: ${{ matrix.install }} uses: alandefreitas/cpp-actions/package-install@v1.2.1 id: package-install with: apt-get: ${{ matrix.install }} + vcpkg: libxml2[tools] + cxx: ${{ steps.setup-cpp.outputs.cxx }} + cc: ${{ steps.setup-cpp.outputs.cc }} - name: CMake Workflow (C++${{ matrix.std }}) uses: alandefreitas/cpp-actions/cmake-workflow@v1.2.1 @@ -74,6 +76,7 @@ jobs: cxxstd: ${{ matrix.std }} cxx: ${{ steps.setup-cpp.outputs.cxx }} cc: ${{ steps.setup-cpp.outputs.cc }} + toolchain: ${{ steps.package-install.outputs.vcpkg-toolchain }} generator: Ninja install-prefix: .local extra-args: ${{ format('-D LLVM_ROOT="{0}" -D Clang_ROOT="{0}" -D CMAKE_EXPORT_COMPILE_COMMANDS=ON', steps.llvm-install.outputs.llvm-dir || '/usr/local') }}