1515# specific language governing permissions and limitations
1616# under the License.
1717
18- regenerate-client :
18+ # .SILENT:
19+
20+ # Configures the shell for recipes to use bash, enabling bash commands and ensuring
21+ # that recipes exit on any command failure (including within pipes).
22+ SHELL = /usr/bin/env bash -o pipefail
23+ .SHELLFLAGS = -ec
24+
25+ # Version information
26+ VERSION ?= $(shell cat pyproject.toml | grep version | sed 's/version * = * "\(.* \) "/\1/')
27+ BUILD_DATE := $(shell date -u +"% Y-% m-% dT% H:% M:% S% :z")
28+ GIT_COMMIT := $(shell git rev-parse HEAD)
29+ POETRY_VERSION := $(shell cat pyproject.toml | grep requires-poetry | sed 's/requires-poetry * = * "\(.* \) "/\1/')
30+
31+ # Variables
32+ VENV_DIR := .venv
33+
34+ .PHONY : help
35+ help : # # Display this help.
36+ @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-30s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
37+
38+ .PHONY : version
39+ version : # # Print version information.
40+ @echo " Apache Polaris version: ${VERSION} "
41+ @echo " Build date: ${BUILD_DATE} "
42+ @echo " Git commit: ${GIT_COMMIT} "
43+ @echo " Poetry version: ${POETRY_VERSION} "
44+
45+ # Target to create the virtual environment directory
46+ $(VENV_DIR ) :
47+ @echo " Setting up Python virtual environment at $( VENV_DIR) ..."
48+ python3 -m venv $(VENV_DIR )
49+ @echo " Virtual environment created."
50+
51+ .PHONY : setup-env
52+ setup-env : $(VENV_DIR ) install-poetry-deps
53+
54+ .PHONY : install-poetry-deps
55+ install-poetry-deps :
56+ @echo " Installing Poetry and project dependencies into $( VENV_DIR) ..."
57+ # Ensure pip is up-to-date within the venv
58+ $(VENV_DIR ) /bin/pip install --upgrade pip
59+ # Install poetry if not already present
60+ @if [ ! -f " $( VENV_DIR) /bin/poetry" ]; then \
61+ $(VENV_DIR ) /bin/pip install --upgrade " poetry${POETRY_VERSION} " ; \
62+ fi
63+ # Install needed dependencies using poetry
64+ $(VENV_DIR ) /bin/poetry install --all-extras
65+ @echo " Poetry and dependencies installed."
66+
67+ .PHONY : regenerate-client
68+ regenerate-client : # # Regenerate the client code
1969 ../templates/regenerate.sh
2070
21- test-integration :
71+ .PHONY : test-client
72+ test-client : setup-env # # Run client tests
73+ SCRIPT_DIR=" non-existing-mock-directory" $(VENV_DIR ) /bin/poetry run pytest test/
74+
75+ .PHONY : test-integration
76+ test-integration : setup-env # # Run integration tests
2277 docker compose -f docker-compose.yml kill
2378 docker compose -f docker-compose.yml rm -f
2479 docker compose -f docker-compose.yml up -d
@@ -28,8 +83,25 @@ test-integration:
2883 echo " Still waiting for HTTP 200 from /q/health..." ; \
2984 done
3085 @echo " Polaris is healthy. Starting integration tests..."
31- poetry run pytest integration_tests/ ${PYTEST_ARGS}
86+ $(VENV_DIR ) /bin/poetry run pytest integration_tests/ ${PYTEST_ARGS}
87+
88+ .PHONY : lint
89+ lint : setup-env # # Run linting checks
90+ $(VENV_DIR ) /bin/poetry run pre-commit run --files integration_tests/* cli/*
3291
92+ .PHONY : clean-venv
93+ clean-venv :
94+ @echo " Attempting to remove virtual environment directory: $( VENV_DIR) ..."
95+ # SAFETY CHECK: Ensure VENV_DIR is not empty and exists before attempting to remove
96+ @if [ -n " $( VENV_DIR) " ] && [ -d " $( VENV_DIR) " ]; then \
97+ rm -rf " $( VENV_DIR) " ; \
98+ echo " Virtual environment removed." ; \
99+ else \
100+ echo " Virtual environment directory '$( VENV_DIR) ' not found or VENV_DIR is empty. No action taken." ; \
101+ fi
33102
34- lint :
35- poetry run pre-commit run --files integration_tests/*
103+ .PHONY : clean
104+ clean : clean-venv # # Cleanup
105+ @echo " Cleaning up Python cache files..."
106+ find . -type f -name " *.pyc" -delete
107+ find . -type d -name " __pycache__" -delete
0 commit comments