From 2ed0f24aead401127844660b98622b3160395581 Mon Sep 17 00:00:00 2001 From: Simeon Ehrig Date: Tue, 13 Aug 2024 11:22:33 +0200 Subject: [PATCH] add the possibility to disable exit on error via environment variable in a CI job --- script/gitlabci/print_env.sh | 6 +++++- script/run.sh | 9 ++++++++- script/setup_utilities.sh | 7 ++++++- script/setup_utilities/set.sh | 10 +++++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/script/gitlabci/print_env.sh b/script/gitlabci/print_env.sh index b7d53b7aa564..692ecb522bfb 100755 --- a/script/gitlabci/print_env.sh +++ b/script/gitlabci/print_env.sh @@ -7,7 +7,9 @@ # set exit on error manually instead using setup_utilities because # otherwise the begin of the job log looks not helpful -set -e +if [ -z ${alpaka_DISABLE_EXIT_FAILURE+x} ]; then + set -e +fi # display output with yellow color echo -e "\033[0;33mSteps to setup containter locally" @@ -41,6 +43,8 @@ printenv | grep -E 'alpaka_*|ALPAKA_*|CMAKE_*|BOOST_|CC|CXX|CUDA_' | while read echo "export $line \\" done +# the variable is not set, but should be set if a job is debugged locally in a container +echo 'export alpaka_DISABLE_EXIT_FAILURE=true \' echo 'export GITLAB_CI=true' echo "" diff --git a/script/run.sh b/script/run.sh index a881483e0b58..c84b6c5d779e 100755 --- a/script/run.sh +++ b/script/run.sh @@ -103,7 +103,14 @@ then then set +eu which ${CXX} || source /opt/intel/oneapi/setvars.sh - set -eu + + # exit by default if the command does not return 0 + # can be deactivated by setting the environment variable alpaka_DISABLE_EXIT_FAILURE + # for example for local debugging in a Docker container + if [ -z ${alpaka_DISABLE_EXIT_FAILURE+x} ]; then + set -e + fi + set -u fi which "${CXX}" diff --git a/script/setup_utilities.sh b/script/setup_utilities.sh index 1fb696d88ac5..2276fc854c33 100755 --- a/script/setup_utilities.sh +++ b/script/setup_utilities.sh @@ -7,7 +7,12 @@ # if a bash script is normal called, self defined bash functions are not avaible from the calling bash instance -set -e +# exit by default if the command does not return 0 +# can be deactivated by setting the environment variable alpaka_DISABLE_EXIT_FAILURE +# for example for local debugging in a Docker container +if [ -z ${alpaka_DISABLE_EXIT_FAILURE+x} ]; then + set -e +fi # disable command traces for the following scripts to avoid useless noise in the job output source ./script/setup_utilities/color_echo.sh diff --git a/script/setup_utilities/set.sh b/script/setup_utilities/set.sh index 5719100fee5a..2e738877279d 100755 --- a/script/setup_utilities/set.sh +++ b/script/setup_utilities/set.sh @@ -11,4 +11,12 @@ # -u: treat unset variables as an error # -v: Print shell input lines as they are read # -x: Print command traces before executing command -set -eouvx pipefail + +# exit by default if the command does not return 0 +# can be deactivated by setting the environment variable alpaka_DISABLE_EXIT_FAILURE +# for example for local debugging in a Docker container +if [ -z ${alpaka_DISABLE_EXIT_FAILURE+x} ]; then + set -e +fi + +set -ouvx pipefail