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 [ -f extras/scripts/build_static_vppctl.sh ]; then
64 if ! extras/scripts/build_static_vppctl.sh ; then
65 BUILD_ERROR="FAILED 'extras/scripts/build_static_vppctl.sh'"
68 if ! make UNATTENDED=yes test-dep ; then
69 BUILD_ERROR="FAILED 'make test-dep'"
72 if ! make UNATTENDED=yes pkg-verify ; then
73 BUILD_ERROR="FAILED 'make pkg-verify'"
76 if [ "${IS_CSIT_VPP_JOB,,}" == "true" ] ; then
77 # CSIT jobs don't need to run make test
80 if [ -n "${MAKE_PARALLEL_JOBS}" ] ; then
81 TEST_JOBS="${MAKE_PARALLEL_JOBS}"
82 echo "Testing VPP with ${TEST_JOBS} cores."
85 echo "Testing VPP with automatically calculated number of cores. " \
86 "See test logs for the exact number."
88 if grep -q "${OS_ID}-${OS_VERSION_ID}" <<< "${VPPAPIGEN_TEST_OS}"; then
89 if ! src/tools/vppapigen/test_vppapigen.py ; then
90 BUILD_ERROR="FAILED src/tools/vppapigen/test_vppapigen.py"
94 if grep -q "${OS_ID}-${OS_VERSION_ID}" <<< "${MAKE_TEST_OS}"; then
95 if ! make COMPRESS_FAILED_TEST_LOGS=yes TEST_JOBS="$TEST_JOBS" RETRIES=3 test ; then
96 BUILD_ERROR="FAILED 'make test'"
100 echo "Skip running 'make test' on ${OS_ID}-${OS_VERSION_ID}"
102 if grep -q "${OS_ID}-${OS_VERSION_ID}" <<< "${MAKE_TEST_MULTIWORKER_OS}"; then
103 if git grep -q VPP_WORKER_CONFIG ; then
104 if ! make VPP_WORKER_CONFIG="workers 2" COMPRESS_FAILED_TEST_LOGS=yes \
105 RETRIES=3 TEST_JOBS="$TEST_JOBS" test ; then
106 BUILD_ERROR="FAILED 'make test' with VPP_WORKER_CONFIG='workers 2'"
109 echo -e "\n* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^}" \
110 "MULTIWORKER MAKE TEST SUCCESSFULLY COMPLETED\n"
112 elif git grep -q VPP_WORKER_COUNT ; then
113 if ! make VPP_WORKER_COUNT="2" COMPRESS_FAILED_TEST_LOGS=yes \
114 RETRIES=3 TEST_JOBS="$TEST_JOBS" test ; then
115 BUILD_ERROR="FAILED 'make test' with VPP_WORKER_CONFIG='workers 2'"
118 echo -e "\n* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^}" \
119 "MULTIWORKER MAKE TEST SUCCESSFULLY COMPLETED\n"
122 echo "Skip running MULTIWORKER MAKE TEST on ${OS_ID}-${OS_VERSION_ID}"
125 echo "Skip running MULTIWORKER MAKE TEST on ${OS_ID}-${OS_VERSION_ID}"
129 if [ "${DRYRUN,,}" != "true" ] ; then
132 if [ -n "$BUILD_ERROR" ] ; then
133 BUILD_RESULT="$BUILD_ERROR"
136 echo -e "\n$line\n* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^}" \
137 "BUILD $BUILD_RESULT\n$line\n"