@@ -4,9 +4,10 @@ SELF ::= $(firstword $(MAKEFILE_LIST))
44
55# https://tech.davis-hansson.com/p/make/
66SHELL := bash
7- # todo: do not set .ONESHELL: for now
7+ .ONESHELL :
88# http://redsymbol.net/articles/unofficial-bash-strict-mode/
9- # .SHELLFLAGS := -eu -o pipefail -c
9+ # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
10+ .SHELLFLAGS := -Eeux -o pipefail -c
1011.DELETE_ON_ERROR :
1112MAKEFLAGS += --warn-undefined-variables
1213MAKEFLAGS += --no-builtin-rules
@@ -493,13 +494,11 @@ undeploy-c9s-%: bin/kubectl
493494define test_with_papermill
494495 $(eval PREFIX_NAME := $(subst /,-,$(1 ) _$(2 ) ) ) \
495496 $(KUBECTL_BIN ) exec $(FULL_NOTEBOOK_NAME ) -- /bin/sh -c "python3 -m pip install papermill" ; \
496- $(KUBECTL_BIN ) exec $(FULL_NOTEBOOK_NAME ) -- /bin/sh -c "wget ${NOTEBOOK_REPO_BRANCH_BASE}/jupyter/$(1 ) /$(2 ) -$(3 ) /test/test_notebook.ipynb -O test_notebook.ipynb && python3 -m papermill test_notebook.ipynb $(PREFIX_NAME ) _output.ipynb --kernel python3 --stderr-file $(PREFIX_NAME ) _error.txt" ; \
497- if [ $$? -ne 0 ]; then \
497+ if ! $(KUBECTL_BIN ) exec $(FULL_NOTEBOOK_NAME ) -- /bin/sh -c "wget ${NOTEBOOK_REPO_BRANCH_BASE}/jupyter/$(1 ) /$(2 ) -$(3 ) /test/test_notebook.ipynb -O test_notebook.ipynb && python3 -m papermill test_notebook.ipynb $(PREFIX_NAME ) _output.ipynb --kernel python3 --stderr-file $(PREFIX_NAME ) _error.txt" ; then \
498498 echo "ERROR: The $(1 ) $(2 ) notebook encountered a failure. To investigate the issue, you can review the logs located in the ocp-ci cluster on 'artifacts/notebooks-e2e-tests/jupyter-$(1 ) -$(2 ) -$(3 ) -test-e2e' directory or run 'cat $(PREFIX_NAME ) _error.txt' within your container. The make process has been aborted." ; \
499499 exit 1 ; \
500500 fi ; \
501- $(KUBECTL_BIN ) exec $(FULL_NOTEBOOK_NAME ) -- /bin/sh -c "cat $(PREFIX_NAME ) _error.txt | grep --quiet FAILED" ; \
502- if [ $$? -eq 0 ]; then \
501+ if $(KUBECTL_BIN ) exec $(FULL_NOTEBOOK_NAME ) -- /bin/sh -c "cat $(PREFIX_NAME ) _error.txt | grep --quiet FAILED" ; then \
503502 echo "ERROR: The $(1 ) $(2 ) notebook encountered a failure. The make process has been aborted." ; \
504503 $(KUBECTL_BIN ) exec $(FULL_NOTEBOOK_NAME ) -- /bin/sh -c "cat $(PREFIX_NAME ) _error.txt" ; \
505504 exit 1 ; \
@@ -562,19 +561,17 @@ validate-runtime-image: bin/kubectl
562561 fi ; \
563562 for cmd in $$ required_commands ; do \
564563 echo " => Checking container image $$ image for $$ cmd..." ; \
565- $(KUBECTL_BIN ) exec runtime-pod which $$ cmd > /dev/null 2>&1 ; \
566- if [ $$ ? -ne 0 ]; then \
564+ if ! $( KUBECTL_BIN) exec runtime-pod which $$ cmd > /dev/null 2>&1 ; then \
567565 echo " ERROR: Container image $$ image does not meet criteria for command: $$ cmd" ; \
568566 fail=1; \
569567 continue ; \
570568 fi ; \
571569 if [ $$ cmd == " python3" ]; then \
572570 echo " => Checking notebook execution..." ; \
573- $(KUBECTL_BIN ) exec runtime-pod -- /bin/sh -c " curl https://raw.githubusercontent.com/opendatahub-io/elyra/refs/heads/main/etc/generic/requirements-elyra.txt --output req.txt && \
574- python3 -m pip install -r req.txt > /dev/null && \
575- curl https://raw.githubusercontent.com/nteract/papermill/main/papermill/tests/notebooks/simple_execute.ipynb --output simple_execute.ipynb && \
576- python3 -m papermill simple_execute.ipynb output.ipynb > /dev/null" ; \
577- if [ $$ ? -ne 0 ]; then \
571+ if ! $( KUBECTL_BIN) exec runtime-pod -- /bin/sh -c " curl https://raw.githubusercontent.com/opendatahub-io/elyra/refs/heads/main/etc/generic/requirements-elyra.txt --output req.txt && \
572+ python3 -m pip install -r req.txt > /dev/null && \
573+ curl https://raw.githubusercontent.com/nteract/papermill/main/papermill/tests/notebooks/simple_execute.ipynb --output simple_execute.ipynb && \
574+ python3 -m papermill simple_execute.ipynb output.ipynb > /dev/null" ; then \
578575 echo " ERROR: Image does not meet Python requirements criteria in pipfile" ; \
579576 fail=1; \
580577 fi ; \
@@ -599,8 +596,7 @@ validate-codeserver-image: bin/kubectl
599596 fi ; \
600597 for cmd in $$ required_commands ; do \
601598 echo " => Checking container image $$ image for $$ cmd..." ; \
602- $(KUBECTL_BIN ) exec codeserver-pod which $$ cmd > /dev/null 2>&1 ; \
603- if [ $$ ? -ne 0 ]; then \
599+ if ! $( KUBECTL_BIN) exec codeserver-pod which $$ cmd > /dev/null 2>&1 ; then \
604600 echo " ERROR: Container image $$ image does not meet criteria for command: $$ cmd" ; \
605601 fail=1; \
606602 continue ; \
@@ -618,19 +614,17 @@ validate-rstudio-image: bin/kubectl
618614 echo " Usage: make validate-rstudio-image image=<container-image-name>" ; \
619615 exit 1 ; \
620616 fi ; \
621- echo " => Checking container image $$ image for package intallation ..." ; \
617+ echo " => Checking container image $$ image for package installation ..." ; \
622618 $(KUBECTL_BIN ) exec -it rstudio-pod -- mkdir -p /opt/app-root/src/R/temp-library > /dev/null 2>&1 ; \
623- $(KUBECTL_BIN ) exec rstudio-pod -- R -e " install.packages('tinytex', lib='/opt/app-root/src/R/temp-library')" > /dev/null 2>&1 ; \
624- if [ $$ ? -eq 0 ]; then \
619+ if $( KUBECTL_BIN) exec rstudio-pod -- R -e " install.packages('tinytex', lib='/opt/app-root/src/R/temp-library')" > /dev/null 2>&1 ; then \
625620 echo "Tinytex installation successful!"; \
626621 else \
627622 echo "Error : Tinytex installation failed."; \
628623 fi ; \
629624 for cmd in $$ required_commands ; do \
630625 echo " => Checking container image $$ image for $$ cmd..." ; \
631- $(KUBECTL_BIN ) exec rstudio-pod which $$ cmd > /dev/null 2>&1 ; \
632- if [ $$ ? -eq 0 ]; then \
633- echo "$$cmd executed successfuly!"; \
626+ if $( KUBECTL_BIN) exec rstudio-pod which $$ cmd > /dev/null 2>&1 ; then \
627+ echo "$$cmd executed successfully!"; \
634628 else \
635629 echo "ERROR : Container image $$image does not meet criteria for command: $$cmd" ; \
636630 fail=1; \
@@ -640,8 +634,7 @@ validate-rstudio-image: bin/kubectl
640634 echo " => Fetching R script from URL and executing on the container..." ; \
641635 curl -sSL -o test_script.R " ${NOTEBOOK_REPO_BRANCH_BASE} /rstudio/c9s-python-$( PYTHON_VERSION) /test/test_script.R" > /dev/null 2>&1 ; \
642636 $(KUBECTL_BIN ) cp test_script.R rstudio-pod:/opt/app-root/src/test_script.R > /dev/null 2>&1 ; \
643- $(KUBECTL_BIN ) exec rstudio-pod -- Rscript /opt/app-root/src/test_script.R > /dev/null 2>&1 ; \
644- if [ $$ ? -eq 0 ]; then \
637+ if $( KUBECTL_BIN) exec rstudio-pod -- Rscript /opt/app-root/src/test_script.R > /dev/null 2>&1 ; then \
645638 echo "R script executed successfully!"; \
646639 rm test_script.R ; \
647640 else \
0 commit comments