vpp: disable ccache for gcc builds
[ci-management.git] / jjb / scripts / vpp / cov-build.sh
1 #!/bin/bash
2
3 # Copyright (c) 2023 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 echo "---> jjb/scripts/vpp/cov-build.sh"
17
18 set -euxo pipefail
19
20 line="*************************************************************************"
21 # Don't build anything if this is a merge job.
22 if [[ ${JOB_NAME} == *merge* ]] ; then
23     echo -e "\n$line\nSkipping build."
24     exit 0
25 fi
26
27 OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
28 OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
29 OS_ARCH=$(uname -m)
30 DRYRUN="${DRYRUN:-}"
31 IS_CSIT_VPP_JOB="${IS_CSIT_VPP_JOB:-}"
32 MAKE_PARALLEL_FLAGS="${MAKE_PARALLEL_FLAGS:-}"
33 MAKE_PARALLEL_JOBS="${MAKE_PARALLEL_JOBS:-}"
34 MAKE_TEST_OS="${MAKE_TEST_OS:-ubuntu-22.04}"
35 MAKE_TEST_MULTIWORKER_OS="${MAKE_TEST_MULTIWORKER_OS:-debian-11}"
36 VPPAPIGEN_TEST_OS="${VPPAPIGEN_TEST_OS:-${MAKE_TEST_OS}}"
37 BUILD_RESULT="SUCCESSFULLY COMPLETED"
38 BUILD_ERROR=""
39 RETVAL="0"
40
41 if [ -n "${MAKE_PARALLEL_FLAGS}" ] ; then
42   echo "Building VPP. Number of cores for build set with" \
43        "MAKE_PARALLEL_FLAGS='${MAKE_PARALLEL_FLAGS}'."
44 elif [ -n "${MAKE_PARALLEL_JOBS}" ] ; then
45   echo "Building VPP. Number of cores for build set with" \
46        "MAKE_PARALLEL_JOBS='${MAKE_PARALLEL_JOBS}'."
47 else
48     echo "Building VPP. Number of cores not set," \
49          "using build default ($(grep -c ^processor /proc/cpuinfo))."
50 fi
51
52 make_test_coverage_report() {
53     if ! make UNATTENDED=yes install-dep ; then
54         BUILD_ERROR="FAILED 'make install-dep'"
55         return
56     fi
57     if ! make UNATTENDED=yes install-ext-deps ; then
58         BUILD_ERROR="FAILED 'make install-ext-deps'"
59         return
60     fi
61     if ! make UNATTENDED=yes test-dep ; then
62         BUILD_ERROR="FAILED 'make test-dep'"
63         return
64     fi
65     if ! make UNATTENDED=yes CCACHE_DISABLE=1 pkg-verify ; then
66         BUILD_ERROR="FAILED 'make pkg-verify'"
67             return
68     fi
69     if [ "${IS_CSIT_VPP_JOB,,}" == "true" ] ; then
70             # CSIT jobs don't need to run make test
71             return
72     fi
73     if [ -n "${MAKE_PARALLEL_JOBS}" ] ; then
74         TEST_JOBS="${MAKE_PARALLEL_JOBS}"
75         echo "Testing VPP with ${TEST_JOBS} cores."
76     else
77         TEST_JOBS="auto"
78         echo "Testing VPP with automatically calculated number of cores. " \
79              "See test logs for the exact number."
80     fi
81     if grep -q "${OS_ID}-${OS_VERSION_ID}" <<< "${VPPAPIGEN_TEST_OS}"; then
82         if ! src/tools/vppapigen/test_vppapigen.py ; then
83             BUILD_ERROR="FAILED src/tools/vppapigen/test_vppapigen.py"
84             return
85         fi
86     fi
87     if grep -q "${OS_ID}-${OS_VERSION_ID}" <<< "${MAKE_TEST_OS}"; then
88         if ! make COMPRESS_FAILED_TEST_LOGS=yes TEST_JOBS="$TEST_JOBS" CCACHE_DISABLE=1 test-cov ; then
89             BUILD_ERROR="FAILED 'make test-cov'"
90             return
91         fi
92     else
93         echo "Skip running 'make test-cov' on ${OS_ID}-${OS_VERSION_ID}"
94     fi
95 }
96
97 if [ "${DRYRUN,,}" != "true" ] ; then
98     make_test_coverage_report
99 fi
100 if [ -n "$BUILD_ERROR" ] ; then
101     BUILD_RESULT="$BUILD_ERROR"
102     RETVAL="1"
103 fi
104 echo -e "\n$line\n* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^}" \
105         "TEST COVERAGE REPORT $BUILD_RESULT\n$line\n"
106 exit $RETVAL