|
| 1 | +name: CMake CI |
| 2 | +on: [push, pull_request] |
| 3 | + |
| 4 | +jobs: |
| 5 | + build: |
| 6 | + name: CMake on ${{ matrix.os }} with ${{ matrix.dependencies }} |
| 7 | + runs-on: ${{ matrix.os }} |
| 8 | + strategy: |
| 9 | + fail-fast: false |
| 10 | + matrix: |
| 11 | + os: [macOS-latest, ubuntu-18.04, windows-2016] |
| 12 | + dependencies: [submodule, vcpkg] |
| 13 | + steps: |
| 14 | + - name: Checkout source |
| 15 | + uses: actions/checkout@v2 |
| 16 | + |
| 17 | + - name: Checkout submodules |
| 18 | + if: matrix.dependencies == 'submodule' |
| 19 | + shell: bash |
| 20 | + run: | |
| 21 | + auth_header="$(git config --local --get http.https://github.com/.extraheader)" |
| 22 | + git submodule sync --recursive |
| 23 | + git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 |
| 24 | +
|
| 25 | + - name: Mount vcpkg cache |
| 26 | + if: matrix.dependencies == 'vcpkg' |
| 27 | + uses: actions/cache@v2 |
| 28 | + with: |
| 29 | + path: "~/.cache/vcpkg/archives" |
| 30 | + key: vcpkg-${{ matrix.os }} |
| 31 | + |
| 32 | + - name: Install vcpkg dependencies |
| 33 | + if: matrix.dependencies == 'vcpkg' |
| 34 | + run: vcpkg install benchmark civetweb curl[core] gtest zlib |
| 35 | + |
| 36 | + - name: Generate German locale on Ubuntu |
| 37 | + if: runner.os == 'Linux' |
| 38 | + run: | |
| 39 | + sudo apt-get remove -y --purge man-db # avoid time-consuming trigger |
| 40 | + sudo apt-get update |
| 41 | + sudo apt-get install -y locales |
| 42 | + sudo locale-gen de_DE.UTF-8 # used by SerializerTest |
| 43 | +
|
| 44 | + - name: Install ninja on Ubuntu |
| 45 | + if: runner.os == 'Linux' |
| 46 | + run: | |
| 47 | + sudo apt-get install -y ninja-build |
| 48 | +
|
| 49 | + - name: Install ninja on macOS |
| 50 | + if: runner.os == 'macOS' |
| 51 | + run: brew install ninja |
| 52 | + |
| 53 | + - name: "Configure for Unix with internal dependencies" |
| 54 | + if: matrix.dependencies == 'submodule' && runner.os != 'Windows' |
| 55 | + run: cmake -DUSE_THIRDPARTY_LIBRARIES=ON -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/_install -DENABLE_WARNINGS_AS_ERRORS=ON -DENABLE_COMPRESSION=OFF -DENABLE_PUSH=OFF -DCMAKE_DEBUG_POSTFIX=_d -DCMAKE_CONFIGURATION_TYPES='Release;Debug' -G"Ninja Multi-Config" -S ${{ github.workspace }} -B ${{ github.workspace }}/_build |
| 56 | + |
| 57 | + - name: "Configure for Windows with internal dependencies" |
| 58 | + if: matrix.dependencies == 'submodule' && runner.os == 'Windows' |
| 59 | + run: cmake -DUSE_THIRDPARTY_LIBRARIES=ON -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/_install -DENABLE_WARNINGS_AS_ERRORS=ON -DENABLE_COMPRESSION=OFF -DENABLE_PUSH=OFF -DCMAKE_DEBUG_POSTFIX=_d -S ${{ github.workspace }} -B ${{ github.workspace }}/_build |
| 60 | + |
| 61 | + - name: "Configure for Unix with vcpkg dependencies" |
| 62 | + if: matrix.dependencies == 'vcpkg' && runner.os != 'Windows' |
| 63 | + run: cmake -DUSE_THIRDPARTY_LIBRARIES=OFF -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/_install "-DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" -DCMAKE_DEBUG_POSTFIX=_d -DCMAKE_CONFIGURATION_TYPES='Release;Debug' -G"Ninja Multi-Config" -S ${{ github.workspace }} -B ${{ github.workspace }}/_build |
| 64 | + |
| 65 | + - name: "Configure for Windows with vcpkg dependencies" |
| 66 | + if: matrix.dependencies == 'vcpkg' && runner.os == 'Windows' |
| 67 | + run: cmake -DUSE_THIRDPARTY_LIBRARIES=OFF -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/_install "-DCMAKE_TOOLCHAIN_FILE=${Env:VCPKG_INSTALLATION_ROOT}\scripts\buildsystems\vcpkg.cmake" -DCMAKE_DEBUG_POSTFIX=_d -S ${{ github.workspace }} -B ${{ github.workspace }}/_build |
| 68 | + |
| 69 | + - name: "Build Debug" |
| 70 | + run: cmake --build ${{ github.workspace }}/_build --config Debug |
| 71 | + |
| 72 | + - name: "Build Release" |
| 73 | + run: cmake --build ${{ github.workspace }}/_build --config Release |
| 74 | + |
| 75 | + - name: "Test Debug" |
| 76 | + run: ctest -C Debug -V -LE Benchmark |
| 77 | + working-directory: "${{ github.workspace }}/_build" |
| 78 | + |
| 79 | + - name: "Test Release" |
| 80 | + run: ctest -C Debug -V -LE Benchmark |
| 81 | + working-directory: "${{ github.workspace }}/_build" |
| 82 | + |
| 83 | + - name: "Install Debug" |
| 84 | + run: cmake --install ${{ github.workspace }}/_build --config Debug |
| 85 | + |
| 86 | + - name: "Install Release" |
| 87 | + run: cmake --install ${{ github.workspace }}/_build --config Release |
| 88 | + |
| 89 | + - name: "Configure CMake import for Unix with internal dependencies" |
| 90 | + if: matrix.dependencies == 'submodule' && runner.os != 'Windows' |
| 91 | + run: cmake -Dprometheus-cpp_DIR=${{ github.workspace }}/_install/lib/cmake/prometheus-cpp -DCMAKE_CONFIGURATION_TYPES='Release;Debug' -G"Ninja Multi-Config" -S ${{ github.workspace }}/cmake/project-import-cmake -B ${{ github.workspace }}/_import_cmake |
| 92 | + |
| 93 | + - name: "Configure CMake import for Windows with internal dependencies" |
| 94 | + if: matrix.dependencies == 'submodule' && runner.os == 'Windows' |
| 95 | + run: cmake -Dprometheus-cpp_DIR=${{ github.workspace }}/_install/lib/cmake/prometheus-cpp -S ${{ github.workspace }}/cmake/project-import-cmake -B ${{ github.workspace }}/_import_cmake |
| 96 | + |
| 97 | + - name: "Configure CMake import for Unix with vcpkg dependencies" |
| 98 | + if: matrix.dependencies == 'vcpkg' && runner.os != 'Windows' |
| 99 | + run: cmake -Dprometheus-cpp_DIR=${{ github.workspace }}/_install/lib/cmake/prometheus-cpp "-DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" -DCMAKE_CONFIGURATION_TYPES='Release;Debug' -G"Ninja Multi-Config" -S ${{ github.workspace }}/cmake/project-import-cmake -B ${{ github.workspace }}/_import_cmake |
| 100 | + |
| 101 | + - name: "Configure CMake import for Windows with vcpkg dependencies" |
| 102 | + if: matrix.dependencies == 'vcpkg' && runner.os == 'Windows' |
| 103 | + run: cmake -Dprometheus-cpp_DIR=${{ github.workspace }}/_install/lib/cmake/prometheus-cpp "-DCMAKE_TOOLCHAIN_FILE=${Env:VCPKG_INSTALLATION_ROOT}\scripts\buildsystems\vcpkg.cmake" -S ${{ github.workspace }}/cmake/project-import-cmake -B ${{ github.workspace }}/_import_cmake |
| 104 | + |
| 105 | + - name: "Build CMake import Debug" |
| 106 | + run: cmake --build ${{ github.workspace }}/_import_cmake --config Debug |
| 107 | + |
| 108 | + - name: "Build CMake import Release" |
| 109 | + run: cmake --build ${{ github.workspace }}/_import_cmake --config Release |
| 110 | + |
| 111 | + - name: "Configure for Unix Shared Libs with internal dependencies" |
| 112 | + if: matrix.dependencies == 'submodule' && runner.os != 'Windows' |
| 113 | + run: cmake -DUSE_THIRDPARTY_LIBRARIES=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/_install_shared -DENABLE_WARNINGS_AS_ERRORS=ON -DENABLE_COMPRESSION=OFF -DENABLE_PUSH=OFF -DCMAKE_DEBUG_POSTFIX=_d -GNinja -S ${{ github.workspace }} -B ${{ github.workspace }}/_build_shared |
| 114 | + |
| 115 | + - name: "Build for Unix Shared Libs" |
| 116 | + if: matrix.dependencies == 'submodule' && runner.os != 'Windows' |
| 117 | + run: cmake --build ${{ github.workspace }}/_build_shared |
| 118 | + |
| 119 | + - name: "Install for Unix Shared Libs" |
| 120 | + if: matrix.dependencies == 'submodule' && runner.os != 'Windows' |
| 121 | + run: cmake --install ${{ github.workspace }}/_build_shared |
| 122 | + |
| 123 | + - name: "Configure pkg-config import for Unix" |
| 124 | + if: matrix.dependencies == 'submodule' && runner.os != 'Windows' |
| 125 | + run: cmake -DCMAKE_PREFIX_PATH=${{ github.workspace }}/_install_shared -GNinja -S ${{ github.workspace }}/cmake/project-import-pkgconfig -B ${{ github.workspace }}/_import_pkgconfig |
| 126 | + |
| 127 | + - name: "Build pkg-config import for Unix" |
| 128 | + if: matrix.dependencies == 'submodule' && runner.os != 'Windows' |
| 129 | + run: cmake --build ${{ github.workspace }}/_import_pkgconfig |
0 commit comments