From 136d2f165ed40ec1822042f09d3449f1857480bc Mon Sep 17 00:00:00 2001 From: Christian Gumpert <christian.gumpert@cern.ch> Date: Fri, 10 Mar 2017 15:03:18 +0100 Subject: [PATCH] propagate number of shell execution errors Even if we do not to fail immediately on errors when building Gaudi or ATLAS externals, it is still important for the CI system to know whether some errors occured. By not failing on error but reporting the total number of errors, the calling scripts can decide how to deal with this in specific situations (e.g. CI build vs nightly). --- Build/AtlasBuildScripts/build_Gaudi.sh | 28 +++++++++++-------- .../AtlasBuildScripts/build_atlasexternals.sh | 26 ++++++++++------- Projects/Athena/build.sh | 5 ++-- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/Build/AtlasBuildScripts/build_Gaudi.sh b/Build/AtlasBuildScripts/build_Gaudi.sh index b07758d86280..5138e9acea22 100755 --- a/Build/AtlasBuildScripts/build_Gaudi.sh +++ b/Build/AtlasBuildScripts/build_Gaudi.sh @@ -3,8 +3,12 @@ # Script used for building Gaudi. # -# Don't stop on errors: +# Don't stop on errors but count them set +e +ERROR_COUNT=0 + +# consider a pipe failed if ANY of the commands fails +set -o pipefail # Function printing the usage information for the script usage() { @@ -75,30 +79,32 @@ if [ "$SOURCEDIR" = "" ] || [ "$BUILDDIR" = "" ] || [ "$INSTALLDIR" = "" ] \ fi # Create the build directory if it doesn't exist, and move to it: -mkdir -p ${BUILDDIR} -cd ${BUILDDIR} +mkdir -p ${BUILDDIR} || ((ERROR_COUNT++)) +cd ${BUILDDIR} || ((ERROR_COUNT++)) # Set up the externals project: -source ${EXTDIR}/setup.sh +source ${EXTDIR}/setup.sh || ((ERROR_COUNT++)) # Configure the build: cmake -DCMAKE_BUILD_TYPE:STRING=${BUILDTYPE} -DCTEST_USE_LAUNCHERS:BOOL=TRUE \ -DGAUDI_ATLAS:BOOL=TRUE -DGAUDI_ATLAS_BASE_PROJECT:STRING=${EXTPROJECT} \ -DCMAKE_INSTALL_PREFIX:PATH=/InstallArea/${PLATFORM} \ - ${SOURCEDIR} 2>&1 | tee cmake_config.log + ${SOURCEDIR} 2>&1 | tee cmake_config.log || ((ERROR_COUNT++)) # Build it: -make -k +make -k || ((ERROR_COUNT++)) # Install it: -make -k install/fast DESTDIR=${INSTALLDIR} +make -k install/fast DESTDIR=${INSTALLDIR} || ((ERROR_COUNT++)) # If no RPM directory was specified, stop here: if [ "$RPMDIR" = "" ]; then - exit 0 + exit ${ERROR_COUNT} fi # Build the RPM for the project: -cpack -mkdir -p ${RPMDIR} -cp GAUDI*.rpm ${RPMDIR} +cpack || ((ERROR_COUNT++)) +mkdir -p ${RPMDIR} || ((ERROR_COUNT++)) +cp GAUDI*.rpm ${RPMDIR} || ((ERROR_COUNT++)) + +exit ${ERROR_COUNT} diff --git a/Build/AtlasBuildScripts/build_atlasexternals.sh b/Build/AtlasBuildScripts/build_atlasexternals.sh index ca17939ba81c..3848ef0025fe 100755 --- a/Build/AtlasBuildScripts/build_atlasexternals.sh +++ b/Build/AtlasBuildScripts/build_atlasexternals.sh @@ -4,8 +4,12 @@ # repository. # -# Don't stop on errors: +# Don't stop on errors but count them set +e +ERROR_COUNT=0 + +# consider a pipe failed if ANY of the commands fails +set -o pipefail # Function printing the usage information for the script usage() { @@ -65,8 +69,8 @@ if [ "$SOURCEDIR" = "" ] || [ "$BUILDDIR" = "" ] || [ "$INSTALLDIR" = "" ]; then fi # Create the build directory if it doesn't exist, and move to it: -mkdir -p ${BUILDDIR} -cd ${BUILDDIR} +mkdir -p ${BUILDDIR} || ((ERROR_COUNT++)) +cd ${BUILDDIR} || ((ERROR_COUNT++)) # Extra settings for providing a project version for the build if necessary: EXTRACONF= @@ -78,21 +82,23 @@ fi # Configure the build: cmake -DCMAKE_BUILD_TYPE:STRING=${BUILDTYPE} -DCTEST_USE_LAUNCHERS:BOOL=TRUE \ ${EXTRACONF} \ - ${SOURCEDIR}/Projects/${PROJECT}/ 2>&1 | tee cmake_config.log + ${SOURCEDIR}/Projects/${PROJECT}/ 2>&1 | tee cmake_config.log || ((ERROR_COUNT++)) # Build it: -make -k +make -k || ((ERROR_COUNT++)) # Install it: -make -k install/fast DESTDIR=${INSTALLDIR} +make -k install/fast DESTDIR=${INSTALLDIR} || ((ERROR_COUNT++)) # If no RPM directory was specified, stop here: if [ "$RPMDIR" = "" ]; then - exit 0 + exit ${ERROR_COUNT} fi # Build the RPM or other package for the project: -cpack -mkdir -p ${RPMDIR} +cpack || ((ERROR_COUNT++)) +mkdir -p ${RPMDIR} || ((ERROR_COUNT++)) FILES=$(ls ${PROJECT}*.rpm ${PROJECT}*.tar.gz ${PROJECT}*.dmg) -cp ${FILES} ${RPMDIR} +cp ${FILES} ${RPMDIR} || ((ERROR_COUNT++)) + +exit ${ERROR_COUNT} diff --git a/Projects/Athena/build.sh b/Projects/Athena/build.sh index e2e3790b322d..3ff8eda92cd4 100755 --- a/Projects/Athena/build.sh +++ b/Projects/Athena/build.sh @@ -75,6 +75,8 @@ fi # Stop on errors from here on out: set -e +# consider a pipe failed if ANY of the commands fails +set -o pipefail # Source in our environment AthenaSrcDir=$(dirname ${BASH_SOURCE[0]}) @@ -89,9 +91,6 @@ source $AthenaSrcDir/build_env.sh -b $BUILDDIR mkdir -p ${BUILDDIR}/build/Athena cd ${BUILDDIR}/build/Athena -# consider a pipe failed if ANY of the commands fails -set -o pipefail - # CMake: if [ -n "$EXE_CMAKE" ]; then # Remove the CMakeCache.txt file, to force CMake to find externals -- GitLab