Skip to content

Commit

Permalink
Setup CodeCov (#29)
Browse files Browse the repository at this point in the history
* add codecov.yml

* enabled codecov through blt

* install lcov in docker imaage
  • Loading branch information
rrsettgast authored Dec 30, 2023
1 parent 4a411fa commit 8b8e52d
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 13 deletions.
46 changes: 37 additions & 9 deletions .github/workflows/continuousIntegration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
CMAKE_CXX_COMPILER: /usr/bin/clang++
CMAKE_C_COMPILER: /usr/bin/clang
CMAKE_BUILD_TYPE: Release
BUILD_AND_TEST_ARGS: --code_checks
BUILD_AND_TEST_ARGS: --code-checks
run: ./scripts/ci_build_and_test.sh

linux_builds:
Expand Down Expand Up @@ -101,39 +101,39 @@ jobs:
CMAKE_C_COMPILER: /opt/rh/gcc-toolset-12/root/bin/gcc
CMAKE_BUILD_TYPE: Release

- name: ubuntu22-gcc11-rel (ubi8.8, gcc 11.4.0, Release)
- name: ubuntu22-gcc11-rel (ubuntu-22, gcc 11.4.0, Release)
DOCKER_REPOSITORY: geosx/ubuntu:22.04
OS: ubuntu-22.04
CMAKE_CXX_COMPILER: /usr/bin/g++
CMAKE_C_COMPILER: /usr/bin/gcc
CMAKE_BUILD_TYPE: Release
BUILD_AND_TEST_ARGS: "--disable-unit-tests"

- name: ubuntu22-clang14-rel (ubi8.8, clang-14.0.0, Release)
- name: ubuntu22-clang14-rel (ubuntu-22, clang-14.0.0, Release)
DOCKER_REPOSITORY: geosx/ubuntu:22.04
OS: ubuntu-22.04
CMAKE_CXX_COMPILER: /usr/bin/clang++
CMAKE_C_COMPILER: /usr/bin/clang
CMAKE_BUILD_TYPE: Release
BUILD_AND_TEST_ARGS: "--disable-unit-tests"

- name: ubuntu22-clang14-dbg (ubi8.8, clang-14.0.0, Debug)
- name: ubuntu22-clang14-dbg (ubuntu-22, clang-14.0.0, Debug)
DOCKER_REPOSITORY: geosx/ubuntu:22.04
OS: ubuntu-22.04
CMAKE_CXX_COMPILER: /usr/bin/clang++
CMAKE_C_COMPILER: /usr/bin/clang
CMAKE_BUILD_TYPE: Debug
BUILD_AND_TEST_ARGS: "--disable-unit-tests"

- name: ubuntu22-gcc11-dbg (ubi8.8, gcc 11.4.0, Release)
- name: ubuntu22-gcc11-dbg (ubuntu-22, gcc 11.4.0, Release)
DOCKER_REPOSITORY: geosx/ubuntu:22.04
OS: ubuntu-22.04
CMAKE_CXX_COMPILER: /usr/bin/g++
CMAKE_C_COMPILER: /usr/bin/gcc
CMAKE_BUILD_TYPE: Debug
BUILD_AND_TEST_ARGS: "--disable-unit-tests"

- name: ubuntu22-gcc11-cuda11-rel (ubi8.8, gcc 11.4.0, cuda-11.8.0, Release)
- name: ubuntu22-gcc11-cuda11-rel (ubuntu-22, gcc 11.4.0, cuda-11.8.0, Release)
DOCKER_REPOSITORY: geosx/ubuntu:22.04-cuda11.8.0
OS: ubuntu-22.04
CMAKE_CXX_COMPILER: /usr/bin/g++
Expand All @@ -142,7 +142,7 @@ jobs:
ENABLE_CUDA: ON
BUILD_AND_TEST_ARGS: "--disable-unit-tests"

- name: ubuntu22-gcc11-cuda11-dbg (ubi8.8, gcc 11.4.0, cuda-11.8.0, Debug)
- name: ubuntu22-gcc11-cuda11-dbg (ubuntu-22, gcc 11.4.0, cuda-11.8.0, Debug)
DOCKER_REPOSITORY: geosx/ubuntu:22.04-cuda11.8.0
OS: ubuntu-22.04
CMAKE_CXX_COMPILER: /usr/bin/g++
Expand All @@ -151,7 +151,7 @@ jobs:
ENABLE_CUDA: ON
BUILD_AND_TEST_ARGS: "--disable-unit-tests"

- name: ubuntu22-clang14-cuda11-rel (ubi8.8, clang-14.0.0, cuda-11.8.0, Release)
- name: ubuntu22-clang14-cuda11-rel (ubuntu-22, clang-14.0.0, cuda-11.8.0, Release)
DOCKER_REPOSITORY: geosx/ubuntu:22.04-cuda11.8.0
OS: ubuntu-22.04
CMAKE_CXX_COMPILER: /usr/bin/clang++
Expand All @@ -160,7 +160,7 @@ jobs:
ENABLE_CUDA: ON
BUILD_AND_TEST_ARGS: "--disable-unit-tests"

- name: ubuntu22-clang14-cuda11-dbg (ubi8.8, clang-14.0.0, cuda-11.8.0, Debug)
- name: ubuntu22-clang14-cuda11-dbg (ubuntu-22, clang-14.0.0, cuda-11.8.0, Debug)
DOCKER_REPOSITORY: geosx/ubuntu:22.04-cuda11.8.0
OS: ubuntu-22.04
CMAKE_CXX_COMPILER: /usr/bin/clang++
Expand Down Expand Up @@ -208,6 +208,34 @@ jobs:
HOST_CONFIG: hostconfigs/environment.cmake
run: ./scripts/ci_build_and_test.sh

code_coverage:
runs-on: ubuntu-22.04
needs:
- linux_builds
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: run code coverage
env:
DOCKER_REPOSITORY: geosx/ubuntu:22.04
HOST_CONFIG: hostconfigs/environment.cmake
CMAKE_CXX_COMPILER: /usr/bin/g++
CMAKE_C_COMPILER: /usr/bin/gcc
CMAKE_BUILD_TYPE: Debug
BUILD_AND_TEST_ARGS: "--build-exe --code-coverage"
run: ./scripts/ci_build_and_test.sh
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: shiva_coverage.info.cleaned
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}


check_that_all_jobs_succeeded:
runs-on: ubuntu-22.04
needs:
Expand Down
11 changes: 10 additions & 1 deletion cmake/Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ macro(shiva_add_code_checks)

set( CPPCHECK_FLAGS --std=c++17
--enable=all
--suppress=missingIncludeSystem
--suppress=missingIncludeSystem
--suppress=unmatchedSuppression
--suppress=missingInclude
--suppress=noConstructor
--suppress=noExplicitConstructor
--suppress=unusedFunction
--suppress=constStatement
--suppress=unusedStructMember )
Expand All @@ -60,4 +62,11 @@ macro(shiva_add_code_checks)
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()


if (ENABLE_COVERAGE)
blt_add_code_coverage_target(NAME ${arg_PREFIX}_coverage
RUNNER ${CMAKE_MAKE_PROGRAM} test
SOURCE_DIRECTORIES ${PROJECT_SOURCE_DIR}/src )
endif()
endmacro(shiva_add_code_checks)
3 changes: 2 additions & 1 deletion docker/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ RUN ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime && \
g++ \
clang \
cppcheck \
clang-tidy
clang-tidy \
lcov

ARG CMAKE_VERSION=3.23.5
RUN curl -fsSL -k https://cmake.org/files/v${CMAKE_VERSION%.[0-9]*}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz | tar --directory=/usr/local --strip-components=1 -xzf -
Expand Down
5 changes: 5 additions & 0 deletions hostconfigs/apple/macOS_base.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ set( DOXYGEN_EXECUTABLE "${HOMEBREW_DIR}/bin/doxygen" CACHE PATH "" FORCE)
set( CPPCHECK_EXECUTABLE "${HOMEBREW_DIR}/bin/cppcheck" CACHE PATH "" FORCE)
set( CLANGTIDY_EXECUTABLE "${HOMEBREW_DIR}/opt/llvm/bin/clang-tidy" CACHE PATH "" FORCE)

set( ENABLE_COVERAGE ON CACHE BOOL "" FORCE)
set( GCOV_EXECUTABLE "/usr/bin/gcov" CACHE PATH "" FORCE)
set( LCOV_EXECUTABLE "${HOMEBREW_DIR}/bin/lcov" CACHE PATH "" FORCE)


set(SHIVA_BUILD_OBJ_LIBS ON CACHE BOOL "" FORCE)
19 changes: 17 additions & 2 deletions scripts/ci_build_and_test_in_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,20 @@ if [[ -z "${CMAKE_BUILD_TYPE}" ]]; then
exit 1
fi

if [[ "$*" == *--code-coverage* ]]; then
ENABLE_COVERAGE=ON
else
ENABLE_COVERAGE=OFF
fi

SHIVA_BUILD_DIR=/tmp/build
SHIVA_INSTALL_DIR=/tmp/install
or_die python3 scripts/config-build.py \
-hc ${HOST_CONFIG} \
-bt ${CMAKE_BUILD_TYPE} \
-bp ${SHIVA_BUILD_DIR} \
-ip ${SHIVA_INSTALL_DIR}
-ip ${SHIVA_INSTALL_DIR}\
-DENABLE_COVERAGE:BOOL=${ENABLE_COVERAGE}

or_die cd ${SHIVA_BUILD_DIR}

Expand All @@ -55,14 +62,22 @@ if [[ "$*" == *--test-doxygen* ]]; then
fi

# code checks
if [[ "$*" == *----code_checks* ]]; then
if [[ "$*" == *--code-checks* ]]; then
or_die ctest --output-on-failure -R "testCppCheck|testClangTidy"
exit 0
fi




if [[ "$*" == *--build-exe* ]]; then
or_die make -j $(nproc)

if [[ "$*" == *--code-coverage* ]]; then
or_die make shiva_coverage
cp -r ${SHIVA_BUILD_DIR}/shiva_coverage.info.cleaned /tmp/Shiva/shiva_coverage.info.cleaned
fi

if [[ "$*" != *--disable-unit-tests* ]]; then
or_die ctest --output-on-failure -E "testUncrustifyCheck|testDoxygenCheck|testCppCheck|testClangTidy"
fi
Expand Down

0 comments on commit 8b8e52d

Please sign in to comment.