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
71 changes: 71 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
codecov:
require_ci_to_pass: no

coverage:
precision: 2
round: down
range: "70...100"

status:
project:
default:
target: auto # Uses coverage from base commit
threshold: 2 # Allow 2% drop

patch:
default:
target: 85 # New code should have 85% coverage
threshold: 2 # Allow 2% variance

changes: no

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "reach, diff, flags, tree, files"
behavior: default
require_changes: no

ignore:
- "test/**/*"

- "benchmark/**/*"

- "scripts/**/*"
- "**/*.C"

- "Doxyfile"

flags:
ramcore:
paths:
- "src/ramcore/**"
- "inc/ramcore/**"
carryforward: true

rntuple:
paths:
- "src/rntuple/**"
- "inc/rntuple/**"
carryforward: true

ttree:
paths:
- "src/ttree/**"
- "inc/ttree/**"
carryforward: true

tools:
paths:
- "tools/**"
carryforward: true

github_checks:
annotations: true

64 changes: 60 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ on:
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-24.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v5

- name: Install ROOT
run: |
ROOT_URL="https://root.cern/download/root_v6.36.00.Linux-ubuntu24.04-x86_64-gcc13.3.tar.gz"
wget -O root.tar.gz $ROOT_URL
tar -xzf root.tar.gz -C /opt/
tar -xzf root.tar.gz -C /opt/
echo "/opt/root/bin" >> $GITHUB_PATH

- name: Install build dependencies
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Configure CMake
run: |
source thisroot.sh
mkdir build
mkdir build
cd build
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
Expand All @@ -49,3 +49,59 @@ jobs:
cd build
ctest --output-on-failure --build-config Release

coverage:
name: Code Coverage
runs-on: ubuntu-24.04
needs: build-and-test # Run only if build-and-test succeeds

steps:
- uses: actions/checkout@v5

- name: Install ROOT
run: |
ROOT_URL="https://root.cern/download/root_v6.36.00.Linux-ubuntu24.04-x86_64-gcc13.3.tar.gz"
wget -O root.tar.gz $ROOT_URL
tar -xzf root.tar.gz -C /opt/
echo "/opt/root/bin" >> $GITHUB_PATH

- name: Install build and coverage dependencies
run: |
sudo apt-get update
sudo apt-get install -y libvdt-dev libtbb-dev gcovr lcov

- name: Configure with coverage
run: |
source thisroot.sh
mkdir build
cd build
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DENABLE_COVERAGE=ON \
-DRAMTOOLS_BUILD_TESTS=ON \
-DRAMTOOLS_BUILD_TOOLS=ON \
-DRAMTOOLS_BUILD_BENCHMARKS=OFF

- name: Build
run: |
source thisroot.sh
cd build
cmake --build . --config Debug -j $(nproc)

- name: Run tests
run: |
source thisroot.sh
cd build
ctest --output-on-failure --build-config Debug

- name: Generate coverage report
run: |
cd build
gcovr -r .. --xml-pretty --xml coverage.xml --print-summary

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./build/coverage.xml
flags: unittests
name: codecov-ramtools
fail_ci_if_error: false
36 changes: 36 additions & 0 deletions .github/workflows/clang-tidy-review-post.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Post clang-tidy review comments

on:
workflow_run:
workflows: ["clang-tidy-review"]
types:
- completed

permissions:
checks: write
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.event.workflow_run.pull_requests[0].number }}
cancel-in-progress: true

jobs:
post-comments:
# Only run if the triggering workflow was from a pull request
if: github.event.workflow_run.event == 'pull_request'
runs-on: ubuntu-latest

steps:
- name: Post review comments
id: post-review
uses: ZedThree/clang-tidy-review/post@v0.21.0
with:
max_comments: 10

# Fail if there are any clang-tidy warnings
- name: Check for issues
if: steps.post-review.outputs.total_comments > 0
run: |
echo "::error::Found ${{ steps.post-review.outputs.total_comments }} clang-tidy issues"
exit 1

29 changes: 27 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
option(RAMTOOLS_BUILD_TESTS "Build unit tests" ON)
option(RAMTOOLS_BUILD_BENCHMARKS "Build benchmarks" ON)
option(RAMTOOLS_BUILD_TOOLS "Build tools" ON)
option(ENABLE_COVERAGE "Enable code coverage reporting" OFF)

if(ENABLE_COVERAGE)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
message(STATUS "Code coverage enabled")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
else()
message(WARNING "Code coverage requires GCC or Clang")
endif()
endif()

set(ROOT_MIN_VERSION 6.26)
find_package(ROOT ${ROOT_MIN_VERSION} REQUIRED COMPONENTS Core RIO Tree ROOTNTuple ROOTNTupleUtil)
Expand All @@ -20,7 +33,7 @@ include(GNUInstallDirs)
set(CMAKE_INSTALL_LIBDIR lib)
set(CMAKE_INSTALL_INCLUDEDIR include)

ROOT_STANDARD_LIBRARY_PACKAGE(ramcore
ROOT_STANDARD_LIBRARY_PACKAGE(ramcore
HEADERS
inc/ttree/RAMRecord.h
inc/ttree/Utils.h
Expand Down Expand Up @@ -61,12 +74,24 @@ if(RAMTOOLS_BUILD_TOOLS)
add_subdirectory(tools)
endif()

if(RAMTOOLS_BUILD_BENCHMARKS)
# Include benchmark directory if benchmarks OR tests are enabled
# (sam_generator is needed by tests)
if(RAMTOOLS_BUILD_BENCHMARKS OR RAMTOOLS_BUILD_TESTS)
add_subdirectory(benchmark)
endif()

if(RAMTOOLS_BUILD_TESTS)
enable_testing()
add_subdirectory(test)

if(ENABLE_COVERAGE)
add_custom_target(coverage
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
COMMAND gcovr -r ${CMAKE_SOURCE_DIR} --html --html-details -o ${CMAKE_BINARY_DIR}/coverage.html
COMMAND gcovr -r ${CMAKE_SOURCE_DIR} --xml-pretty --xml coverage.xml
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Running tests and generating code coverage report..."
)
endif()
endif()

Loading