Skip to content
Snippets Groups Projects
Commit 0b1bed62 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Added coverage

parent 9786bd85
No related branches found
No related tags found
No related merge requests found
...@@ -10,9 +10,12 @@ stages: ...@@ -10,9 +10,12 @@ stages:
- build - build
# Unit test stage # Unit test stage
- test - test
# Code coverage
- coverage
include: include:
- local: '/.gitlab/ci/_global.gitlab-ci.yml' - local: '/.gitlab/ci/_global.gitlab-ci.yml'
- local: '/.gitlab/ci/static_analysis.gitlab-ci.yml' - local: '/.gitlab/ci/static_analysis.gitlab-ci.yml'
- local: '/.gitlab/ci/build.gitlab-ci.yml' - local: '/.gitlab/ci/build.gitlab-ci.yml'
- local: '/.gitlab/ci/test.gitlab-ci.yml' - local: '/.gitlab/ci/test.gitlab-ci.yml'
- local: '/.gitlab/ci/coverage.gitlab-ci.yml'
...@@ -14,7 +14,7 @@ build:ubuntu_cpp: ...@@ -14,7 +14,7 @@ build:ubuntu_cpp:
- export CMAKE_PREFIX_PATH=../install_cpp - export CMAKE_PREFIX_PATH=../install_cpp
- mkdir -p build_cpp - mkdir -p build_cpp
- cd build_cpp - cd build_cpp
- cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON .. - cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=ON ..
- make -j4 all install - make -j4 all install
artifacts: artifacts:
......
coverage:ubuntu_cpp:
stage: coverage
needs: ["build:ubuntu_cpp"]
tags:
- docker
script:
- cd build_cpp
- ctest --output-on-failure
# HTML report for visualization
- gcovr --html-details --exclude-unreachable-branches -o coverage.html --root ${CI_PROJECT_DIR} --filter '\.\./include/' --filter '\.\./src/'
# Coberta XML report for Gitlab integration
- gcovr --xml-pretty --exclude-unreachable-branches --print-summary -o coverage.xml --root ${CI_PROJECT_DIR} --filter '\.\./include/' --filter '\.\./src/'
coverage: /^\s*lines:\s*\d+.\d+\%/
artifacts:
name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
expire_in: 2 days
reports:
coverage_report:
coverage_format: cobertura
path: build_cpp/coverage.xml
coverage:ubuntu_python:
stage: coverage
needs: ["build:ubuntu_python"]
tags:
- docker
script:
- source venv/bin/activate
- python3 -m pip install numpy coverage
- cd ${CI_PROJECT_NAME}
- python3 -m coverage run --source=. -m unittest discover -s unit_tests/ -v -b
- python3 -m coverage report
- python3 -m coverage xml
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: ${CI_PROJECT_NAME}/coverage.xml
...@@ -26,8 +26,8 @@ static_analysis:python: ...@@ -26,8 +26,8 @@ static_analysis:python:
script: script:
- pip install pylint - pip install pylint
- pip install pylint-gitlab - pip install pylint-gitlab
- pylint --rcfile=.pylintrc --exit-zero --output-format=pylint_gitlab.GitlabCodeClimateReporter aidge_backend_cpu/ > codeclimate.json - pylint --rcfile=.pylintrc --exit-zero --output-format=pylint_gitlab.GitlabCodeClimateReporter ${CI_PROJECT_NAME}/ > codeclimate.json
- pylint --rcfile=.pylintrc --exit-zero --output-format=pylint_gitlab.GitlabPagesHtmlReporter aidge_backend_cpu/ > pylint.html - pylint --rcfile=.pylintrc --exit-zero --output-format=pylint_gitlab.GitlabPagesHtmlReporter ${CI_PROJECT_NAME}/ > pylint.html
- mkdir -p public/python/$CI_COMMIT_REF_NAME - mkdir -p public/python/$CI_COMMIT_REF_NAME
- mv pylint.html public/python/$CI_COMMIT_REF_NAME/ - mv pylint.html public/python/$CI_COMMIT_REF_NAME/
artifacts: artifacts:
......
...@@ -17,7 +17,7 @@ test:ubuntu_python: ...@@ -17,7 +17,7 @@ test:ubuntu_python:
- docker - docker
script: script:
- source venv/bin/activate - source venv/bin/activate
- cd aidge_backend_cpu - cd ${CI_PROJECT_NAME}
- python3 -m pip install numpy unittest-xml-reporting - python3 -m pip install numpy unittest-xml-reporting
- python3 -m pip list - python3 -m pip list
# Run on discovery all tests located in core/unit_tests/python and discard the stdout # Run on discovery all tests located in core/unit_tests/python and discard the stdout
...@@ -25,7 +25,7 @@ test:ubuntu_python: ...@@ -25,7 +25,7 @@ test:ubuntu_python:
- python3 -m xmlrunner discover -s unit_tests/ -v -b --output-file xmlrunner-results.xml - python3 -m xmlrunner discover -s unit_tests/ -v -b --output-file xmlrunner-results.xml
artifacts: artifacts:
reports: reports:
junit: aidge_core/xmlrunner-results.xml junit: ${CI_PROJECT_NAME}/xmlrunner-results.xml
test:windows_cpp: test:windows_cpp:
stage: test stage: test
......
...@@ -21,6 +21,17 @@ include(PybindModuleCreation) ...@@ -21,6 +21,17 @@ include(PybindModuleCreation)
# Define options # Define options
option(PYBIND "python binding" ON) option(PYBIND "python binding" ON)
option(WERROR "Warning as error" OFF) option(WERROR "Warning as error" OFF)
option(TEST "Enable tests" ON)
option(COVERAGE "Enable coverage" OFF)
##############################################
# Import utils CMakeLists
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
include(PybindModuleCreation)
if(CMAKE_COMPILER_IS_GNUCXX AND COVERAGE)
Include(CodeCoverage)
endif()
############################################## ##############################################
# Find system dependencies # Find system dependencies
...@@ -79,6 +90,10 @@ else() ...@@ -79,6 +90,10 @@ else()
/W4>) /W4>)
endif() endif()
if(CMAKE_COMPILER_IS_GNUCXX AND COVERAGE)
append_coverage_compiler_flags()
endif()
############################################## ##############################################
# Installation instructions # Installation instructions
...@@ -129,6 +144,7 @@ export(EXPORT ${project}-targets ...@@ -129,6 +144,7 @@ export(EXPORT ${project}-targets
############################################## ##############################################
## Add test ## Add test
enable_testing() if(TEST)
add_subdirectory(unit_tests) enable_testing()
add_subdirectory(unit_tests)
endif()
![Pipeline status](https://gitlab.eclipse.org/eclipse/aidge/aidge_backend_cpu/badges/master/pipeline.svg?ignore_skipped=true) ![C++ coverage](https://gitlab.eclipse.org/eclipse/aidge/aidge_backend_cpu/badges/master/coverage.svg?job=coverage:ubuntu_cpp&key_text=C%2B%2B+coverage&key_width=90) ![Python coverage](https://gitlab.eclipse.org/eclipse/aidge/aidge_backend_cpu/badges/master/coverage.svg?job=coverage:ubuntu_python&key_text=Python+coverage&key_width=100)
# Aidge CPU library # Aidge CPU library
You can find in this folder the library that implements the CPU operators. <br> You can find in this folder the library that implements the CPU operators. <br>
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment