From 7302c60481dfe876e5f0cc9ad26aa40b820b8ca0 Mon Sep 17 00:00:00 2001 From: Nikola Ducak Date: Sat, 25 May 2024 14:09:51 +0200 Subject: [PATCH] ci: build on windows and mac --- .github/workflows/build-and-test-matrix.yml | 113 ++++++++++++++++++ .github/workflows/conventional-commits.yml | 2 +- .github/workflows/pr-check.yml | 84 +------------ .github/workflows/release.yml | 63 ++-------- ...ux-to-windows-crosscompile-toolchain.cmake | 10 -- source/log/annual_log_data.hpp | 3 + source/view/annual_view.cpp | 3 + 7 files changed, 136 insertions(+), 142 deletions(-) create mode 100644 .github/workflows/build-and-test-matrix.yml delete mode 100644 cmake/linux-to-windows-crosscompile-toolchain.cmake diff --git a/.github/workflows/build-and-test-matrix.yml b/.github/workflows/build-and-test-matrix.yml new file mode 100644 index 0000000..5dc6544 --- /dev/null +++ b/.github/workflows/build-and-test-matrix.yml @@ -0,0 +1,113 @@ +name: Build and test matrix + +on: + workflow_call: + inputs: + version: + description: 'Version of the caps-log' + required: false + default: '' + type: string + run_tests: + description: 'Whether to run tests' + required: false + default: false + type: boolean + build_type: + description: 'Build type (e.g., Debug, Release)' + required: true + type: string + release_name: + description: 'Name of the release' + required: false + default: '' + type: string + +jobs: + build_and_test_windows: + runs-on: windows-latest + steps: + - name: Get deps + run: | + choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' + choco install boost-msvc-14.1 + choco install libgit2 + - name: Configure environment + run: | + $libgit2_root = "C:\ProgramData\chocolatey\lib\libgit2\tools" + echo "LIBGIT2_INCLUDE_DIR=$libgit2_root\include" >> $env:GITHUB_ENV + echo "LIBGIT2_LIBRARY=$libgit2_root\lib\libgit2.lib" >> $env:GITHUB_ENV + echo "CMAKE_PREFIX_PATH=C:\Program Files\libgit2" >> $env:GITHUB_ENV + - uses: actions/checkout@v4 + - name: CMake configure + run: | + if ('${{ inputs.run_tests }}' -eq 'true') { $CAPS_LOG_BUILD_TESTS = 'On' } else { $CAPS_LOG_BUILD_TESTS = 'Off' } + cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DCAPS_LOG_BUILD_TESTS=$CAPS_LOG_BUILD_TESTS -DBOOST_ROOT=C:\local\boost -DCMAKE_PREFIX_PATH="C:\local\boost;C:\Program Files\libgit2" -DLIBGIT2_INCLUDE_DIR=$env:LIBGIT2_INCLUDE_DIR -DLIBGIT2_LIBRARY=$env:LIBGIT2_LIBRARY + + - name: CMake build + run: cmake --build ${{ github.workspace }}/build --config ${{ inputs.build_type }} + - name: Test + if: ${{ inputs.run_tests == true }} + working-directory: ${{ github.workspace }}/build + run: ctest -C ${{ inputs.build_type }} --output-on-failure + - name: Upload + if: ${{ inputs.release_name != '' }} + run: | + ARCHIVE="caps-log-win.tar.gz" + cp build/source/caps-log ./caps-log + tar -czvf $ARCHIVE caps-log + gh release upload ${{ inputs.release_name }} $ARCHIVE --clobber + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build_and_test_macos: + runs-on: macos-latest + steps: + - name: Get deps + run: brew install libgit2 boost + - uses: actions/checkout@v4 + - name: CMake configure + run: | + if [ "${{ inputs.run_tests }}" == "true" ]; then TESTS="On"; else TESTS="Off"; fi + cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DCAPS_LOG_BUILD_TESTS=$TEST + - name: CMake build + run: cmake --build ${{github.workspace}}/build --config ${{ inputs.build_type }} + - name: Test + if: ${{ inputs.run_tests == true }} + working-directory: ${{ github.workspace }}/build + run: ctest -C ${{ inputs.build_type }} --output-on-failure + - name: Upload + if: ${{ inputs.release_name != '' }} + run: | + ARCHIVE="caps-log-macos.tar.gz" + cp build/source/caps-log ./caps-log + tar -czvf $ARCHIVE caps-log + gh release upload ${{ inputs.release_name }} $ARCHIVE --clobber + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build_and_test_linux: + runs-on: ubuntu-latest + steps: + - name: Get deps + run: sudo apt-get update && sudo apt-get install libboost-program-options-dev libgit2-dev + - uses: actions/checkout@v4 + - name: CMake configure + run: | + if [ "${{ inputs.run_tests }}" == "true" ]; then TESTS="On"; else TESTS="Off"; fi + cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DCAPS_LOG_BUILD_TESTS=$TESTS + - name: CMake build + run: cmake --build ${{ github.workspace }}/build --config ${{ inputs.build_type }} + - name: Test + if: ${{ inputs.run_tests == true }} + working-directory: ${{ github.workspace }}/build + run: ctest -C ${{ inputs.build_type }} --output-on-failure + - name: Upload + if: ${{ inputs.release_name != '' }} + run: | + ARCHIVE="caps-log-linux.tar.gz" + cp build/source/caps-log ./caps-log + tar -czvf $ARCHIVE caps-log + gh release upload ${{ inputs.release_name }} $ARCHIVE --clobber + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/conventional-commits.yml b/.github/workflows/conventional-commits.yml index 387dbc1..5b0ee7a 100644 --- a/.github/workflows/conventional-commits.yml +++ b/.github/workflows/conventional-commits.yml @@ -12,6 +12,6 @@ jobs: name: Conventional Commits runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: webiny/action-conventional-commits@v1.1.0 diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 07f75c1..74d7e94 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -4,7 +4,7 @@ on: pull_request: branches: [ "master" ] paths-ignore: - - '.github/**' + #- '.github/**' - '.gitignore' - 'README' - 'LICENCE' @@ -21,82 +21,11 @@ concurrency: cancel-in-progress: true jobs: - build: - strategy: - fail-fast: false - matrix: - compiler: ['clang','msvc','gcc'] - os: ['ubuntu-latest', 'windows-latest'] - exclude: - - os: 'ubuntu-latest' - compiler: 'msvc' - - os: 'windows-latest' - # temporary exclude everything - # compiler: 'gcc' - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v3 - - name: Cache - id: cache-step - uses: actions/cache@v3 - with: - path: | - ~/vcpkg - ./build/vcpkg_installed - ${{ env.CONAN_USER_HOME }} - ~/.cache/pip - ${{ env.HOME }}/.cache/vcpkg/archives - ${{ env.XDG_CACHE_HOME }}/vcpkg/archives - ${{ env.LOCALAPPDATA }}\vcpkg\archives - ${{ env.APPDATA }}\vcpkg\archives - key: ${{ runner.os }}-${{ matrix.compiler }}-${{ hashFiles('**/CMakeLists.txt') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.compiler }} - - - name: Prepare environment - uses: aminya/setup-cpp@v1 - with: - compiler: ${{ matrix.compiler }} - vcvarsall: ${{ contains(matrix.os, 'windows' )}} - cmake: true - ninja: true - conan: false - vcpkg: false - ccache: false - clangtidy: false - cppcheck: false - gcovr: false - opencppcoverage: false - - - name: Setup vcpkg and install Boost (Windows) - if: steps.cache-step.outputs.cache-hit != 'true' && matrix.os == 'windows-latest' - - run: | - git clone https://github.com/microsoft/vcpkg.git - cd vcpkg - ./bootstrap-vcpkg.bat - ./vcpkg install boost - - - name: Get boost - if: matrix.os != 'windows-latest' - run: sudo apt-get update && sudo apt-get install libboost-program-options-dev libgit2-dev - - - name: Configure CMake (Windows) - if: matrix.os == 'windows-latest' - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DCAPS_LOG_BUILD_TESTS=On -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake - - - name: Configure CMake (Windows) - if: matrix.os != 'windows-latest' - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DCAPS_LOG_BUILD_TESTS=On - - - name: Build - run: cmake --build ${{github.workspace}}/build --config Release - - - name: Test - working-directory: ${{ github.workspace }}/build - run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure + matrix_build_and_test: + uses: ./.github/workflows/build-and-test-matrix.yml + with: + run_tests: true + build_type: "Release" static-analysis: runs-on: ubuntu-latest @@ -118,4 +47,3 @@ jobs: - name: Fail fast?! if: steps.linter.outputs.checks-failed > 0 run: exit 1 - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f0d8f8a..92c7d55 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,13 +6,13 @@ env: BUILD_TYPE: Release jobs: - get-version: + create-next-release: runs-on: ubuntu-latest outputs: version: ${{ steps.get_next_version.outputs.version }} steps: - name: Clone repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Get next version @@ -24,59 +24,16 @@ jobs: echo "Failed to comput next version!" exit 1 fi - - create-release: - needs: get-version - runs-on: ubuntu-latest - permissions: - contents: write - outputs: - version: ${{ steps.set_output.outputs.version }} - steps: - name: Create GitHub Release uses: ncipollo/release-action@v1 with: - tag: ${{ needs.get-version.outputs.version }} - - name: Set version output for dependent jobs - id: set_output - run: echo "version=${{ needs.get-version.outputs.version }}" >> "$GITHUB_OUTPUT" + tag: ${{ steps.get_next_version.outputs.version }} - build-and-upload-linux: - needs: create-release - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - run: sudo apt-get update && sudo apt-get install libboost-program-options-dev libssl-dev libgit2-dev - - - name: Build - run: | - mkdir build && cd build - cmake -DCAPS_LOG_VERSION="${{ needs.create-release.outputs.version }}" .. && make + matrix-build-and-upload: + needs: create-next-release + uses: ./.github/workflows/build-and-test-matrix.yml + with: + run_tests: false + build_type: "Release" + release_name: ${{ needs.create-next-release.outputs.version }} - - name: Archive and Upload binaries to release - run: | - cp build/source/caps-log ./caps-log - tar -czvf caps-log-linux.tar.gz caps-log - gh release upload ${{ needs.create-release.outputs.version }} caps-log-linux.tar.gz --clobber - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - build-and-upload-mac: - needs: create-release - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - - run: brew install boost openssl libgit2 - - - name: Build for MacOS - run: | - mkdir build-macos && cd build-macos - cmake -DCAPS_LOG_VERSION="${{ needs.create-release.outputs.version }}" .. && make - - - name: Archive and Upload MacOS binaries to release - run: | - cp build-macos/source/caps-log ./caps-log - tar -czvf caps-log-macos.tar.gz caps-log - gh release upload ${{ needs.create-release.outputs.version }} caps-log-macos.tar.gz --clobber - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/cmake/linux-to-windows-crosscompile-toolchain.cmake b/cmake/linux-to-windows-crosscompile-toolchain.cmake deleted file mode 100644 index 441eb0f..0000000 --- a/cmake/linux-to-windows-crosscompile-toolchain.cmake +++ /dev/null @@ -1,10 +0,0 @@ -set(CMAKE_SYSTEM_NAME Windows) - -set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) -set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) - -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - diff --git a/source/log/annual_log_data.hpp b/source/log/annual_log_data.hpp index 95526a7..5b5d0f3 100644 --- a/source/log/annual_log_data.hpp +++ b/source/log/annual_log_data.hpp @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include "log_repository_base.hpp" #include "utils/date.hpp" diff --git a/source/view/annual_view.cpp b/source/view/annual_view.cpp index 384ce0b..553a43f 100644 --- a/source/view/annual_view.cpp +++ b/source/view/annual_view.cpp @@ -67,6 +67,9 @@ std::shared_ptr AnnualView::makeFullUIComponent() { }); const auto eventHandler = CatchEvent(wholeUiRenderer, [&](const Event &event) { + + event. + // controller does not care about mouse events if (not event.is_mouse()) { return m_handler->handleInputEvent(UIEvent{UnhandledRootEvent{event.input()}});