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 echo "sha1sum of this script: ${0}"
46 if [ -n "${MAKE_PARALLEL_FLAGS}" ] ; then
47 echo "Building VPP. Number of cores for build set with" \
48 "MAKE_PARALLEL_FLAGS='${MAKE_PARALLEL_FLAGS}'."
49 elif [ -n "${MAKE_PARALLEL_JOBS}" ] ; then
50 echo "Building VPP. Number of cores for build set with" \
51 "MAKE_PARALLEL_JOBS='${MAKE_PARALLEL_JOBS}'."
53 echo "Building VPP. Number of cores not set," \
54 "using build default ($(grep -c ^processor /proc/cpuinfo))."
58 if ! make UNATTENDED=yes install-dep ; then
59 BUILD_ERROR="FAILED 'make install-dep'"
62 if ! make UNATTENDED=yes install-ext-deps ; then
63 BUILD_ERROR="FAILED 'make install-ext-deps'"
66 if ! make UNATTENDED=yes test-dep ; then
67 BUILD_ERROR="FAILED 'make test-dep'"
70 if ! make UNATTENDED=yes pkg-verify ; then
71 BUILD_ERROR="FAILED 'make pkg-verify'"
74 if [ "${IS_CSIT_VPP_JOB,,}" == "true" ] ; then
75 # CSIT jobs don't need to run make test
78 if [ -n "${MAKE_PARALLEL_JOBS}" ] ; then
79 TEST_JOBS="${MAKE_PARALLEL_JOBS}"
80 echo "Testing VPP with ${TEST_JOBS} cores."
83 echo "Testing VPP with automatically calculated number of cores. " \
84 "See test logs for the exact number."
86 if [ "${OS_ID}-${OS_VERSION_ID}" == "${VPPAPIGEN_TEST_OS}" ] ; then
87 if ! src/tools/vppapigen/test_vppapigen.py ; then
88 BUILD_ERROR="FAILED src/tools/vppapigen/test_vppapigen.py"
92 if [ "${OS_ID}-${OS_VERSION_ID}" == "${MAKE_TEST_OS}" ] ; then
93 if ! make COMPRESS_FAILED_TEST_LOGS=yes TEST_JOBS="$TEST_JOBS" RETRIES=3 test ; then
94 BUILD_ERROR="FAILED 'make test'"
98 echo "Skip running 'make test' on ${OS_ID}-${OS_VERSION_ID}"
100 if [ "${OS_ID}-${OS_VERSION_ID}" == "${MAKE_TEST_MULTIWORKER_OS}" ] ; then
101 if git grep -q VPP_WORKER_CONFIG ; then
102 if ! make VPP_WORKER_CONFIG="workers 2" COMPRESS_FAILED_TEST_LOGS=yes \
103 RETRIES=3 TEST_JOBS="$TEST_JOBS" test ; then
104 BUILD_ERROR="FAILED 'make test' with VPP_WORKER_CONFIG='workers 2'"
107 echo -e "\n* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^}" \
108 "MULTIWORKER MAKE TEST SUCCESSFULLY COMPLETED\n"
110 elif git grep -q VPP_WORKER_COUNT ; then
111 if ! make VPP_WORKER_COUNT="2" COMPRESS_FAILED_TEST_LOGS=yes \
112 RETRIES=3 TEST_JOBS="$TEST_JOBS" test ; then
113 BUILD_ERROR="FAILED 'make test' with VPP_WORKER_CONFIG='workers 2'"
116 echo -e "\n* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^}" \
117 "MULTIWORKER MAKE TEST SUCCESSFULLY COMPLETED\n"
120 echo "Skip running MULTIWORKER MAKE TEST on ${OS_ID}-${OS_VERSION_ID}"
125 if [ "${DRYRUN,,}" != "true" ] ; then
128 if [ -n "$BUILD_ERROR" ] ; then
129 BUILD_RESULT="$BUILD_ERROR"
132 echo -e "\n$line\n* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^}" \
133 "BUILD $BUILD_RESULT\n$line\n"