fix(vpp/hs-test): fix hst debug job to build/test vpp debug image
[ci-management.git] / jjb / scripts / vpp / api-checkstyle.sh
1 #!/bin/bash
2
3 # Copyright (c) 2020 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:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
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.
15
16 echo "---> jjb/scripts/vpp/api-checkstyle.sh"
17
18 VPP_CRC_CHECKER="extras/scripts/crcchecker.py"
19 VPP_CRC_CHECKER_CMD="$VPP_CRC_CHECKER --check-patchset"
20
21 send_notify() {
22             # 'roomId' field from the response of:
23             # curl https://api.ciscospark.com/v1/memberships  -H "Authorization: Bearer ${SECRET_WEBEX_TEAMS_ACCESS_TOKEN}"
24             WEBEX_TEAMS_ROOM_ID='Y2lzY29zcGFyazovL3VzL1JPT00vMzUzZmI3OTAtYTVjNS0xMWVhLWI4ZjYtMDUxN2I4NzFmOWU5'
25             curl https://api.ciscospark.com/v1/messages -X POST  -H "Authorization: Bearer ${SECRET_WEBEX_TEAMS_ACCESS_TOKEN}" -H "Content-Type: application/json" --data '{"roomId":"'${WEBEX_TEAMS_ROOM_ID}'", "markdown": "'"${WEBEX_TEAMS_MESSAGE}"'" }' || true
26 }
27
28 if [ -f $VPP_CRC_CHECKER ]; then
29     # API checker complains if the git repo is not clean.
30     # Help diagnosing those issues easier
31     git --no-pager diff
32     echo "Running $VPP_CRC_CHECKER_CMD"
33     if $VPP_CRC_CHECKER_CMD; then
34             echo "API check successful"
35     else
36             RET_CODE=$?
37             echo "API check failed: ret code $RET_CODE; please read https://wiki.fd.io/view/VPP/ApiChangeProcess and discuss with ayourtch@gmail.com if unsure how to proceed"
38             WEBEX_TEAMS_MESSAGE="API check FAILED for $GERRIT_REFSPEC -  see $BUILD_URL"
39             send_notify
40             exit $RET_CODE
41     fi
42 else
43     echo "Cannot find $VPP_CRC_CHECKER - skipping API compatibility check"
44 fi