From a9974e0b0f4ba4dbec164d36bb525bc408faf205 Mon Sep 17 00:00:00 2001 From: Nikola Ducak Date: Sun, 17 Mar 2024 22:25:07 +0100 Subject: [PATCH] ci: update static checks --- .../{build-and-test.yml => pr-check.yml} | 48 ++++++++----------- CMakeLists.txt | 2 +- README.md | 2 +- test/calendar_component_test.cpp | 3 +- 4 files changed, 24 insertions(+), 31 deletions(-) rename .github/workflows/{build-and-test.yml => pr-check.yml} (73%) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/pr-check.yml similarity index 73% rename from .github/workflows/build-and-test.yml rename to .github/workflows/pr-check.yml index 8ef7783..07f75c1 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/pr-check.yml @@ -1,4 +1,4 @@ -name: Build and test +name: PR check on: pull_request: @@ -85,11 +85,11 @@ jobs: - name: Configure CMake (Windows) if: matrix.os == 'windows-latest' - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=On -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake + 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 -DBUILD_TESTS=On + 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 @@ -98,32 +98,24 @@ jobs: working-directory: ${{ github.workspace }}/build run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure - static-analysis: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - run: sudo apt-get update && sudo apt-get install libboost-program-options-dev libgit2-dev + - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DCAPS_LOG_BUILD_TESTS=On + - uses: cpp-linter/cpp-linter-action@v2 + id: linter + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + version: 19 + database: 'build' + style: 'file' # Use .clang-format config file + tidy-checks: '' # Use .clang-tidy config file + # only 'update' a single comment in a pull request's thread. + thread-comments: ${{ github.event_name == 'pull_request' && 'update' }} + - name: Fail fast?! + if: steps.linter.outputs.checks-failed > 0 + run: exit 1 - - name: Prepare environment - run: sudo apt-get update && sudo apt-get install libboost-program-options-dev libgit2-dev clang-tidy - - - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=Off - - - name: Build - run: cmake --build ${{github.workspace}}/build --config Release - - - name: Static Analysis - run: ln -s ./build/compile_commands.json ./ && run-clang-tidy ./source/ - - code-formatting: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - uses: DoozyX/clang-format-lint-action@v0.16.2 - with: - source: 'source test' - extensions: 'hpp,cpp' - clangFormatVersion: 16 diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f70012..db4e77f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ endif() # ------------------------------- OpenSSL -------------------------------- # set(OPENSSL_USE_STATIC_LIBS TRUE) -find_package(OpenSSL REQUIRED) +find_package(OpenSSL REQUIRED COMPONENTS Crypto) # ------------------------------- LibGit2 -------------------------------- # diff --git a/README.md b/README.md index 2c44f9a..2ee13be 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ by typing `caps-log` in your terminal. If you wish to build and run the tests, execute: ```shell -mkdir build && cd build && cmake .. -DBUILD_TESTS=ON +mkdir build && cd build && cmake .. -DCAPS_LOG_BUILD_TESTS=ON make ctest ``` diff --git a/test/calendar_component_test.cpp b/test/calendar_component_test.cpp index bda0d47..218f6d4 100644 --- a/test/calendar_component_test.cpp +++ b/test/calendar_component_test.cpp @@ -1,9 +1,10 @@ #include "view/calendar_component.hpp" #include +#include #include static const std::filesystem::path data_dir_path = - CAPS_LOG_TEST_DATA_DIR "/calendar_component_test_expected_render.bin"; + std::filesystem::path{CAPS_LOG_TEST_DATA_DIR} / "calendar_component_test_expected_render.bin"; TEST(CalnedarComponentTest, Render) { using namespace std::chrono_literals;