diff --git a/.github/actions/benchmark_epilogue/action.yml b/.github/actions/benchmark_epilogue/action.yml index 448cdb79..c7222878 100644 --- a/.github/actions/benchmark_epilogue/action.yml +++ b/.github/actions/benchmark_epilogue/action.yml @@ -1,18 +1,33 @@ name: "Benchmark Epilogue" description: "Processes coverage information with lcov and uploads it to coveralls/codecov" inputs: + compiler: + required: True + description: 'Compiler used to build benchmark' + os: + required: True + description: 'OS used to build benchmark' + stdlib: + required: True + description: 'C++ standard library used to build benchmark' build-output-dir: required: true description: 'Build output directory' runs: using: "composite" steps: + - name: Archive benchmark results + uses: actions/upload-artifact@v4 + with: + name: benchmark_${{ inputs.os }}_${{ inputs.compiler }}_${{ inputs.stdlib }}_json + path: ${{ inputs.build-output-dir }}/benchmark/benchmark_result.json + # Download previous benchmark result from cache (if exists) - name: Download previous benchmark data uses: actions/cache@v4 with: path: ./cache - key: ${{ runner.os }}-benchmark + key: benchmark_${{ inputs.os }}_${{ inputs.compiler }}_${{ inputs.stdlib }} - name: Store benchmark result uses: benchmark-action/github-action-benchmark@v1 diff --git a/.github/problem_matchers/clang_problem_matcher.json b/.github/problem_matchers/clang_problem_matcher.json new file mode 100644 index 00000000..b3af1a14 --- /dev/null +++ b/.github/problem_matchers/clang_problem_matcher.json @@ -0,0 +1,17 @@ +{ + "problemMatcher": [ + { + "owner": "clang", + "pattern": [ + { + "regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + ] + } + ] +} \ No newline at end of file diff --git a/.github/problem_matchers/gcc_problem_matcher.json b/.github/problem_matchers/gcc_problem_matcher.json new file mode 100644 index 00000000..75374fac --- /dev/null +++ b/.github/problem_matchers/gcc_problem_matcher.json @@ -0,0 +1,17 @@ +{ + "problemMatcher": [ + { + "owner": "gcc", + "pattern": [ + { + "regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + ] + } + ] +} \ No newline at end of file diff --git a/.github/problem_matchers/msvc_problem_matcher.json b/.github/problem_matchers/msvc_problem_matcher.json new file mode 100644 index 00000000..5d85a18b --- /dev/null +++ b/.github/problem_matchers/msvc_problem_matcher.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "owner": "msvc", + "pattern": [ + { + "regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),?(\\d+)?(?:,\\d+,\\d+)?\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "code": 5, + "message": 6 + } + ] + } + ] +} \ No newline at end of file diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index c0a37e00..8b8cf439 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -105,10 +105,16 @@ jobs: -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + - name: Register Compiler Problem Matcher + run: echo "::add-matcher::.github/problem_matchers/${{ matrix.compiler}}_problem_matcher.json" + - name: Build # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --target ${{ matrix.target }} --config ${{ matrix.build_type }} --parallel + - name: Unregister Compiler Problem Matcher + run: echo "::remove-matcher owner=${{ matrix.compiler}}::" + - name: Test # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail @@ -123,4 +129,7 @@ jobs: - uses: ./.github/actions/benchmark_epilogue if: matrix.preset == 'benchmark' with: + os: ${{ matrix.os }} + compiler: ${{ matrix.compiler }} + stdlib: ${{ matrix.stdlib }} build-output-dir: ${{ steps.strings.outputs.build-output-dir }} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6fef04b4..8c621da4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -5,17 +5,19 @@ include(FetchContent) -find_package(GTest) -if (NOT GTest OR "${GTest_DIR}" STREQUAL "GTest-NOTFOUND") - FetchContent_Declare( - googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG 6910c9d9165801d8827d628cb72eb7ea9dd538c5 # v1.16.x - ) - # For Windows: Prevent overriding the parent project's compiler/linker settings - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - FetchContent_MakeAvailable(googletest) - include(GoogleTest) +if (NOT TARGET GTest::gtest) + find_package(GTest) + if (NOT GTest_DIR OR "${GTest_DIR}" STREQUAL "GTest_DIR-NOTFOUND") + FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG 6910c9d9165801d8827d628cb72eb7ea9dd538c5 # v1.16.x + ) + # For Windows: Prevent overriding the parent project's compiler/linker settings + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + FetchContent_MakeAvailable(googletest) + include(GoogleTest) + endif() endif() add_executable(bitlib-tests) @@ -40,27 +42,20 @@ target_sources(bitlib-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/vector_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/inc/test_utils.hpp ) -target_include_directories(bitlib-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/inc) - if (BITLIB_MDSPAN) target_sources(bitlib-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/test-mdspan.cpp) endif() -# ASAN throws no matter what when using Google HWY, not sure why but need to fix -# if (NOT BITLIB_HWY) -# target_compile_options(bitlib-tests PUBLIC -fsanitize=address) -# target_link_options(bitlib-tests PUBLIC -fsanitize=address) -# endif() +target_include_directories(bitlib-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/inc) + # specify test-specific libraries target_link_libraries(bitlib-tests PRIVATE bitlib GTest::gtest GTest::gtest_main) -target_link_options(bitlib-tests PRIVATE -pthread -lgcov --coverage) if (NOT BITLIB_GTEST_REPEAT) set(BITLIB_GTEST_REPEAT 1) endif() -enable_testing() gtest_discover_tests( bitlib-tests EXTRA_ARGS --gtest_repeat=${BITLIB_GTEST_REPEAT})