Merge "vpp-hst: add VPP HostStack Test framework jobs"
[ci-management.git] / docker / scripts / lib_vpp.sh
1 # lib_vpp.sh - Docker build script VPP library.
2 #              For import only.
3
4 # Copyright (c) 2024 Cisco and/or its affiliates.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at:
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Don't import more than once.
18 if [ -n "$(alias lib_vpp_imported 2> /dev/null)" ] ; then
19     return 0
20 fi
21 alias lib_vpp_imported=true
22
23 export CIMAN_DOCKER_SCRIPTS=${CIMAN_DOCKER_SCRIPTS:-"$(dirname "${BASH_SOURCE[0]}")"}
24 . "$CIMAN_DOCKER_SCRIPTS"/lib_common.sh
25
26
27 VPP_SUPPORTED_EXECUTOR_CLASSES="builder"
28 vpp_supported_executor_class() {
29     if ! grep -q "${1:-}" <<< $VPP_SUPPORTED_EXECUTOR_CLASSES ; then
30         return 1
31     fi
32     return 0
33 }
34
35 install_hst_deps() {
36     local branch=${1:-"master"}
37     local branchname=${branch/\//_}
38     local hst_dir="./extras/hs-test"
39     local bld_log="$DOCKER_BUILD_LOG_DIR"
40     bld_log="${bld_log}/$FDIOTOOLS_IMAGENAME-$branchname"
41     bld_log="${bld_log}-install_hst_deps_bld.log"
42
43     if [ -d "$hst_dir" ] ; then
44         make -C "$hst_dir" install-deps 2>&1 | tee -a "$bld_log"
45     fi
46 }
47
48 make_vpp() {
49     local target=$1
50     local branch=${2:-"master"}
51     local branchname=${branch/\//_}
52     local bld_log="$DOCKER_BUILD_LOG_DIR"
53     bld_log="${bld_log}/$FDIOTOOLS_IMAGENAME-$branchname"
54     bld_log="${bld_log}-make_vpp_${target}-bld.log"
55
56     makefile_target="^${target}:"
57     if [ -z "$(grep $makefile_target Makefile)" ] ; then
58         echo "Make target '$target' does not exist in VPP branch '$branch'!"
59         return
60     fi
61     git clean -qfdx
62     description="'make UNATTENDED=yes $target' in $(pwd) ($branch)"
63     echo_log -e "    Starting  $description..."
64     make UNATTENDED=yes "$target" 2>&1 | tee -a "$bld_log"
65     git checkout -q -- .
66     echo_log "    Completed $description!"
67 }
68
69 make_vpp_test() {
70     local target=$1
71     local branch=${2:-"master"}
72     local branchname=${branch/\//_}
73     local bld_log="$DOCKER_BUILD_LOG_DIR"
74     bld_log="${bld_log}/$FDIOTOOLS_IMAGENAME-$branchname"
75     bld_log="${bld_log}-make_vpp_test_${target}-bld.log"
76
77     makefile_target="^${target}:"
78     if [ -z "$(grep -e $makefile_target test/Makefile)" ] ; then
79         echo "Make test target '$target' does not exist in VPP branch '$branch'!"
80         return
81     fi
82     git clean -qfdx
83     description="'make -C test $target' in $(pwd) ($branch)"
84     echo_log "    Starting  $description..."
85     make WS_ROOT="$DOCKER_VPP_DIR" BR="$DOCKER_VPP_DIR/build-root" \
86          TEST_DIR="$DOCKER_VPP_DIR/test" -C test $target 2>&1 | tee -a $bld_log
87     remove_pyc_files_and_pycache_dirs
88     git checkout -q -- .
89     echo_log "    Completed $description!"
90 }
91
92 docker_build_setup_vpp() {
93     if vpp_supported_executor_class "$EXECUTOR_CLASS" ; then
94         if [ ! -d "$DOCKER_VPP_DIR" ] ; then
95             echo_log "Cloning VPP into $DOCKER_VPP_DIR..."
96             git clone -q https://gerrit.fd.io/r/vpp $DOCKER_VPP_DIR
97         fi
98         clean_git_repo $DOCKER_VPP_DIR
99     fi
100 }
101
102 # Branches must be listed in chronological order -- oldest stable branch
103 # first and master last.
104 #
105 # Note: CI Jobs for each architecture are maintained in
106 #       .../ci-management/jjb/vpp/vpp.yaml
107 #       All OS's and branches are included in the 'os' and 'stream'
108 #       definitions respectively, then the exclude list maintained
109 #       to create an enumerated set of jobs jobs that match the
110 #       definitions here.
111 declare -A VPP_BRANCHES
112 VPP_BRANCHES["debian-11"]="stable/2310 stable/2402 master"
113 VPP_BRANCHES["ubuntu-20.04"]="stable/2310 stable/2402 master"
114 VPP_BRANCHES["ubuntu-22.04"]="stable/2310 stable/2402 master"
115 export VPP_BRANCHES