Skip to content

Commit

Permalink
[coverage] Fix codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Mar 17, 2024
1 parent df1b082 commit 296fd06
Show file tree
Hide file tree
Showing 18 changed files with 350 additions and 299 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ jobs:
matrix:
os: [macos-latest]
build_type: [Release]
enable_simd: [ON]
env:
COMPILER: clang
BUILD_TYPE: ${{ matrix.build_type }}
BUILD_DARTPY: ON
DART_USE_SYSTEM_ENTT: ON
IN_CI: ON
ENABLE_SIMD: ${{ matrix.enable_simd }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ jobs:
codecov: [OFF]
check_format: [OFF]
build_dartpy: [ON]
enable_simd: [ON]
include:
# For code coverage report to Codecov
- os: ubuntu-jammy
build_type: Debug
codecov: ON
check_format: ON
build_dartpy: ON
enable_simd: ON
env:
# Hosted on: https://hub.docker.com/repository/docker/jslee02/dart-dev
DART_DEV_IMAGE: jslee02/dart-dev
Expand All @@ -49,7 +51,11 @@ jobs:
BUILD_TYPE: ${{ matrix.build_type }}
BUILD_DARTPY: "${{ matrix.build_dartpy }}"
CODECOV: ${{ matrix.codecov }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
CHECK_FORMAT: ${{ matrix.check_format }}
ENABLE_SIMD: ${{ matrix.enable_simd }}
IN_CI: ON
IN_DOCKER: ON
steps:
# https://github.com/marketplace/actions/docker-setup-qemu
- name: Set up QEMU
Expand Down
41 changes: 37 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ dart_option(DART_FAST_DEBUG "Add -O1 option for DEBUG mode build" OFF)
dart_option(DART_FORCE_COLORED_OUTPUT
"Always produce ANSI-colored output (GNU/Clang only)." OFF)
dart_option(DART_USE_SYSTEM_ENTT "Use system EnTT" OFF)
dart_option(DART_IN_CI "Indicate building DART as part of CI" OFF)

#===============================================================================
# Print intro
Expand All @@ -128,11 +129,38 @@ message(STATUS "")
# CodeCov settings
#===============================================================================
if(DART_CODECOV)
include(CodeCoverage)
setup_target_for_coverage(codecov ctest coverage)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage"
# Set up custom targets for code coverage
dart_coverage(
INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dart
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dart
)

# Code Coverage Configuration
add_library(coverage_config INTERFACE)

# CodeCov can only be enabled in Debug mode
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(FATAL_ERROR "CodeCov can only be enabled in Debug mode")
endif()

# CodeCov can only be enabled with GCC or Clang
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
message(FATAL_ERROR "CodeCov can only be enabled with GCC or Clang")
endif()

# Add required flags (GCC & LLVM/Clang)
target_compile_options(coverage_config INTERFACE
-O0 # no optimization
-g # generate debug info
--coverage # sets all required flags
)

# Add required flags (GCC & LLVM/Clang)
target_link_options(coverage_config INTERFACE --coverage)

# Export CodeCov configuration
install(TARGETS coverage_config DESTINATION lib EXPORT coverage_config)
install(EXPORT coverage_config DESTINATION ${CONFIG_INSTALL_DIR})
endif()

#===============================================================================
Expand Down Expand Up @@ -670,6 +698,11 @@ if(TARGET dartpy)
message(STATUS "Run 'make dartpy' to build dartpy")
message(STATUS "Run 'make install' to install dartpy")
endif()
if(TARGET coverage)
message(STATUS "- 'coverage' : generage coverage report")
message(STATUS "- 'coverage_html': generage coverage report in html")
message(STATUS "- 'coverage_view': view generaged coverage report in a browser")
endif()

#===============================================================================
# END
Expand Down
208 changes: 0 additions & 208 deletions cmake/CodeCoverage.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/DARTFindpagmo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
#
# This file is provided under the "BSD-style" License

find_package(pagmo 2.17.0 QUIET CONFIG)
find_package(pagmo QUIET CONFIG)
Loading

0 comments on commit 296fd06

Please sign in to comment.