Skip to content

Commit e8159ab

Browse files
committed
Log code coverage with Codecov
1 parent 8a52692 commit e8159ab

File tree

16 files changed

+888
-26
lines changed

16 files changed

+888
-26
lines changed

.github/workflows/cpp-python-build.yml

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,37 @@ jobs:
649649
name: ${{ matrix.os }}-Wheels.binaries
650650
path: ./wheelhouse/*.whl
651651

652+
Codecov:
653+
name: Code coverage
654+
needs: Linux
655+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
656+
runs-on: ubuntu-latest
657+
steps:
658+
- name: Install Ubuntu packages
659+
run: |
660+
sudo apt-get update
661+
sudo apt-get install cxxtest lcov
662+
- name: Checkout JSBSim
663+
uses: actions/checkout@v3
664+
- name: Configure JSBSim
665+
run: |
666+
mkdir build && cd build
667+
cmake -DENABLE_COVERAGE=ON -DBUILD_PYTHON_MODULE=OFF ..
668+
- name: Build JSBSim
669+
working-directory: build
670+
run: make -j2
671+
- name: Run JSBSim tests
672+
working-directory: build
673+
run: ctest -R Test1 --output-on-failure
674+
- name: Generate coverage report
675+
working-directory: build
676+
run: make lcov
677+
- name: Upload to Codecov
678+
uses: codecov/codecov-action@v3
679+
with:
680+
working-directory: build/lcov/data/capture
681+
files: all_targets.info
682+
652683
Rolling-Release:
653684
needs: [Python-Wheels, Test-Build-PyPackage-From-Source, Windows-MinGW32, Windows-installer]
654685
name: Deploy Rolling Release
@@ -804,19 +835,19 @@ jobs:
804835
- name: Install Ubuntu packages
805836
run: |
806837
sudo apt-get update
807-
sudo apt-get install doxygen graphviz cxxtest lcov
838+
sudo apt-get install doxygen graphviz
808839
- name: Set up Python 3.7
809840
uses: actions/setup-python@v4
810841
with:
811842
python-version: '3.7'
812843
- name: Install Python packages
813-
run: pip install -U numpy sphinx cython 'setuptools>=60.0.0'
844+
run: pip install -U numpy sphinx
814845
- name: Checkout JSBSim
815846
uses: actions/checkout@v3
816847
- name: Configure JSBSim
817848
run: |
818849
mkdir build && cd build
819-
cmake -DCMAKE_C_FLAGS_DEBUG="--coverage" -DCMAKE_CXX_FLAGS_DEBUG="--coverage" -DCMAKE_BUILD_TYPE=Debug ..
850+
cmake -DBUILD_PYTHON_MODULE=OFF ..
820851
- name: Download Python wheels
821852
uses: actions/download-artifact@v3
822853
with:
@@ -828,16 +859,6 @@ jobs:
828859
pip install jsbsim --no-index -f .
829860
touch documentation/html/.nojekyll
830861
sphinx-build -b html documentation documentation/html/python
831-
- name: Build JSBSim
832-
working-directory: build
833-
run: make -j2
834-
- name: Unit tests coverage
835-
working-directory: build
836-
run: |
837-
ctest -R Test1 --output-on-failure
838-
lcov -d . -c -o tmp.info
839-
lcov -r tmp.info /usr/include/c++/\* /usr/include/cxxtest/\* \*/tests/unit_tests/\* -o coverage.info
840-
genhtml -o documentation/html/coverage -t "JSBSim unit tests" coverage.info
841862
- name: Publish docs to GitHub Pages
842863
uses: crazy-max/ghaction-github-pages@v3
843864
with:

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ find_package(PkgConfig)
3434
# Build JSBSim libs and exec #
3535
################################################################################
3636

37+
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/tests/unit_tests/CMakeModules)
38+
find_package(codecov)
3739
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
3840
add_subdirectory(src)
3941

@@ -114,6 +116,11 @@ if (CXXTEST_FOUND)
114116
include_directories(${PROJECT_SOURCE_DIR}/src)
115117
enable_testing()
116118
add_subdirectory(tests/unit_tests)
119+
list(APPEND LCOV_REMOVE_PATTERNS "'*/JSBSim.cpp'")
120+
list(APPEND LCOV_REMOVE_PATTERNS "'*/GeographicLib/*'")
121+
list(APPEND LCOV_REMOVE_PATTERNS "'*/simgear/*'")
122+
list(APPEND LCOV_REMOVE_PATTERNS "'*/unit_tests/*'")
123+
coverage_evaluate()
117124
endif(CXXTEST_FOUND)
118125

119126
################################################################################

python/CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,9 @@ file(COPY ${PROJECT_SOURCE_DIR}/scripts DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/
6767

6868
# Copy each source file
6969
foreach(OBJECT ${libJSBSim_SOURCE_FILES})
70-
string(SUBSTRING ${OBJECT} 0 17 HEADER)
71-
if (${HEADER} STREQUAL "$<TARGET_OBJECTS:")
72-
string(LENGTH ${OBJECT} OBJECT_LENGTH)
73-
math(EXPR TARGET_LENGTH "${OBJECT_LENGTH}-18")
74-
string(SUBSTRING ${OBJECT} 17 ${TARGET_LENGTH} TARGET)
75-
get_target_property(TARGET_SOURCE_FILES ${TARGET} SOURCES)
76-
get_target_property(TARGET_SOURCE_DIRECTORY ${TARGET} TARGET_DIRECTORY)
70+
if(${OBJECT} MATCHES "TARGET_OBJECTS:([^ >]+)")
71+
get_target_property(TARGET_SOURCE_FILES ${CMAKE_MATCH_1} SOURCES)
72+
get_target_property(TARGET_SOURCE_DIRECTORY ${CMAKE_MATCH_1} TARGET_DIRECTORY)
7773
file(RELATIVE_PATH TARGET_PATH ${PROJECT_SOURCE_DIR} ${TARGET_SOURCE_DIRECTORY})
7874
file(MAKE_DIRECTORY ${TARGET_PATH})
7975
foreach(_FILE ${TARGET_SOURCE_FILES})

src/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ add_library(libJSBSim ${HEADERS} ${SOURCES}
6464
$<TARGET_OBJECTS:Simgear>
6565
$<TARGET_OBJECTS:GeographicLib>
6666
)
67+
add_coverage(libJSBSim)
6768

6869
if(EXPAT_FOUND)
6970
include_directories(${EXPAT_INCLUDE_DIRS})
@@ -87,12 +88,8 @@ set(JSBSIM_MSVC_COMPILE_DEFINITIONS ${MSVC_COMPILE_DEFINITIONS} PARENT_SCOPE)
8788
get_target_property(libJSBSim_SOURCE_FILES libJSBSim SOURCES)
8889

8990
foreach(OBJECT ${libJSBSim_SOURCE_FILES})
90-
string(SUBSTRING ${OBJECT} 0 17 HEADER)
91-
if (${HEADER} STREQUAL "$<TARGET_OBJECTS:")
92-
string(LENGTH ${OBJECT} OBJECT_LENGTH)
93-
math(EXPR TARGET_LENGTH "${OBJECT_LENGTH}-18")
94-
string(SUBSTRING ${OBJECT} 17 ${TARGET_LENGTH} TARGET_OBJECT)
95-
list(APPEND TARGET_OBJECTS_LIST ${TARGET_OBJECT})
91+
if (${OBJECT} MATCHES "TARGET_OBJECTS:([^ >]+)")
92+
list(APPEND TARGET_OBJECTS_LIST ${CMAKE_MATCH_1})
9693
endif()
9794
endforeach(OBJECT)
9895

@@ -168,6 +165,8 @@ endif()
168165

169166
add_executable(JSBSim JSBSim.cpp)
170167
target_link_libraries(JSBSim libJSBSim)
168+
# Add JSBSim to the coverage analysis to avoid linking errors
169+
add_coverage(JSBSim)
171170

172171
if(MSVC AND BUILD_SHARED_LIBS)
173172
# Under Windows, during the linking process, executables must have a

src/initialization/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ set(HEADERS FGInitialCondition.h
1111
add_library(Init OBJECT ${HEADERS} ${SOURCES})
1212
set_target_properties(Init PROPERTIES TARGET_DIRECTORY
1313
${CMAKE_CURRENT_SOURCE_DIR})
14+
add_coverage(Init)
1415

1516
install(FILES ${HEADERS} DESTINATION include/JSBSim/initialization
1617
COMPONENT devel)

src/input_output/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,7 @@ set_target_properties(InputOutput PROPERTIES TARGET_DIRECTORY
4444
# See https://docs.microsoft.com/fr-fr/windows/win32/winprog/using-the-windows-headers#setting-winver-or-_win32_winnt
4545
target_compile_definitions(InputOutput PRIVATE $<$<BOOL:${MINGW}>:_WIN32_WINNT=0x600>) # Windows Vista/Windows Server 2008
4646

47+
add_coverage(InputOutput)
48+
4749
install(FILES ${HEADERS} DESTINATION include/JSBSim/input_output
4850
COMPONENT devel)

src/math/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ set(HEADERS FGColumnVector3.h
3333
add_library(Math OBJECT ${HEADERS} ${SOURCES})
3434
set_target_properties(Math PROPERTIES TARGET_DIRECTORY
3535
${CMAKE_CURRENT_SOURCE_DIR})
36+
add_coverage(Math)
3637

3738
install(FILES ${HEADERS} DESTINATION include/JSBSim/math COMPONENT devel)

src/models/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ set(HEADERS FGAerodynamics.h
4848
add_library(Models OBJECT ${HEADERS} ${SOURCES})
4949
set_target_properties(Models PROPERTIES TARGET_DIRECTORY
5050
${CMAKE_CURRENT_SOURCE_DIR})
51+
add_coverage(Models)
5152

5253
install(FILES ${HEADERS} DESTINATION include/JSBSim/models COMPONENT devel)

src/models/atmosphere/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ set(HEADERS FGMSIS.h
1212
add_library(Atmosphere OBJECT ${HEADERS} ${SOURCES})
1313
set_target_properties(Atmosphere PROPERTIES TARGET_DIRECTORY
1414
${CMAKE_CURRENT_SOURCE_DIR})
15+
add_coverage(Atmosphere)
1516

1617
install(FILES ${HEADERS} DESTINATION include/JSBSim/models/atmosphere
1718
COMPONENT devel)

src/models/flight_control/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ set(HEADERS FGDeadBand.h
4040
add_library(FlightControl OBJECT ${HEADERS} ${SOURCES})
4141
set_target_properties(FlightControl PROPERTIES TARGET_DIRECTORY
4242
${CMAKE_CURRENT_SOURCE_DIR})
43+
add_coverage(FlightControl)
4344

4445
install(FILES ${HEADERS} DESTINATION include/JSBSim/models/flight_control
4546
COMPONENT devel)

0 commit comments

Comments
 (0)