3 # Copyright (c) 2021 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:
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 echo "---> jjb/scripts/vpp/build.sh"
20 line="*************************************************************************"
21 # Don't build anything if this is a merge job being run when
22 # the git HEAD id is not the same as the Gerrit New Revision id.
23 if [[ ${JOB_NAME} == *merge* ]] && [ -n "${GERRIT_NEWREV:-}" ] &&
24 [ "$GERRIT_NEWREV" != "$GIT_COMMIT" ] ; then
25 echo -e "\n$line\nSkipping build. A newer patch has been merged.\n$line\n"
29 OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
30 OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
33 IS_CSIT_VPP_JOB="${IS_CSIT_VPP_JOB:-}"
34 MAKE_PARALLEL_FLAGS="${MAKE_PARALLEL_FLAGS:-}"
35 MAKE_PARALLEL_JOBS="${MAKE_PARALLEL_JOBS:-}"
36 MAKE_TEST_OS="${MAKE_TEST_OS:-ubuntu-22.04}"
37 MAKE_TEST_MULTIWORKER_OS="${MAKE_TEST_MULTIWORKER_OS:-debian-11}"
38 VPPAPIGEN_TEST_OS="${VPPAPIGEN_TEST_OS:-${MAKE_TEST_OS}}"
39 BUILD_RESULT="SUCCESSFULLY COMPLETED"
43 if [ -n "${MAKE_PARALLEL_FLAGS}" ] ; then
44 echo "Building VPP. Number of cores for build set with" \
45 "MAKE_PARALLEL_FLAGS='${MAKE_PARALLEL_FLAGS}'."
46 elif [ -n "${MAKE_PARALLEL_JOBS}" ] ; then
47 echo "Building VPP. Number of cores for build set with" \
48 "MAKE_PARALLEL_JOBS='${MAKE_PARALLEL_JOBS}'."
50 echo "Building VPP. Number of cores not set," \
51 "using build default ($(grep -c ^processor /proc/cpuinfo))."
55 if ! make UNATTENDED=yes install-dep ; then
56 BUILD_ERROR="FAILED 'make install-dep'"
59 if ! make UNATTENDED=yes install-ext-deps ; then
60 BUILD_ERROR="FAILED 'make install-ext-deps'"
63 if ! make UNATTENDED=yes test-dep ; then
64 BUILD_ERROR="FAILED 'make test-dep'"
67 if ! make UNATTENDED=yes pkg-verify ; then
68 BUILD_ERROR="FAILED 'make pkg-verify'"
71 if [ "${IS_CSIT_VPP_JOB,,}" == "true" ] ; then
72 # CSIT jobs don't need to run make test
75 if [ -n "${MAKE_PARALLEL_JOBS}" ] ; then
76 TEST_JOBS="${MAKE_PARALLEL_JOBS}"
77 echo "Testing VPP with ${TEST_JOBS} cores."
80 echo "Testing VPP with automatically calculated number of cores. " \
81 "See test logs for the exact number."
83 if [ "${OS_ID}-${OS_VERSION_ID}" == "${VPPAPIGEN_TEST_OS}" ] ; then
84 if ! src/tools/vppapigen/test_vppapigen.py ; then
85 BUILD_ERROR="FAILED src/tools/vppapigen/test_vppapigen.py"
89 if [ "${OS_ID}-${OS_VERSION_ID}" == "${MAKE_TEST_OS}" ] ; then
90 if ! make COMPRESS_FAILED_TEST_LOGS=yes TEST_JOBS="$TEST_JOBS" RETRIES=3 test ; then
91 BUILD_ERROR="FAILED 'make test'"
95 echo "Skip running 'make test' on ${OS_ID}-${OS_VERSION_ID}"
97 if [ "${OS_ID}-${OS_VERSION_ID}" == "${MAKE_TEST_MULTIWORKER_OS}" ] ; then
98 if git grep -q VPP_WORKER_CONFIG ; then
99 if ! make VPP_WORKER_CONFIG="workers 2" COMPRESS_FAILED_TEST_LOGS=yes \
100 RETRIES=3 TEST_JOBS="$TEST_JOBS" test ; then
101 BUILD_ERROR="FAILED 'make test' with VPP_WORKER_CONFIG='workers 2'"
104 echo -e "\n* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^}" \
105 "MULTIWORKER MAKE TEST SUCCESSFULLY COMPLETED\n"
107 elif git grep -q VPP_WORKER_COUNT ; then
108 if ! make VPP_WORKER_COUNT="2" COMPRESS_FAILED_TEST_LOGS=yes \
109 RETRIES=3 TEST_JOBS="$TEST_JOBS" test ; then
110 BUILD_ERROR="FAILED 'make test' with VPP_WORKER_CONFIG='workers 2'"
113 echo -e "\n* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^}" \
114 "MULTIWORKER MAKE TEST SUCCESSFULLY COMPLETED\n"
117 echo "Skip running MULTIWORKER MAKE TEST on ${OS_ID}-${OS_VERSION_ID}"
122 if [ "${DRYRUN,,}" != "true" ] ; then
125 if [ -n "$BUILD_ERROR" ] ; then
126 BUILD_RESULT="$BUILD_ERROR"
129 echo -e "\n$line\n* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^}" \
130 "BUILD $BUILD_RESULT\n$line\n"