diff --git a/.github/workflows/CI-build-and-test.yml b/.github/workflows/CI-build-and-test.yml index 8bb402a..48b0086 100644 --- a/.github/workflows/CI-build-and-test.yml +++ b/.github/workflows/CI-build-and-test.yml @@ -38,7 +38,7 @@ jobs: - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -DCMAKE_PREFIX_PATH=`python3 -c 'import torch;print(torch.utils.cmake_prefix_path)'` -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: cmake -DTEST_COVERAGE=ON -DCMAKE_PREFIX_PATH=`python3 -c 'import torch;print(torch.utils.cmake_prefix_path)'` -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build # Build your program with the given configuration @@ -50,3 +50,14 @@ jobs: # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail run: ctest -C ${{env.BUILD_TYPE}} + - name: Generate Coverage Report + working-directory: ${{github.workspace}}/build + run: gcovr --json -o nuTens_coverage.json -r .. -f "../nuTens/*" + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + verbose: true + files: nuTens_coverage.json + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a7d26f..835dee6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,20 @@ cmake_minimum_required(VERSION 3.18 FATAL_ERROR) set(CMAKE_CXX_STANDARD 17) + +OPTION(TEST_COVERAGE "TEST_COVERAGE" OFF) + +IF(TEST_COVERAGE) + message("Adding flags to check test coverage") + #SET(CMAKE_CXX_FLAGS "--coverage -g -O0") + #SET(CMAKE_C_FLAGS "--coverage -g -O0") + #SET(CMAKE_EXE_LINKER_FLAGS "--coverage -g -O0") + add_compile_options("--coverage") + add_link_options("--coverage") +ELSE() + message("Won't check test coverage") +ENDIF() + + project(nuTens) enable_testing() diff --git a/PyTorch_requirements.txt b/PyTorch_requirements.txt index 0e78035..030704d 100644 --- a/PyTorch_requirements.txt +++ b/PyTorch_requirements.txt @@ -1,5 +1,6 @@ attrs==23.2.0 filelock==3.15.4 +gcovr==7.2 jinja2==3.1.4 jsonschema-specifications==2023.12.1 MarkupSafe==2.1.3 diff --git a/README.md b/README.md index 82f4b90..7c01b9c 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ nuTens is a software library which uses [tensors](https://en.wikipedia.org/wiki/ [![CI badge](https://github.com/ewanwm/nuTens/actions/workflows/CI-build-and-test.yml/badge.svg)](https://github.com/ewanwm/nuTens/actions/workflows/CI-build-and-test.yml) [![Code - Doxygen](https://img.shields.io/badge/Code-Doxygen-2ea44f)](https://ewanwm.github.io/nuTens/index.html) - +[![test - coverage](https://codecov.io/github/ewanwm/nuTens/graph/badge.svg?token=PJ8C8CX37O)](https://codecov.io/github/ewanwm/nuTens) ## Installation ### Requirements @@ -43,7 +43,7 @@ make test - [x] Basic test suite - [x] Basic CI - [x] Doxygen documentation with automatic deployment -- [ ] Add test coverage checks into CI +- [x] Add test coverage checks into CI - [ ] Integrate linting ( [cpp-linter](https://github.com/cpp-linter)? ) - [ ] Add instrumentation library for benchmarking and profiling - [ ] Add suite of benchmarking tests