vpp 23.06 post release clean up.
[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) 2023 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)"}
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 make_vpp() {
36     local target=$1
37     local branch=${2:-"master"}
38     local branchname="$(echo $branch | sed -e 's,/,_,')"
39     local bld_log="$DOCKER_BUILD_LOG_DIR"
40     bld_log="${bld_log}/$FDIOTOOLS_IMAGENAME-$branchname"
41     bld_log="${bld_log}-make_vpp_${target}-bld.log"
42
43     makefile_target="^${target}:"
44     if [ -z "$(grep $makefile_target Makefile)" ] ; then
45         echo "Make target '$target' does not exist in VPP branch '$branch'!"
46         return
47     fi
48     git clean -qfdx
49     description="'make UNATTENDED=yes $target' in $(pwd) ($branch)"
50     echo_log -e "    Starting  $description..."
51     make UNATTENDED=yes $target 2>&1 | tee -a "$bld_log"
52     git checkout -q -- .
53     echo_log "    Completed $description!"
54 }
55
56 make_vpp_test() {
57     local target=$1
58     local branch=${2:-"master"}
59     local branchname="$(echo $branch | sed -e 's,/,_,')"
60     local bld_log="$DOCKER_BUILD_LOG_DIR"
61     bld_log="${bld_log}/$FDIOTOOLS_IMAGENAME-$branchname"
62     bld_log="${bld_log}-make_vpp_test_${target}-bld.log"
63
64     makefile_target="^${target}:"
65     if [ -z "$(grep -e $makefile_target test/Makefile)" ] ; then
66         echo "Make test target '$target' does not exist in VPP branch '$branch'!"
67         return
68     fi
69     git clean -qfdx
70     description="'make -C test $target' in $(pwd) ($branch)"
71     echo_log "    Starting  $description..."
72     make WS_ROOT="$DOCKER_VPP_DIR" BR="$DOCKER_VPP_DIR/build-root" \
73          TEST_DIR="$DOCKER_VPP_DIR/test" -C test $target 2>&1 | tee -a $bld_log
74     remove_pyc_files_and_pycache_dirs
75     git checkout -q -- .
76     echo_log "    Completed $description!"
77 }
78
79 docker_build_setup_vpp() {
80     if vpp_supported_executor_class "$EXECUTOR_CLASS" ; then
81         if [ ! -d "$DOCKER_VPP_DIR" ] ; then
82             echo_log "Cloning VPP into $DOCKER_VPP_DIR..."
83             git clone -q https://gerrit.fd.io/r/vpp $DOCKER_VPP_DIR
84         fi
85         clean_git_repo $DOCKER_VPP_DIR
86     fi
87 }
88
89 # Branches must be listed in chronological order -- oldest stable branch
90 # first and master last.
91 #
92 # Note: CI Jobs for each architecture are maintained in
93 #       .../ci-management/jjb/vpp/vpp.yaml
94 #       All OS's and branches are included in the 'os' and 'stream'
95 #       definitions respectively, then the exclude list maintained
96 #       to create an enumerated set of jobs jobs that match the
97 #       definitions here.
98 declare -A VPP_BRANCHES
99 VPP_BRANCHES["debian-11"]="stable/2302 stable/2306 master"
100 VPP_BRANCHES["ubuntu-20.04"]="stable/2302 stable/2306 master"
101 VPP_BRANCHES["ubuntu-22.04"]="stable/2302 stable/2306 master"
102 export VPP_BRANCHES