Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow runnotebooks.sh to run without arguments #330

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 54 additions & 2 deletions runnotebooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [--clone-irdb] [--delete]

Test whether all the notebooks run.

Available options:

-h, --help Print this help and exit
-v, --verbose Print script debug info
--clone-irdb Clone the IRDB instead of downloading it
--delete Delete generated files
EOF
exit
}

parse_params() {
# default values of variables set from params
DELETE=0
CLONEIRDB=0

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
--clone-irdb) CLONEIRDB=1 ;;
--delete) DELETE=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

args=("$@")

return 0
}

msg() {
echo >&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
Expand Down Expand Up @@ -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}"
Expand Down