From fa93b070b2ee5a25142bdfacee8ef0ba27dd34df Mon Sep 17 00:00:00 2001 From: Hugo Buddelmeijer Date: Mon, 8 Jan 2024 10:34:43 +0100 Subject: [PATCH] Allow runnotebooks.sh to run without arguments Better follow https://betterdev.blog/minimal-safe-bash-script-template/ --- runnotebooks.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/runnotebooks.sh b/runnotebooks.sh index 3362a8ae..01d17dfd 100755 --- a/runnotebooks.sh +++ b/runnotebooks.sh @@ -6,9 +6,61 @@ set -Eeuo pipefail # Set stdout as default so the script can be ran on the commandline. STEP_SUMMARY="${GITHUB_STEP_SUMMARY:-/dev/stdout}" +usage() { + cat <&2 -e "${1-}" +} + +die() { + local msg=$1 + local code=${2-1} # default exit status 1 + msg "$msg" + exit "$code" +} + +parse_params "$@" + echo "# Running Notebooks Tests" >> $STEP_SUMMARY -if [[ "x${1}" == "x--clone-irdb" ]] ; then +if [[ "${CLONEIRDB}" == 1 ]] ; then # Cloning IRDB if [[ ! -e inst_pkgs ]] ; then echo "_Cloning IRDB_" >> $STEP_SUMMARY @@ -48,7 +100,7 @@ do # By default do not delete any files. # The delete functionality is intended to make it easy for developers to test # all the notebooks on their own machine. - if [ "x$1" = "x--delete" ] + if [ "${DELETE}" = 1 ] then echo "Removing ${fnpy}" rm "${fnpy}"