Merge "Correction in script for building longbow docs"
[ci-management.git] / jjb / vpp / include-raw-vpp-csit-functional.sh
1 #!/bin/bash
2 set -xeu -o pipefail
3
4 # Get CSIT branch from which to test from
5 # running build-root/scripts/csit-test-branch
6 if [ -x build-root/scripts/csit-test-branch ]; then
7     CSIT_BRANCH=`build-root/scripts/csit-test-branch`;
8 fi
9
10 # check CSIT_BRANCH value
11 if [ "$CSIT_BRANCH" == "" ]; then
12     echo "CSIT_BRANCH not provided => 'latest' will be used"
13     CSIT_BRANCH="latest"
14 fi
15
16 # clone csit
17 git clone --depth 1 --no-single-branch https://gerrit.fd.io/r/csit
18
19 # if the git clone fails, complain clearly and exit
20 if [ $? != 0 ]; then
21     echo "Failed to run: git clone --depth 1 --no-single-branch https://gerrit.fd.io/r/csit"
22     exit 1
23 fi
24
25 cp build-root/*.deb csit/
26 if [ -e dpdk/vpp-dpdk-dkms*.deb ]
27 then
28     cp dpdk/vpp-dpdk-dkms*.deb csit/
29 else
30     cp /var/cache/apt/archives/vpp-dpdk-dkms*.deb csit/
31 fi
32
33 cd csit
34
35 if [ "$CSIT_BRANCH" == "latest" ]; then
36     # set required CSIT branch_id based on VPP master branch; by default use 'oper'
37     case "$VPP_BRANCH" in
38         master )
39             BRANCH_ID="oper"
40             ;;
41         stable/1710 )
42             BRANCH_ID="oper-rls1710"
43             ;;
44         stable/1801 )
45             BRANCH_ID="oper-rls1801"
46             ;;
47         * )
48             BRANCH_ID="oper"
49     esac
50
51     # get the latest verified version of the required branch
52     CSIT_BRANCH=$(echo $(git branch -r | grep -E "${BRANCH_ID}-[0-9]+" | tail -n 1))
53
54     if [ "${CSIT_BRANCH}" == "" ]; then
55         echo "No verified CSIT branch found - exiting"
56         exit 1
57     fi
58
59     # remove 'origin/' from the branch name
60     CSIT_BRANCH=$(echo ${CSIT_BRANCH#origin/})
61 fi
62
63 # checkout the required csit branch
64 git checkout ${CSIT_BRANCH}
65
66 if [ $? != 0 ]; then
67     echo "Failed to checkout the required CSIT branch: ${CSIT_BRANCH}"
68     exit 1
69 fi
70
71 # execute csit bootstrap script if it exists
72 if [ -e bootstrap.sh ]
73 then
74     # make sure that bootstrap.sh is executable
75     chmod +x bootstrap.sh
76     # run the script
77     ./bootstrap.sh *.deb
78 else
79     echo 'ERROR: No bootstrap.sh found'
80     exit 1
81 fi
82
83 # vim: ts=4 ts=4 sts=4 et :