diff --git a/.codecov.yml b/.codecov.yml index 6a10b8f39fb..526348cc5d7 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,8 +1,8 @@ ignore: - - src/windows/ - - src/test/ - - src/common/valgrind/ - - src/benchmarks/ + - '.*windows.*' + - '.*test.*' + - '.*valgrind.*' + - '.*benchmarks.*' comment: layout: "diff" diff --git a/utils/docker/build-CI.sh b/utils/docker/build-CI.sh index afbcd0c42c8..9cade9295f0 100755 --- a/utils/docker/build-CI.sh +++ b/utils/docker/build-CI.sh @@ -49,7 +49,7 @@ containerName=pmdk-${OS}-${OS_VER} if [[ $MAKE_PKG -eq 0 ]] ; then command="./run-build.sh"; fi if [[ $MAKE_PKG -eq 1 ]] ; then command="./run-build-package.sh"; fi -if [[ $COVERAGE -eq 1 ]] ; then command="./run-coverage.sh"; ci_env=`bash <(curl -s https://codecov.io/env)`; fi +if [[ $COVERAGE -eq 1 ]] ; then command="./run-coverage.sh"; fi if [[ $BANDIT -eq 1 ]] ; then command="./run-bandit.sh"; fi if [[ ( "$CI_EVENT_TYPE" == "cron" || "$CI_BRANCH" == "coverity_scan" )\ @@ -102,7 +102,6 @@ SCRIPTSDIR=$WORKDIR/utils/docker docker run --rm --name=$containerName -i $TTY \ --cap-add=SYS_PTRACE --security-opt seccomp=unconfined \ $DNS_SETTING \ - $ci_env \ --env http_proxy=$http_proxy \ --env https_proxy=$https_proxy \ --env AUTO_DOC_UPDATE=$AUTO_DOC_UPDATE \ @@ -134,6 +133,7 @@ docker run --rm --name=$containerName -i $TTY \ --env GITHUB_REF=$GITHUB_REF \ --env GITHUB_RUN_ID=$GITHUB_RUN_ID \ --env GITHUB_SHA=$GITHUB_SHA \ + --env GITHUB_SERVER_URL=$GITHUB_SERVER_URL \ --env CI_RUN=$CI_RUN \ --env SRC_CHECKERS=$SRC_CHECKERS \ --env BLACKLIST_FILE=$BLACKLIST_FILE \ diff --git a/utils/docker/images/0001-fix-generating-gcov-files-and-turn-off-verbose-log.patch b/utils/docker/images/0001-fix-generating-gcov-files-and-turn-off-verbose-log.patch deleted file mode 100644 index 7377d07f6fb..00000000000 --- a/utils/docker/images/0001-fix-generating-gcov-files-and-turn-off-verbose-log.patch +++ /dev/null @@ -1,37 +0,0 @@ -From d633d3b0a5f03be280efb80a69b9d5ed4e9c4d56 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?=C5=81ukasz=20Stolarczuk?= -Date: Tue, 14 Jul 2020 13:58:34 +0200 -Subject: [PATCH] fix generating gcov files and turn-off verbose log - ---- - codecov | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/codecov b/codecov -index e702ecd..0a2f4d8 100755 ---- a/codecov -+++ b/codecov -@@ -1108,9 +1108,9 @@ then - if [ "$ft_gcovout" = "0" ]; - then - # suppress gcov output -- bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -exec $gcov_exe -pb $gcov_arg {} +" >/dev/null 2>&1 || true -+ bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -execdir $gcov_exe -pb $gcov_arg {} \;" >/dev/null 2>&1 || true - else -- bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -exec $gcov_exe -pb $gcov_arg {} +" || true -+ bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -execdir $gcov_exe -pb $gcov_arg {} \;" || true - fi - else - say "${e}==>${x} gcov disabled" -@@ -1425,7 +1425,7 @@ do - report_len=$(wc -c < "$file") - if [ "$report_len" -ne 0 ]; - then -- say " ${g}+${x} $file ${e}bytes=$(echo "$report_len" | tr -d ' ')${x}" -+ #say " ${g}+${x} $file ${e}bytes=$(echo "$report_len" | tr -d ' ')${x}" - # append to to upload - _filename=$(basename "$file") - if [ "${_filename##*.}" = 'gcov' ]; --- -2.25.1 - diff --git a/utils/docker/images/Dockerfile.ubuntu-22.04 b/utils/docker/images/Dockerfile.ubuntu-22.04 index b0519330fa0..408458f7d89 100644 --- a/utils/docker/images/Dockerfile.ubuntu-22.04 +++ b/utils/docker/images/Dockerfile.ubuntu-22.04 @@ -1,5 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2016-2022, Intel Corporation +# Copyright 2016-2023, Intel Corporation # # Dockerfile - a 'recipe' for Docker to build an image of ubuntu-based @@ -56,7 +56,7 @@ ENV PACKAGING_DEPS "debhelper \ fakeroot" # CodeCov -ENV CODECOV_DEPS curl +ENV CODECOV_DEPS curl perl # Coverity ENV COVERITY_DEPS ruby gcc g++ wget @@ -71,10 +71,8 @@ ENV MISC_DEPS "clang \ # Copy install valgrind script COPY install-valgrind.sh install-valgrind.sh -# Copy codecov patch and script to download scripts required in run-*.sh +# Copy script to download codecov script required in run-coverage.sh COPY download-scripts.sh download-scripts.sh -COPY 0001-fix-generating-gcov-files-and-turn-off-verbose-log.patch \ - 0001-fix-generating-gcov-files-and-turn-off-verbose-log.patch # Update the Apt cache and install basic tools RUN apt-get update && apt-get dist-upgrade -y \ diff --git a/utils/docker/images/download-scripts.sh b/utils/docker/images/download-scripts.sh index fae37b4647b..448e38c8f26 100755 --- a/utils/docker/images/download-scripts.sh +++ b/utils/docker/images/download-scripts.sh @@ -1,18 +1,14 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2020, Intel Corporation +# Copyright 2020-2023, Intel Corporation # -# download-scripts.sh - downloads specific version of codecov's bash -# script to generate and upload reports. It's useful, -# since unverified version may break coverage results. +# download-scripts.sh - downloads latest version of +# codecov's uploader to generate and upload reports. # set -e -# master: Merge pull request #342 from codecov/revert-proj-name-..., 18.08.2020 -CODECOV_VERSION="e877c1280cc6e902101fb5df2981ed1c962da7f0" - if [ "${SKIP_SCRIPTS_DOWNLOAD}" ]; then echo "Variable 'SKIP_SCRIPTS_DOWNLOAD' is set; skipping scripts' download" exit @@ -20,13 +16,24 @@ fi mkdir -p /opt/scripts -# Download codecov's bash script -git clone https://github.com/codecov/codecov-bash -cd codecov-bash -git checkout $CODECOV_VERSION +if ! [ -x "$(command -v curl)" ]; then + echo "Error: curl is not installed." + return 1 +fi + +# Download codecov and check integrity +mkdir -p codecov-tmp +pushd codecov-tmp + +curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import +curl -Os https://uploader.codecov.io/latest/linux/codecov +curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM +curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig +gpgv codecov.SHA256SUM.sig codecov.SHA256SUM +shasum -a 256 -c codecov.SHA256SUM +chmod +x codecov -git apply ../0001-fix-generating-gcov-files-and-turn-off-verbose-log.patch mv -v codecov /opt/scripts/codecov -cd .. -rm -rf codecov-bash +popd +rm -rf codecov-tmp diff --git a/utils/docker/run-coverage.sh b/utils/docker/run-coverage.sh index 542ff83e5e7..9c9ff0e34c9 100755 --- a/utils/docker/run-coverage.sh +++ b/utils/docker/run-coverage.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2017-2022, Intel Corporation +# Copyright 2017-2023, Intel Corporation # # run-coverage.sh - is called inside a Docker container; runs tests @@ -19,31 +19,34 @@ export UT_DUMP_LINES=0 export UT_VALGRIND_SKIP_PRINT_MISMATCHED=1 # Build all and run tests -cd $WORKDIR +pushd ${WORKDIR} make -j$(nproc) COVERAGE=1 make -j$(nproc) test COVERAGE=1 -# XXX: unfortunately valgrind raports issues in coverage instrumentation +# XXX: unfortunately valgrind reports issues in coverage instrumentation # which we have to ignore (-k flag) -cd src/test +pushd src/test # do not change -j2 to -j$(nproc) in case of tests (make check/pycheck) make -kj2 pcheck-local-quiet TEST_BUILD=debug || true # do not change -j2 to -j$(nproc) in case of tests (make check/pycheck) make -kj2 pycheck TEST_BUILD=debug || true -cd ../.. +popd # prepare flag for codecov report to differentiate builds flag=tests -[ -n "$GITHUB_ACTIONS" ] && flag=GHA -[ -n "$TRAVIS" ] && flag=Travis - -# run gcov exe, using codecov's bash (remove parsed coverage files, set flag and exit 1 if not successful) -/opt/scripts/codecov -c -F ${flag} -Z - -printf "check for any leftover gcov files\n" -leftover_files=$(find . -name "*.gcov" | wc -l) -if [[ $leftover_files > 0 ]]; then +[ -n "${GITHUB_ACTIONS}" ] && flag=GHA +[ -n "${TRAVIS}" ] && flag=Travis + +# validate codecov.yaml file +cat "${WORKDIR}/.codecov.yml" | curl --data-binary @- https://codecov.io/validate + +# run codecov's uploader in current dir (WORKDIR), with gcov executable +# (clean parsed coverage files, set flag and exit 1 if not successful) +/opt/scripts/codecov --rootDir . --gcov --clean --flags ${flag} --nonZero --verbose +echo "Check for any leftover gcov files" +leftover_files=$(find . -name "*.gcov") +if [[ -n "${leftover_files}" ]]; then # display found files and exit with error (they all should be parsed) - find . -name "*.gcov" + echo "${leftover_files}" return 1 fi