From b003aaee71f790dc7534b4d77dfe137549dcbfb0 Mon Sep 17 00:00:00 2001 From: Oksana Salyk Date: Fri, 19 Apr 2024 09:07:01 +0200 Subject: [PATCH] common: update CODECOV workflow file --- .github/workflows/main.yml | 2 ++ .github/workflows/scan_coverage.yml | 13 ++++++- .github/workflows/scans.yml | 2 ++ utils/docker/images/Dockerfile.ubuntu-22.04 | 6 +--- utils/docker/images/download-scripts.sh | 39 --------------------- utils/docker/run-coverage.sh | 20 +---------- 6 files changed, 18 insertions(+), 64 deletions(-) delete mode 100755 utils/docker/images/download-scripts.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e2eef50cc19..49b378103dc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -106,4 +106,6 @@ jobs: coverage_scan: needs: [src_checkers, basic_build] uses: ./.github/workflows/scan_coverage.yml + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} name: Coverage diff --git a/.github/workflows/scan_coverage.yml b/.github/workflows/scan_coverage.yml index 521c0fd8cb1..6fcef3d30a1 100644 --- a/.github/workflows/scan_coverage.yml +++ b/.github/workflows/scan_coverage.yml @@ -3,6 +3,9 @@ name: Coverage on: workflow_call: + secrets: + CODECOV_TOKEN: + required: true env: # Note: All coverage scans, e.g. on pull requests, should be run in the same @@ -32,5 +35,13 @@ jobs: - name: Pull the image run: cd $WORKDIR && ./pull-or-rebuild-image.sh - - name: Measure and upload code coverage + - name: Run the build run: cd $WORKDIR && ./build-CI.sh + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + root_dir: /home/runner/work/pmdk/pmdk/ + directory: /home/runner/work/pmdk/pmdk/ + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true diff --git a/.github/workflows/scans.yml b/.github/workflows/scans.yml index fc7ab815547..7bafd77ad01 100644 --- a/.github/workflows/scans.yml +++ b/.github/workflows/scans.yml @@ -22,6 +22,8 @@ jobs: name: Coverity call-coverage: uses: ./.github/workflows/scan_coverage.yml + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} name: Coverage call-documentation: uses: ./.github/workflows/scan_documentation.yml diff --git a/utils/docker/images/Dockerfile.ubuntu-22.04 b/utils/docker/images/Dockerfile.ubuntu-22.04 index 25ae8a0f62b..41dbb7af646 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-2023, Intel Corporation +# Copyright 2016-2024, Intel Corporation # # Dockerfile - a 'recipe' for Docker to build an image of ubuntu-based @@ -83,9 +83,6 @@ ENV PYTHON_DEPS "\ # Copy install valgrind script COPY install-valgrind.sh install-valgrind.sh -# Copy script to download codecov script required in run-coverage.sh -COPY download-scripts.sh download-scripts.sh - # Update the Apt cache and install basic tools RUN apt-get update && apt-get dist-upgrade -y \ && apt-get install -y --no-install-recommends \ @@ -100,7 +97,6 @@ RUN apt-get update && apt-get dist-upgrade -y \ $COVERITY_DEPS \ $MISC_DEPS \ && ./install-valgrind.sh ubuntu \ - && ./download-scripts.sh \ && rm -rf /var/lib/apt/lists/* RUN pip3 install $PYTHON_DEPS diff --git a/utils/docker/images/download-scripts.sh b/utils/docker/images/download-scripts.sh deleted file mode 100755 index 448e38c8f26..00000000000 --- a/utils/docker/images/download-scripts.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: BSD-3-Clause -# Copyright 2020-2023, Intel Corporation - -# -# download-scripts.sh - downloads latest version of -# codecov's uploader to generate and upload reports. -# - -set -e - -if [ "${SKIP_SCRIPTS_DOWNLOAD}" ]; then - echo "Variable 'SKIP_SCRIPTS_DOWNLOAD' is set; skipping scripts' download" - exit -fi - -mkdir -p /opt/scripts - -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 - -mv -v codecov /opt/scripts/codecov - -popd -rm -rf codecov-tmp diff --git a/utils/docker/run-coverage.sh b/utils/docker/run-coverage.sh index 823414c4563..afba8e67fa5 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-2023, Intel Corporation +# Copyright 2017-2024, Intel Corporation # # run-coverage.sh - is called inside a Docker container; runs tests @@ -31,21 +31,3 @@ 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 popd - -# prepare flag for codecov report to differentiate builds -flag=tests -[ -n "${GITHUB_ACTIONS}" ] && flag=GHA - -# 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) - echo "${leftover_files}" - return 1 -fi