Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code coverage integration in SRF #105

Merged
18 commits merged into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ option(SRF_USE_CCACHE "Enable caching compilation results with ccache" OFF)
option(SRF_USE_CLANG_TIDY "Enable running clang-tidy as part of the build process" OFF)
option(SRF_USE_CONDA "Enables finding dependencies via conda instead of vcpkg. Note: This will disable vcpkg. All dependencies must be installed first in the conda environment" ON)
option(SRF_USE_IWYU "Enable running include-what-you-use as part of the build process" OFF)
option(SRF_WITH_CODECOV "Enable gcov code coverage" OFF)
drobison00 marked this conversation as resolved.
Show resolved Hide resolved
mdemoret-nv marked this conversation as resolved.
Show resolved Hide resolved

set(SRF_RAPIDS_VERSION "22.06" CACHE STRING "Which version of RAPIDs to build for. Sets default versions for RAPIDs CMake and RMM.")
set(SRF_RAPIDS_VERSION "22.06" CACHE STRING "Which version of RAPIDS to build for. Sets default versions for RAPIDS CMake and RMM.")

set(SRF_CACHE_DIR "${CMAKE_SOURCE_DIR}/.cache" CACHE PATH "Directory to contain all CPM and CCache data")
mark_as_advanced(SRF_CACHE_DIR)
Expand Down Expand Up @@ -61,6 +62,7 @@ project(srf
LANGUAGES C CXX
)


# Delay enabling CUDA until after we have determined our CXX compiler
if(NOT DEFINED CMAKE_CUDA_HOST_COMPILER)
message(STATUS "Setting CUDA host compiler to match CXX compiler: ${CMAKE_CXX_COMPILER}")
Expand Down Expand Up @@ -139,6 +141,44 @@ include(cmake/setup_compiler.cmake)
# Setup IWYU if enabled
include(cmake/setup_iwyu.cmake)

# Include coverage tools if enabled
if(SRF_WITH_CODECOV)
include(cmake/LibCodeCoverage.cmake)

setup_target_for_coverage_lcov(
NAME lcov-report
EXCLUDE
".cache/*"
"tests/*"
"python/srf/tests/*"
"python/srf/_pysrf/tests/*"
)

setup_target_for_coverage_gcovr_xml(
NAME gcovr-xml-report
EXCLUDE
".cache/*"
"tests/*"
"python/srf/tests/*"
"python/srf/_pysrf/tests/*"
)

setup_target_for_coverage_gcovr_html(
NAME gcovr-html-report
EXCLUDE
".cache/*"
"tests/*"
"python/srf/tests/*"
"python/srf/_pysrf/tests/*"
)

# Anaconda doesn't seem to have a fastcov package -- disable for now
# setup_target_for_coverage_fastcov(
# NAME fastcov-report
# EXCLUDE ".cache/*"
# )
endif()

####################################
# - Begin SRF Targets --------------

Expand Down Expand Up @@ -280,6 +320,10 @@ set_target_properties(libsrf PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
# Finally, set the install RPATH to include the stubs folder for CUDA::nvml. If thats made private, this can be removed
set_target_properties(libsrf PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN:${CMAKE_INSTALL_PREFIX}/lib/stubs")

if(SRF_WITH_CODECOV)
append_coverage_compiler_flags_to_target(libsrf)
endif()

###################################################################################################
# - install targets -------------------------------------------------------------------------------
rapids_cmake_install_lib_dir(lib_dir)
Expand Down Expand Up @@ -318,6 +362,7 @@ endif ()

add_subdirectory(tools/nvrpc)


###################################################################################################
# - install export --------------------------------------------------------------------------------

Expand Down
70 changes: 67 additions & 3 deletions ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pipeline {
stage('Builds') {
failFast true
parallel {
stage('Build:linux:x86_64:gcc') {
stage('Build:linux:x86_64:gcc:release') {
drobison00 marked this conversation as resolved.
Show resolved Hide resolved
options {
timeout(time: 1, unit: 'HOURS')
}
Expand Down Expand Up @@ -69,6 +69,38 @@ pipeline {
}
}
}
stage('Build:linux:x86_64:gcc:debug') {
options {
timeout(time: 1, unit: 'HOURS')
}
environment {
BUILD_CC= "gcc-coverage"
PARALLEL_LEVEL = '16'
HOME = "${WORKSPACE}"
}
agent {
docker {
image 'gpuci/rapidsai-driver:21.10-cuda11.4-devel-ubuntu20.04-py3.8'
label 'cpu4'
}
}
steps {
cleanWs(
deleteDirs: true,
externalDelete: 'sudo rm -rf %s'
)
checkout scm
withCredentials([[
$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: "aws-s3-gpuci",
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
]])
{
sh "${WORKSPACE}/ci/scripts/jenkins/build.sh"
}
}
}
stage('Build:linux:x86_64:clang') {
options {
timeout(time: 1, unit: 'HOURS')
Expand Down Expand Up @@ -132,13 +164,44 @@ pipeline {
}
}
}

}
}
stage('Tests') {
failFast true
parallel {
stage('Test') {
stage('TestDebug') {
drobison00 marked this conversation as resolved.
Show resolved Hide resolved
options {
timeout(time: 1, unit: 'HOURS')
}
agent {
docker {
image 'gpuci/rapidsai:21.10-cuda11.4-devel-ubuntu20.04-py3.8'
label 'driver-495'
args '--cap-add=sys_nice'
drobison00 marked this conversation as resolved.
Show resolved Hide resolved
}
}
environment {
BUILD_TYPE = "Debug"
HOME = "${WORKSPACE}"
drobison00 marked this conversation as resolved.
Show resolved Hide resolved
}
steps {
cleanWs(
deleteDirs: true,
externalDelete: 'sudo rm -rf %s'
)
checkout scm
withCredentials([[
$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: "aws-s3-gpuci",
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
]])
{
sh "${WORKSPACE}/ci/scripts/jenkins/test.sh"
}
}
}
stage('TestRelease') {
options {
timeout(time: 1, unit: 'HOURS')
}
Expand All @@ -150,6 +213,7 @@ pipeline {
}
}
environment {
BUILD_TYPE = "Release"
HOME = "${WORKSPACE}"
}
steps {
Expand Down
2 changes: 2 additions & 0 deletions ci/conda/environments/dev_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies:
- doxygen=1.9.2
- flatbuffers=2.0
- gcc_linux-64=9.4
- gcovr=5.1
- gflags=2.2
- git>=2.35.3 # Needed for wildcards on safe.directory
- glog=0.6
Expand All @@ -22,6 +23,7 @@ dependencies:
- grpc-cpp=1.45
- gtest=1.10
- gxx_linux-64=9.4
- lcov=1.15
- libhwloc=2.5
- librmm=22.06
- libtool
Expand Down
2 changes: 1 addition & 1 deletion ci/scripts/copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
re.compile(r"[.]flake8[.]cython$"),
re.compile(r"meta[.]yaml$")
]
ExemptFiles = ['.cache', 'build', 'cmake/LibFindMacros.cmake', 'versioneer.py']
ExemptFiles = ['.cache', 'build', 'cmake/LibCodeCoverage.cmake', 'cmake/LibFindMacros.cmake', 'versioneer.py']

# this will break starting at year 10000, which is probably OK :)
CheckSimple = re.compile(r"Copyright *(?:\(c\))? *(\d{4}),? *NVIDIA C(?:ORPORATION|orporation)")
Expand Down
5 changes: 5 additions & 0 deletions ci/scripts/jenkins/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ if [[ "${BUILD_CC}" == "gcc" ]]; then
gcc --version
g++ --version
CMAKE_FLAGS="${CMAKE_BUILD_ALL_FEATURES} ${CMAKE_CACHE_FLAGS}"
elif [[ "${BUILD_CC}" == "gcc-coverage" ]]; then
gpuci_logger "Building with GCC with gcov profile '-g -fprofile-arcs -ftest-coverage"
gcc --version
g++ --version
CMAKE_FLAGS="${CMAKE_BUILD_ALL_FEATURES} ${CMAKE_BUILD_WITH_CODECOV} ${CMAKE_CACHE_FLAGS}"
else
gpuci_logger "Installing Clang"
mamba env update -q -n srf --file ${SRF_ROOT}/ci/conda/environments/clang_env.yml
Expand Down
1 change: 1 addition & 0 deletions ci/scripts/jenkins/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export NUM_PROC=${PARALLEL_LEVEL:-$(nproc)}
export CONDA_ENV_YML="${SRF_ROOT}/ci/conda/environments/dev_env.yml"

export CMAKE_BUILD_ALL_FEATURES="-DCMAKE_MESSAGE_CONTEXT_SHOW=ON -DSRF_BUILD_BENCHMARKS=ON -DSRF_BUILD_EXAMPLES=ON -DSRF_BUILD_PYTHON=ON -DSRF_BUILD_TESTS=ON -DSRF_USE_CONDA=ON"
export CMAKE_BUILD_WITH_CODECOV="-DSRF_WITH_CODECOV=ON"

# Set the depth to allow git describe to work
export GIT_DEPTH=1000
Expand Down
11 changes: 10 additions & 1 deletion ci/scripts/jenkins/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,22 @@ pytest -v --junit-xml=${WORKSPACE_TMP}/report_pytest.xml
PYTEST_RESULTS=$?
set -e

if [[ "${BUILD_TYPE}" == "Debug" ]]; then
gpuci_logger "Generating codecov report"
cd ${SRF_ROOT}
cmake --build build --target gcovr-html-report

gpuci_logger "Archiving codecov report"
tar cfj ${WORKSPACE_TMP}/coverage_reports.tar.bz ${SRF_ROOT}/build/gcovr-html-report
aws s3 cp ${WORKSPACE_TMP}/coverage_reports.tar.bz "${ARTIFACT_URL}/coverage_reports.tar.bz"
fi

gpuci_logger "Archiving test reports"
cd $(dirname ${REPORTS_DIR})
tar cfj ${WORKSPACE_TMP}/test_reports.tar.bz $(basename ${REPORTS_DIR})

gpuci_logger "Pushing results to ${DISPLAY_ARTIFACT_URL}/"
aws s3 cp ${WORKSPACE_TMP}/test_reports.tar.bz "${ARTIFACT_URL}/test_reports.tar.bz"


TEST_RESULTS=$(($CTEST_RESULTS+$PYTEST_RESULTS))
exit ${TEST_RESULTS}
Loading