@@ -4,9 +4,10 @@ SELF ::= $(firstword $(MAKEFILE_LIST))
4
4
5
5
# https://tech.davis-hansson.com/p/make/
6
6
SHELL := bash
7
- # todo: do not set .ONESHELL: for now
7
+ .ONESHELL :
8
8
# 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
10
11
.DELETE_ON_ERROR :
11
12
MAKEFLAGS += --warn-undefined-variables
12
13
MAKEFLAGS += --no-builtin-rules
@@ -493,13 +494,11 @@ undeploy-c9s-%: bin/kubectl
493
494
define test_with_papermill
494
495
$(eval PREFIX_NAME := $(subst /,-,$(1 ) _$(2 ) ) ) \
495
496
$(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 \
498
498
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." ; \
499
499
exit 1 ; \
500
500
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 \
503
502
echo "ERROR: The $(1 ) $(2 ) notebook encountered a failure. The make process has been aborted." ; \
504
503
$(KUBECTL_BIN ) exec $(FULL_NOTEBOOK_NAME ) -- /bin/sh -c "cat $(PREFIX_NAME ) _error.txt" ; \
505
504
exit 1 ; \
@@ -562,19 +561,17 @@ validate-runtime-image: bin/kubectl
562
561
fi ; \
563
562
for cmd in $$ required_commands ; do \
564
563
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 \
567
565
echo " ERROR: Container image $$ image does not meet criteria for command: $$ cmd" ; \
568
566
fail=1; \
569
567
continue ; \
570
568
fi ; \
571
569
if [ $$ cmd == " python3" ]; then \
572
570
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 \
578
575
echo " ERROR: Image does not meet Python requirements criteria in pipfile" ; \
579
576
fail=1; \
580
577
fi ; \
@@ -599,8 +596,7 @@ validate-codeserver-image: bin/kubectl
599
596
fi ; \
600
597
for cmd in $$ required_commands ; do \
601
598
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 \
604
600
echo " ERROR: Container image $$ image does not meet criteria for command: $$ cmd" ; \
605
601
fail=1; \
606
602
continue ; \
@@ -618,19 +614,17 @@ validate-rstudio-image: bin/kubectl
618
614
echo " Usage: make validate-rstudio-image image=<container-image-name>" ; \
619
615
exit 1 ; \
620
616
fi ; \
621
- echo " => Checking container image $$ image for package intallation ..." ; \
617
+ echo " => Checking container image $$ image for package installation ..." ; \
622
618
$(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 \
625
620
echo "Tinytex installation successful!"; \
626
621
else \
627
622
echo "Error : Tinytex installation failed."; \
628
623
fi ; \
629
624
for cmd in $$ required_commands ; do \
630
625
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!"; \
634
628
else \
635
629
echo "ERROR : Container image $$image does not meet criteria for command: $$cmd" ; \
636
630
fail=1; \
@@ -640,8 +634,7 @@ validate-rstudio-image: bin/kubectl
640
634
echo " => Fetching R script from URL and executing on the container..." ; \
641
635
curl -sSL -o test_script.R " ${NOTEBOOK_REPO_BRANCH_BASE} /rstudio/c9s-python-$( PYTHON_VERSION) /test/test_script.R" > /dev/null 2>&1 ; \
642
636
$(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 \
645
638
echo "R script executed successfully!"; \
646
639
rm test_script.R ; \
647
640
else \
0 commit comments