|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -ex |
| 4 | + |
| 5 | +echo "Starting lcov-jenkins-gcc-13.sh" |
| 6 | + |
| 7 | +env |
| 8 | + |
| 9 | +if [ -z "${REPONAME}" ]; then |
| 10 | + echo "Please set the env variable REPONAME" |
| 11 | + exit 1 |
| 12 | +fi |
| 13 | + |
| 14 | +if [ -z "${ORGANIZATION}" ]; then |
| 15 | + echo "Please set the env variable ORGANIZATION" |
| 16 | + exit 1 |
| 17 | +fi |
| 18 | + |
| 19 | +# export USER=$(whoami) |
| 20 | +# echo "USER is ${USER}" |
| 21 | + |
| 22 | +# these packages are already installed on containers. |
| 23 | +sudo apt-get update |
| 24 | +sudo apt-get install -y python3-pip sudo git curl jq |
| 25 | + |
| 26 | +# codecov.sh installs perl packages also |
| 27 | +# sudo apt-get install -y libcapture-tiny-perl libdatetime-perl libdatetime-format-dateparse-perl |
| 28 | +sudo apt-get install -y libdatetime-format-dateparse-perl |
| 29 | + |
| 30 | +export B2_TOOLSET="gcc-13" |
| 31 | +export LCOV_VERSION="v2.1" |
| 32 | +export LCOV_OPTIONS="--ignore-errors mismatch" |
| 33 | + |
| 34 | +export REPO_NAME=${ORGANIZATION}/${REPONAME} |
| 35 | +export PATH=~/.local/bin:/usr/local/bin:$PATH |
| 36 | +export BOOST_CI_CODECOV_IO_UPLOAD="skip" |
| 37 | + |
| 38 | +run_coverage_reports () { |
| 39 | + |
| 40 | + git clone https://github.com/boostorg/boost-ci.git boost-ci-cloned --depth 1 |
| 41 | + cp -prf boost-ci-cloned/ci . |
| 42 | + rm -rf boost-ci-cloned |
| 43 | + |
| 44 | + export SELF=`basename $REPO_NAME` |
| 45 | + export BOOST_CI_SRC_FOLDER=$(pwd) |
| 46 | + |
| 47 | + . ./ci/common_install.sh |
| 48 | + |
| 49 | + # Formatted such as "cppalliance/buffers cppalliance/http-proto" |
| 50 | + for EXTRA_LIB in ${EXTRA_BOOST_LIBRARIES}; do |
| 51 | + EXTRA_LIB_REPO=`basename $EXTRA_LIB` |
| 52 | + if [ ! -d "$BOOST_ROOT/libs/${EXTRA_LIB_REPO}" ]; then |
| 53 | + pushd $BOOST_ROOT/libs |
| 54 | + git clone https://github.com/${EXTRA_LIB} -b $BOOST_BRANCH --depth 1 |
| 55 | + popd |
| 56 | + fi |
| 57 | + done |
| 58 | + |
| 59 | + cd $BOOST_ROOT/libs/$SELF |
| 60 | + ci/travis/codecov.sh |
| 61 | + |
| 62 | + # expecting a venv to already exist in /opt/venv. |
| 63 | + export pythonvirtenvpath=/opt/venv |
| 64 | + if [ -f ${pythonvirtenvpath}/bin/activate ]; then |
| 65 | + source ${pythonvirtenvpath}/bin/activate |
| 66 | + fi |
| 67 | + |
| 68 | + pip3 install gcovr || true |
| 69 | + |
| 70 | + cd $BOOST_CI_SRC_FOLDER |
| 71 | + |
| 72 | + export PATH=/tmp/lcov/bin:$PATH |
| 73 | + command -v lcov |
| 74 | + lcov --version |
| 75 | + |
| 76 | + lcov --ignore-errors unused --remove coverage.info -o coverage_filtered.info '*/test/*' '*/extra/*' |
| 77 | + |
| 78 | + # Now the tracefile is coverage_filtered.info |
| 79 | + genhtml --flat -o genhtml coverage_filtered.info |
| 80 | + |
| 81 | + ######################### |
| 82 | + # |
| 83 | + # gcovr |
| 84 | + # |
| 85 | + ######################### |
| 86 | + |
| 87 | + GCOVRFILTER=".*/$REPONAME/.*" |
| 88 | + mkdir gcovr |
| 89 | + mkdir -p json |
| 90 | + cd ../boost-root |
| 91 | + gcovr -p --html-details --exclude '.*/test/.*' --exclude '.*/extra/.*' --filter "$GCOVRFILTER" --html --output $BOOST_CI_SRC_FOLDER/gcovr/index.html |
| 92 | + ls -al $BOOST_CI_SRC_FOLDER/gcovr |
| 93 | + |
| 94 | + gcovr -p --json-summary --exclude '.*/test/.*' --exclude '.*/extra/.*' --filter "$GCOVRFILTER" --output $BOOST_CI_SRC_FOLDER/json/summary.json |
| 95 | + # jq . $BOOST_CI_SRC_FOLDER/json/summary.json |
| 96 | + |
| 97 | + gcovr -p --json --exclude '.*/test/.*' --exclude '.*/extra/.*' --filter "$GCOVRFILTER" --output $BOOST_CI_SRC_FOLDER/json/coverage.json |
| 98 | + # jq . $BOOST_CI_SRC_FOLDER/json/coverage.json |
| 99 | +} |
| 100 | + |
| 101 | +run_coverage_reports |
| 102 | + |
| 103 | +######################################################################### |
| 104 | +# |
| 105 | +# RUN EVERYTHING AGAIN the same way on the target branch, usually develop |
| 106 | +# |
| 107 | +######################################################################### |
| 108 | + |
| 109 | +# preparation: |
| 110 | + |
| 111 | +# "$CHANGE_TARGET" is a variable from multibranch-pipeline. |
| 112 | +TARGET_BRANCH="${CHANGE_TARGET}" |
| 113 | + |
| 114 | +cd $BOOST_CI_SRC_FOLDER |
| 115 | +BOOST_CI_SRC_FOLDER_ORIG=$BOOST_CI_SRC_FOLDER |
| 116 | +rm -rf ../boost-root |
| 117 | +cd .. |
| 118 | +# It was possible to have the new folder be named $SELF. |
| 119 | +# But just to be extra careful, choose another name such as |
| 120 | +ADIRNAME=${SELF}-target-branch-iteration |
| 121 | +git clone -b $TARGET_BRANCH https://github.com/$ORGANIZATION/$SELF $ADIRNAME |
| 122 | +cd $ADIRNAME |
| 123 | +# The "new" BOOST_CI_SRC_FOLDER: |
| 124 | +export BOOST_CI_SRC_FOLDER=$(pwd) |
| 125 | +export BOOST_CI_SRC_FOLDER_TARGET=$(pwd) |
| 126 | + |
| 127 | +# done with prep, now everything is the same as before |
| 128 | + |
| 129 | +run_coverage_reports |
| 130 | + |
| 131 | +# Done with building target branch. Return everything back. |
| 132 | + |
| 133 | +BOOST_CI_SRC_FOLDER=$BOOST_CI_SRC_FOLDER_ORIG |
| 134 | +cd $BOOST_CI_SRC_FOLDER |
| 135 | + |
| 136 | +######################################### |
| 137 | +# |
| 138 | +# gcov-compare.py. download and run it. |
| 139 | +# |
| 140 | +######################################### |
| 141 | + |
| 142 | +mkdir -p ~/.local/bin |
| 143 | +GITHUB_REPO_URL="https://github.com/cppalliance/ci-automation/raw/master" |
| 144 | +DIR="scripts" |
| 145 | +FILENAME="gcov-compare.py" |
| 146 | +URL="${GITHUB_REPO_URL}/$DIR/$FILENAME" |
| 147 | +FILE=~/.local/bin/$FILENAME |
| 148 | +if [ ! -f "$FILE" ]; then |
| 149 | + curl -s -S --retry 10 -L -o $FILE $URL && chmod 755 $FILE |
| 150 | +fi |
| 151 | + |
| 152 | +$FILE $BOOST_CI_SRC_FOLDER_ORIG/json/summary.json $BOOST_CI_SRC_FOLDER_TARGET/json/summary.json > gcovr/coverage_diff.txt |
0 commit comments