From a5ccf0ee50f8adba4d03b8482e89f4a06f3c47f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Wed, 1 Nov 2023 11:39:56 +0100 Subject: [PATCH 1/4] Create build.yml --- .github/workflows/build.yml | 87 +++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..9da7282 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,87 @@ +--- +name: Build + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ${{ matrix.runner }} + env: + CCACHE_DIR: ${{ github.workspace }}/CCACHE + CMAKE_GENERATOR: Ninja + CMAKE_BUILD_TYPE: Release + CTEST_OUTPUT_ON_FAILURE: 1 + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-linux-cc + runner: ubuntu-latest + tools-install: | + sudo apt-get -qq update + sudo apt-get -qq install cmake ninja-build ccache g++ + - target: x86_64-darwin-cc + runner: macos-11 + xcode: '13.2.1' + tools-install: | + brew install bash coreutils cmake ninja ccache + + steps: + - name: Checkout Source + uses: actions/checkout@v3 + + - name: Install Build Tools + run: ${{ matrix.tools-install }} + + - name: Setup Xcode (macOS) + if: ${{ matrix.xcode }} + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - name: Setup Environment + run: | + TARGET=${{ matrix.target }} + WORKSPACE=${{ github.workspace }} + echo "TARGET=$TARGET" >> $GITHUB_ENV + # echo "CMAKE_TOOLCHAIN_FILE=$WORKSPACE/cmake/toolchain/$TARGET.cmake" >> $GITHUB_ENV + echo "CMAKE_INSTALL_PREFIX=$WORKSPACE/$TARGET" >> $GITHUB_ENV + echo "BUILD_DIR=build-$TARGET" >> $GITHUB_ENV + + - name: Compute CCache Keys + id: ccache-keys + run: | + key2=ccache-${{env.TARGET}}- + key1="${key2}$(date +%V)" + echo "key1=${key1}" >> $GITHUB_OUTPUT + echo "key2=${key2}" >> $GITHUB_OUTPUT + + - name: Restore CCache + id: ccache-restore + uses: actions/cache@v3 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache-keys.outputs.key1 }} + restore-keys: ${{ steps.ccache-keys.outputs.key2 }} + + - name: CCache Ready Stats + run: ccache --show-stats + + - name: Configure + run: cmake -B "$BUILD_DIR" -S . -DFIND_FATAL=ON + - name: Compile + run: cmake --build "$BUILD_DIR" --config $CMAKE_BUILD_TYPE + - name: Test + if: ${{ ! matrix.test-disable }} + run: ctest --test-dir "$BUILD_DIR" --config $CMAKE_BUILD_TYPE + - name: Install + run: cmake --install "$BUILD_DIR" --config $CMAKE_BUILD_TYPE --prefix "$CMAKE_INSTALL_PREFIX" + - name: Display Assets + working-directory: ${{ env.CMAKE_INSTALL_PREFIX }} + run: ls -R + + - name: CCache Show Stats + run: ccache --show-stats From d14f6dd1af07d1fdcf7eb9657004ba627a4b225f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Wed, 1 Nov 2023 11:45:26 +0100 Subject: [PATCH 2/4] Added boost to the tools installation --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9da7282..ed8f49e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: CCACHE_DIR: ${{ github.workspace }}/CCACHE CMAKE_GENERATOR: Ninja CMAKE_BUILD_TYPE: Release - CTEST_OUTPUT_ON_FAILURE: 1 + CTEST_OUTPUT_ON_FAILURE: 1 strategy: fail-fast: false matrix: @@ -23,12 +23,12 @@ jobs: runner: ubuntu-latest tools-install: | sudo apt-get -qq update - sudo apt-get -qq install cmake ninja-build ccache g++ + sudo apt-get -qq install cmake ninja-build ccache g++ libboost-dev - target: x86_64-darwin-cc runner: macos-11 xcode: '13.2.1' tools-install: | - brew install bash coreutils cmake ninja ccache + brew install bash coreutils cmake ninja ccache boost steps: - name: Checkout Source From 358a4e795b7e89580eccec4d6edbf7378da11935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Wed, 1 Nov 2023 11:48:42 +0100 Subject: [PATCH 3/4] Added CCache to CMakeLists.txt to minimize build times --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 50b785a..c1a66a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,15 @@ cmake_minimum_required(VERSION 3.7) cmake_policy(SET CMP0048 NEW) project(libprlearn VERSION 1.0.0 LANGUAGES CXX) + +find_program(CCACHE_PROGRAM ccache) +if(CCACHE_PROGRAM) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM}) + message(STATUS "Enabled ccache: ${CCACHE_PROGRAM}") +else(CCACHE_PROGRAM) + message(STATUS "Failed to find ccache") +endif(CCACHE_PROGRAM) + if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif(NOT CMAKE_BUILD_TYPE) From b2e747fbea518212662ecc80dd10fee33892b40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Wed, 1 Nov 2023 11:50:18 +0100 Subject: [PATCH 4/4] Switched to debug builds to fail-fast --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ed8f49e..4d1c96e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: env: CCACHE_DIR: ${{ github.workspace }}/CCACHE CMAKE_GENERATOR: Ninja - CMAKE_BUILD_TYPE: Release + CMAKE_BUILD_TYPE: Debug CTEST_OUTPUT_ON_FAILURE: 1 strategy: fail-fast: false @@ -69,7 +69,7 @@ jobs: - name: CCache Ready Stats run: ccache --show-stats - + - name: Configure run: cmake -B "$BUILD_DIR" -S . -DFIND_FATAL=ON - name: Compile