Skip VPP build for merge jobs with Gerrit ID != git HEAD. 26/30926/6
authorDave Wallace <[email protected]>
Tue, 26 Jan 2021 02:41:14 +0000 (21:41 -0500)
committerDave Wallace <[email protected]>
Wed, 27 Jan 2021 02:12:31 +0000 (21:12 -0500)
- Since merge jobs are serialized after the patches have
  been merged into git, all merge jobs which do not have
  the same Gerrit ID as git HEAD are redundant.  Skip
  them to save useless cycles and to reduce the size of
  the build queues when multiple patches are merged in a
  short amount of time.

- This also fixes the issue with packagecloud packages
  containing different contents then the associated
  Gerrit ID when built & pushed in this state.

Change-Id: I822492bd1d523576373bb268258c181a9c5edb42
Signed-off-by: Dave Wallace <[email protected]>
jjb/scripts/packagecloud_push.sh
jjb/scripts/vpp/build.sh
jjb/scripts/vpp/docs.sh
jjb/scripts/vpp/make-test-docs.sh
jjb/scripts/vpp/sphinx-docs.sh

index af3bf48..a4ae9b1 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# Copyright (c) 2020 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
@@ -17,6 +17,22 @@ echo "---> jjb/scripts/packagecloud_push.sh"
 
 set -euxo pipefail
 
+line="*************************************************************************"
+
+# Nothing was built if this is a merge job being run when
+# the git HEAD id is not the same as the Gerrit New Revision ID
+if [[ ${JOB_NAME} == *merge* ]] && [ -n "${GERRIT_NEWREV:-}" ] &&
+       [ "$GERRIT_NEWREV" != "$GIT_COMMIT" ] ; then
+    echo -e "\n$line\nSkipping package push. A newer patch has been merged.\n$line\n"
+    exit 0
+fi
+
+DRYRUN="${DRYRUN:-}"
+if [ "${DRYRUN,,}" = "true" ] ; then
+    echo -e "\n$line\nSkipping package push because DRYRUN is '${DRYRUN,,}'.\n$line\n"
+    exit 0
+fi
+
 echo "STARTING PACKAGECLOUD PUSH"
 
 sleep 10
@@ -58,8 +74,7 @@ if [ -f ~/.packagecloud ]; then
             fi
             ;;
         *)
-            echo "ERROR: Unsupported OS '$FACTER_OS'"
-            echo "PACKAGECLOUD PUSH FAILED!"
+            echo -e "\n$line\n* ERROR: Unsupported OS '$FACTER_OS'\n* PACKAGECLOUD PUSH FAILED!\n$line\n"
             exit 1
             ;;
     esac
@@ -83,4 +98,4 @@ else
     exit 1
 fi
 
-echo "PACKAGECLOUD PUSH COMPLETE"
+echo -e "\n$line\n* PACKAGECLOUD PUSH COMPLETE\n$line\n"
index 52cee09..148999c 100644 (file)
@@ -1,7 +1,6 @@
 #!/bin/bash
-# basic build script example
 
-# Copyright (c) 2020 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
 
 echo "---> jjb/scripts/vpp/build.sh"
 
-set -xe -o pipefail
+set -euxo pipefail
+
+line="*************************************************************************"
+# Don't build anything if this is a merge job being run when
+# the git HEAD id is not the same as the Gerrit New Revision id.
+if [[ ${JOB_NAME} == *merge* ]] && [ -n "${GERRIT_NEWREV:-}" ] &&
+       [ "$GERRIT_NEWREV" != "$GIT_COMMIT" ] ; then
+    echo -e "\n$line\nSkipping build. A newer patch has been merged.\n$line\n"
+    exit 0
+fi
 
 OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
 OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
 OS_ARCH=$(uname -m)
+DRYRUN="${DRYRUN:-}"
+IS_CSIT_VPP_JOB="${IS_CSIT_VPP_JOB:-}"
+MAKE_PARALLEL_FLAGS="${MAKE_PARALLEL_FLAGS:-}"
+MAKE_PARALLEL_JOBS="${MAKE_PARALLEL_JOBS:-}"
 
 echo "sha1sum of this script: ${0}"
 sha1sum $0
@@ -35,11 +47,11 @@ sha1sum $0
 #    echo $CCACHE_DIR does not exist.
 #fi
 
-if [ "x${MAKE_PARALLEL_FLAGS}" != "x" ]
+if [ -n "${MAKE_PARALLEL_FLAGS}" ]
 then
   echo "Building VPP. Number of cores for build set with" \
        "MAKE_PARALLEL_FLAGS='${MAKE_PARALLEL_FLAGS}'."
-elif [ "x${MAKE_PARALLEL_JOBS}" != "x" ]
+elif [ -n "${MAKE_PARALLEL_JOBS}" ]
 then
   echo "Building VPP. Number of cores for build set with" \
        "MAKE_PARALLEL_JOBS='${MAKE_PARALLEL_JOBS}'."
@@ -48,14 +60,11 @@ else
        "using build default ($(grep -c ^processor /proc/cpuinfo))."
 fi
 
-echo "CC=${CC}"
-echo "IS_CSIT_VPP_JOB=${IS_CSIT_VPP_JOB}"
-
 # If we are not a CSIT job just building packages, then use make verify,
 # else use make pkg-verify.
-if [ "x${IS_CSIT_VPP_JOB}" != "xTrue" ]
+if [ "${IS_CSIT_VPP_JOB,,}" != "true" ]
 then
-    if [ "x${MAKE_PARALLEL_JOBS}" != "x" ]
+    if [ -n "${MAKE_PARALLEL_JOBS}" ]
     then
         export TEST_JOBS="${MAKE_PARALLEL_JOBS}"
         echo "Testing VPP with ${TEST_JOBS} cores."
@@ -65,12 +74,10 @@ then
              "See test logs for the exact number."
     fi
     echo "Building using \"make verify\""
-    [ "x${DRYRUN}" == "xTrue" ] || make UNATTENDED=yes verify
+    [ "${DRYRUN,,}" = "true" ] || make UNATTENDED=yes verify
 else
     echo "Building using \"make pkg-verify\""
-    [ "x${DRYRUN}" == "xTrue" ] || make UNATTENDED=yes pkg-verify
+    [ "${DRYRUN,,}" = "true" ] || make UNATTENDED=yes pkg-verify
 fi
 
-echo "*******************************************************************"
-echo "* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^} BUILD SUCCESSFULLY COMPLETED"
-echo "*******************************************************************"
+echo -e "\n$line\n* VPP ${OS_ID^^}-${OS_VERSION_ID}-${OS_ARCH^^} BUILD SUCCESSFULLY COMPLETED\n$line\n"
index 0899b66..866b322 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# Copyright (c) 2020 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
 
 echo "---> jjb/scripts/vpp/docs.sh"
 
-set -xe -o pipefail
-[ "$DOCS_REPO_URL" ] || DOCS_REPO_URL="https://nexus.fd.io/content/sites/site"
-[ "$PROJECT_PATH" ] || PROJECT_PATH=io/fd/vpp
-[ "$DOC_FILE" ] || DOC_FILE=vpp.docs.zip
-[ "$DOC_DIR" ] || DOC_DIR=build-root/docs/html
-[ "$SITE_DIR" ] || SITE_DIR=build-root/docs/deploy-site/
-[ "$RESOURCES_DIR" ] || RESOURCES_DIR=${SITE_DIR}/src/site/resources
-[ "$MVN" ] || MVN="/opt/apache/maven/bin/mvn"
-[ "$VERSION" ] || VERSION=$(./build-root/scripts/version rpm-version)
+set -euxo pipefail
+
+line="*************************************************************************"
+# Don't build anything if this is a merge job being run when
+# the git HEAD id is not the same as the Gerrit New Revision id.
+if [[ ${JOB_NAME} == *merge* ]] && [ -n "${GERRIT_NEWREV:-}" ] &&
+       [ "$GERRIT_NEWREV" != "$GIT_COMMIT" ] ; then
+    echo -e "\n$line\nSkipping doxygen docs build. A newer patch has been merged.\n$line\n"
+    exit 0
+fi
+    
+DOCS_REPO_URL=${DOCS_REPO_URL:-"https://nexus.fd.io/content/sites/site"}
+PROJECT_PATH=${PROJECT_PATH:-"io/fd/vpp"}
+DOC_FILE=${DOC_FILE:-"vpp.docs.zip"}
+DOC_DIR=${DOC_DIR:-"build-root/docs/html"}
+SITE_DIR=${SITE_DIR:-"build-root/docs/deploy-site"}
+RESOURCES_DIR=${RESOURCES_DIR:-"${SITE_DIR}/src/site/resources"}
+MVN=${MVN:-"/opt/apache/maven/bin/mvn"}
+VERSION=${VERSION:-"$(./build-root/scripts/version rpm-version)"}
 
 make doxygen
 
-if [[ ${JOB_NAME} == *merge* ]]; then
+if [[ ${JOB_NAME} == *merge* ]] ; then
   mkdir -p $(dirname ${RESOURCES_DIR})
   mv -f ${DOC_DIR} ${RESOURCES_DIR}
   cd ${SITE_DIR}
index d15cac3..d20a7b8 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# Copyright (c) 2020 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
 
 echo "---> jjb/scripts/vpp/make-test-docs.sh"
 
-set -xe -o pipefail
-[ "$DOCS_REPO_URL" ] || DOCS_REPO_URL="https://nexus.fd.io/content/sites/site"
-[ "$PROJECT_PATH" ] || PROJECT_PATH=io/fd/vpp
-[ "$DOC_DIR" ] || DOC_DIR=build-root/build-test/doc/html
-[ "$SITE_DIR" ] || SITE_DIR=build-root/docs/deploy-site
-[ "$RESOURCES_DIR" ] || RESOURCES_DIR=${SITE_DIR}/src/site/resources/vpp_make_test
-[ "$MVN" ] || MVN="/opt/apache/maven/bin/mvn"
-[ "$VERSION" ] || VERSION=$(./build-root/scripts/version rpm-version)
+set -euxo pipefail
+
+line="*************************************************************************"
+# Don't build anything if this is a merge job being run when
+# the git HEAD id is not the same as the Gerrit New Revision id.
+if [[ ${JOB_NAME} == *merge* ]] && [ -n "${GERRIT_NEWREV:-}" ] &&
+       [ "$GERRIT_NEWREV" != "$GIT_COMMIT" ] ; then
+    echo -e "\n$line\nSkipping 'make test' doxygen docs build. A newer patch has been merged.\n$line\n"
+    exit 0
+fi
+
+DOCS_REPO_URL=${DOCS_REPO_URL:-"https://nexus.fd.io/content/sites/site"}
+PROJECT_PATH=${PROJECT_PATH:-"io/fd/vpp"}
+DOC_DIR=${DOC_DIR:-"build-root/build-test/doc/html"}
+SITE_DIR=${SITE_DIR:-"build-root/docs/deploy-site"}
+RESOURCES_DIR=${RESOURCES_DIR:-"${SITE_DIR}/src/site/resources/vpp_make_test"}
+MVN=${MVN:-"/opt/apache/maven/bin/mvn"}
+VERSION=${VERSION:-"$(./build-root/scripts/version rpm-version)"}
 
 make test-doc
 
index b9eb64b..d80b4cd 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# Copyright (c) 2020 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
 
 echo "---> jjb/scripts/vpp/sphinx-docs.sh"
 
-set -xe -o pipefail
-[ "$DOCS_REPO_URL" ] || DOCS_REPO_URL="https://nexus.fd.io/content/sites/site"
-[ "$PROJECT_PATH" ] || PROJECT_PATH=io/fd/vpp
-[ "$DOC_FILE" ] || DOC_FILE=vpp.docs.zip
-[ "$DOC_DIR" ] || DOC_DIR=./docs/_build/html
-[ "$SITE_DIR" ] || SITE_DIR=build-root/docs/deploy-site
-[ "$RESOURCES_DIR" ] || RESOURCES_DIR=${SITE_DIR}/src/site/resources
-[ "$MVN" ] || MVN="/opt/apache/maven/bin/mvn"
-[ "$VERSION" ] || VERSION=$(./build-root/scripts/version rpm-version)
+set -euxo pipefail
+
+line="*************************************************************************"
+# Don't build anything if this is a merge job being run when
+# the git HEAD id is not the same as the Gerrit New Revision id.
+if [[ ${JOB_NAME} == *merge* ]] && [ -n "${GERRIT_NEWREV:-}" ] &&
+       [ "$GERRIT_NEWREV" != "$GIT_COMMIT" ] ; then
+    echo -e "\n$line\nSkipping sphinx docs build. A newer patch has been merged.\n$line\n"
+    exit 0
+fi
+
+DOCS_REPO_URL=${DOCS_REPO_URL:-"https://nexus.fd.io/content/sites/site"}
+PROJECT_PATH=${PROJECT_PATH:-"io/fd/vpp"}
+DOC_FILE=${DOC_FILE:-"vpp.docs.zip"}
+DOC_DIR=${DOC_DIR:-"./docs/_build/html"}
+SITE_DIR=${SITE_DIR:-"build-root/docs/deploy-site"}
+RESOURCES_DIR=${RESOURCES_DIR:-"${SITE_DIR}/src/site/resources"}
+MVN=${MVN:-"/opt/apache/maven/bin/mvn"}
+VERSION=${VERSION:-"$(./build-root/scripts/version rpm-version)"}
 
 make docs-venv
 CONFIRM=-y FORCE=--force-yes make docs