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
35 changes: 28 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ jobs:
run: cmake --build . -j$(nproc)

# -------------------------------------------------
# 2. FULL BUILD + TEST + SIMPLE DAG RUN + DOCS (RelWithDebInfo + Eigen)
# 2. FULL BUILD + TEST + SIMPLE DAG RUN + COVERAGE + DOCS (RelWithDebInfo + Eigen)
# -------------------------------------------------
test_and_run:
name: Build & Test (RelWithDebInfo + Eigen)
name: Build, Test & Coverage (RelWithDebInfo + Eigen)
runs-on: ubuntu-latest
needs: build_matrix
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master'
Expand All @@ -55,21 +55,42 @@ jobs:
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
make gcc g++ git libboost-all-dev \
doxygen graphviz python3-pip libeigen3-dev
doxygen graphviz python3-pip libeigen3-dev lcov
pip3 install --upgrade pip
pip3 install cmake==3.21.3
- name: Configure
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTS=ON
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTS=ON -DENABLE_COVERAGE=ON

- name: Build all targets
working-directory: ${{ github.workspace }}/build
run: cmake --build . -j$(nproc)

- name: Run tests
- name: Run tests with coverage
working-directory: ${{ github.workspace }}/build
run: ctest --output-on-failure --output-junit test_results.xml
continue-on-error: true
run: |
# Run tests
ctest --output-on-failure --output-junit test_results.xml
# Capture coverage ONLY from include/
lcov --capture --directory . \
--output-file coverage.info \
--ignore-errors empty,mismatch \
--include '*/OneStopParallel/include/*'
# Remove unused warnings + ignore tests/apps
lcov --remove coverage.info '*/tests/*' '*/apps/*' \
--ignore-errors unused,empty,mismatch \
--output-file coverage.info
# Generate HTML report
genhtml coverage.info --output-directory coverage_html
- name: Upload coverage artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: build/coverage_html

- name: Upload test results
uses: actions/upload-artifact@v4
Expand Down
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) # Ensure C++17 standard is strictly enforced

# --- Code Coverage (optional) ---
option(ENABLE_COVERAGE "Enable code coverage flags" OFF)

if(ENABLE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
message(STATUS "Code coverage enabled")
add_compile_options(--coverage -g)
add_link_options(--coverage)
endif()

# Configure git hooks
add_subdirectory(.githooks)

Expand Down Expand Up @@ -102,7 +111,7 @@ target_compile_options(ProjectExecutableFlags INTERFACE
# Else (not Debug)
$<IF:$<CONFIG:RelWithDebInfo>,
# RelWithDebInfo flags
-O3;-g,
-O3;-g;-DNDEBUG,
# Release and other/custom flags
-O3;-DNDEBUG
>
Expand Down