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

common: move on to the new coverage uploader #5548

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ignore:
- src/windows/
- src/test/
- src/common/valgrind/
- src/benchmarks/
- '.*windows.*'
- '.*test.*'
- '.*valgrind.*'
- '.*benchmarks.*'

comment:
layout: "diff"
Expand Down
4 changes: 2 additions & 2 deletions utils/docker/build-CI.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" )\
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down

This file was deleted.

8 changes: 3 additions & 5 deletions utils/docker/images/Dockerfile.ubuntu-22.04
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 \
Expand Down
35 changes: 21 additions & 14 deletions utils/docker/images/download-scripts.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
#!/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
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
33 changes: 18 additions & 15 deletions utils/docker/run-coverage.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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