Skip to content

Commit

Permalink
Merge pull request #26 from ewanwm/feature_codecov
Browse files Browse the repository at this point in the history
Code coverage checks
  • Loading branch information
ewanwm authored Jul 22, 2024
2 parents abbdd1a + e9799d3 commit e4a4d0f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/CI-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/[email protected]
with:
verbose: true
files: nuTens_coverage.json
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()

Expand Down
1 change: 1 addition & 0 deletions PyTorch_requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e4a4d0f

Please sign in to comment.