From e082015a4f8993820ddac9c11be42a86ceb058e1 Mon Sep 17 00:00:00 2001 From: Peter McLean Date: Tue, 6 May 2025 20:56:28 -0400 Subject: [PATCH 1/7] compiler problem matchers --- .../clang_problem_matcher.json | 17 +++++++++++++++++ .../problem_matchers/gcc_problem_matcher.json | 17 +++++++++++++++++ .../problem_matchers/msvc_problem_matcher.json | 18 ++++++++++++++++++ .github/workflows/cmake-multi-platform.yml | 6 ++++++ 4 files changed, 58 insertions(+) create mode 100644 .github/problem_matchers/clang_problem_matcher.json create mode 100644 .github/problem_matchers/gcc_problem_matcher.json create mode 100644 .github/problem_matchers/msvc_problem_matcher.json 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..f659c029 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 From 7a5b67985c84b1586c1fef43f1f6d8ab33686352 Mon Sep 17 00:00:00 2001 From: Peter McLean Date: Tue, 6 May 2025 21:07:18 -0400 Subject: [PATCH 2/7] Fix GTest discovery --- test/CMakeLists.txt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6fef04b4..aa906723 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,7 +6,7 @@ include(FetchContent) find_package(GTest) -if (NOT GTest OR "${GTest_DIR}" STREQUAL "GTest-NOTFOUND") +if (NOT GTest_DIR OR "${GTest_DIR}" STREQUAL "GTest_DIR-NOTFOUND") FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git @@ -46,12 +46,6 @@ 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() - # 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) From ae21d9a73f96fffffe7271167951b314fce3badb Mon Sep 17 00:00:00 2001 From: Peter McLean Date: Tue, 6 May 2025 21:11:34 -0400 Subject: [PATCH 3/7] Encode more metadata for cache --- .github/actions/benchmark_epilogue/action.yml | 11 ++++++++++- .github/workflows/cmake-multi-platform.yml | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/actions/benchmark_epilogue/action.yml b/.github/actions/benchmark_epilogue/action.yml index 448cdb79..9181ea6b 100644 --- a/.github/actions/benchmark_epilogue/action.yml +++ b/.github/actions/benchmark_epilogue/action.yml @@ -1,6 +1,15 @@ 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' @@ -12,7 +21,7 @@ runs: 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/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index f659c029..8b8cf439 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -129,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 }} From 43e0bcf6b1063dc555d808e5e37d547dcc5b8e70 Mon Sep 17 00:00:00 2001 From: Peter McLean Date: Tue, 6 May 2025 21:14:01 -0400 Subject: [PATCH 4/7] Archive benchmark json --- .github/actions/benchmark_epilogue/action.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/actions/benchmark_epilogue/action.yml b/.github/actions/benchmark_epilogue/action.yml index 9181ea6b..a51ec443 100644 --- a/.github/actions/benchmark_epilogue/action.yml +++ b/.github/actions/benchmark_epilogue/action.yml @@ -33,3 +33,9 @@ runs: external-data-json-path: ./cache/benchmark_result.json # Workflow will fail when an alert happens fail-on-alert: true + + - name: Archive benchmark results + uses: actions/upload-artifact@v4 + with: + name: benchmark_json + path: ${{ inputs.build-output-dir }}/benchmark/benchmark_result.json \ No newline at end of file From 42f0bcf7da6ea4b7e23ac153e3d8e48cbe6514a5 Mon Sep 17 00:00:00 2001 From: Peter McLean Date: Tue, 6 May 2025 21:25:39 -0400 Subject: [PATCH 5/7] Archive first because runners are eager to nuke the workflow --- .github/actions/benchmark_epilogue/action.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/actions/benchmark_epilogue/action.yml b/.github/actions/benchmark_epilogue/action.yml index a51ec443..107fc50f 100644 --- a/.github/actions/benchmark_epilogue/action.yml +++ b/.github/actions/benchmark_epilogue/action.yml @@ -16,6 +16,12 @@ inputs: runs: using: "composite" steps: + - name: Archive benchmark results + uses: actions/upload-artifact@v4 + with: + name: benchmark_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 @@ -32,10 +38,4 @@ runs: # Where the previous data file is stored external-data-json-path: ./cache/benchmark_result.json # Workflow will fail when an alert happens - fail-on-alert: true - - - name: Archive benchmark results - uses: actions/upload-artifact@v4 - with: - name: benchmark_json - path: ${{ inputs.build-output-dir }}/benchmark/benchmark_result.json \ No newline at end of file + fail-on-alert: true \ No newline at end of file From d5a24c6e87766cb7e76afe2f28d3e0f0b637ec1f Mon Sep 17 00:00:00 2001 From: Peter McLean Date: Tue, 6 May 2025 21:32:57 -0400 Subject: [PATCH 6/7] Remove stray link options in bitlib-tests --- .github/actions/benchmark_epilogue/action.yml | 2 +- test/CMakeLists.txt | 31 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/actions/benchmark_epilogue/action.yml b/.github/actions/benchmark_epilogue/action.yml index 107fc50f..21db193f 100644 --- a/.github/actions/benchmark_epilogue/action.yml +++ b/.github/actions/benchmark_epilogue/action.yml @@ -38,4 +38,4 @@ runs: # Where the previous data file is stored external-data-json-path: ./cache/benchmark_result.json # Workflow will fail when an alert happens - fail-on-alert: true \ No newline at end of file + fail-on-alert: true diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index aa906723..8c621da4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -5,17 +5,19 @@ include(FetchContent) -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) +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,21 +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() +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}) From 6e1b664f202e3c7ad11c1c6c83a62ec45c20acca Mon Sep 17 00:00:00 2001 From: Peter McLean Date: Tue, 6 May 2025 21:42:17 -0400 Subject: [PATCH 7/7] compose Artifact name --- .github/actions/benchmark_epilogue/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/benchmark_epilogue/action.yml b/.github/actions/benchmark_epilogue/action.yml index 21db193f..c7222878 100644 --- a/.github/actions/benchmark_epilogue/action.yml +++ b/.github/actions/benchmark_epilogue/action.yml @@ -19,7 +19,7 @@ runs: - name: Archive benchmark results uses: actions/upload-artifact@v4 with: - name: benchmark_json + 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)