Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 70 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,58 @@ jobs:
- name: Run multi-threaded tests
run: ./build/mt_tests

- name: Run cachegrind (Linux only)
benchmarks:
name: Benchmarks - ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
include:
- os: ubuntu-latest
cxx: clang++-16
cc: clang-16
- os: macos-latest
cxx: clang++
cc: clang

steps:
- uses: actions/checkout@v4

- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
valgrind --tool=cachegrind --cachegrind-out-file=cachegrind.out ./build/benchmark
echo "=== Cachegrind Summary ==="
cg_annotate cachegrind.out | head -50
sudo apt-get update
sudo apt-get install -y cmake ninja-build clang-16

- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install cmake ninja

- name: Configure CMake
run: |
cmake -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \
-DCMAKE_C_COMPILER=${{ matrix.cc }} \
-DBUILD_BENCHMARKS=ON

- name: Build benchmarks
run: cmake --build build --config Release

- name: Run benchmarks
run: ./build/benchmarks --benchmark_min_time=0.1s

- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results-${{ matrix.os }}
path: |
benchmark_*.json
retention-days: 30

sanitizers:
name: Sanitizers - ${{ matrix.sanitizer }}
Expand Down Expand Up @@ -118,14 +164,32 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Configure CMake
- name: Configure CMake (tests)
run: |
cmake -B build -DBUILD_TESTING=ON

- name: Build
- name: Build tests
run: cmake --build build --config Release

- name: Run tests
run: |
./build/Release/unit_tests.exe
./build/Release/mt_tests.exe

- name: Configure CMake (benchmarks)
run: |
cmake -B build-bench -DBUILD_BENCHMARKS=ON

- name: Build benchmarks
run: cmake --build build-bench --config Release

- name: Run benchmarks
run: ./build-bench/Release/benchmarks.exe --benchmark_min_time=0.1s

- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results-windows
path: |
benchmark_*.json
retention-days: 30
41 changes: 35 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.5)
project(Bring VERSION 0.1.0 LANGUAGES CXX)


Expand All @@ -9,9 +9,14 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(cmake/CPM.cmake)

CPMAddPackage("gh:catchorg/Catch2@3.4.0")
CPMAddPackage("gh:catchorg/Catch2@3.12.0")


set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable benchmark testing" FORCE)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable benchmark gtest" FORCE)
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Disable benchmark install" FORCE)
CPMAddPackage("gh:google/benchmark#v1.8.3")



find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
Expand All @@ -35,15 +40,39 @@ if(BUILD_TESTING) # Standard CMake flag
# This enables Clang-Tidy for the test executable too
set_target_properties(unit_tests PROPERTIES CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY}")

add_executable(benchmark tests/benchmark.cpp)
target_link_libraries(benchmark PRIVATE bring::bring)
set_target_properties(benchmark PROPERTIES CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY}")
#add_executable(benchmark tests/benchmark.cpp)
#target_link_libraries(benchmark PRIVATE bring::bring)
#set_target_properties(benchmark PROPERTIES CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY}")

add_executable(mt_tests tests/test_multithreaded.cpp)
target_link_libraries(mt_tests PRIVATE bring::bring Catch2::Catch2WithMain)
set_target_properties(mt_tests PROPERTIES CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY}")
find_package(Threads REQUIRED)
target_link_libraries(mt_tests PRIVATE Threads::Threads)


if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(STATUS "Clang detected: Enabling Fuzzing and Sanitizer targets")
add_executable(fuzzer_test tests/fuzzer_test.cpp)
target_compile_options(fuzzer_test PRIVATE -fsanitize=fuzzer,address,undefined)
target_link_options(fuzzer_test PRIVATE -fsanitize=fuzzer,address,undefined)
target_link_libraries(fuzzer_test PRIVATE bring::bring)
endif()
endif()

if(BUILD_BENCHMARKS)
add_executable(benchmarks benchmarks/bench_main.cpp)
target_link_libraries(benchmarks PRIVATE
bring::bring
benchmark::benchmark_main
)

# Optimization is mandatory for benchmarks
if(MSVC)
target_compile_options(benchmarks PRIVATE /O2)
else()
target_compile_options(benchmarks PRIVATE -O3)
endif()
endif()


Expand All @@ -56,7 +85,7 @@ target_include_directories(bring INTERFACE
)

if(MSVC)
target_compile_options(bring INTERFACE /W4 /WX)
target_compile_options(bring INTERFACE /W4 /WX /wd4324)
else()
target_compile_options(bring INTERFACE -Wall -Wextra
-Wpedantic -Wshadow -Werror)
Expand Down
Loading
Loading