@@ -26,10 +26,14 @@ DOCKER ?= docker
2626MINIKUBE_PROFILE ?= minikube
2727DEPENDENCIES ?= ct helm helm-docs java21 git
2828OPTIONAL_DEPENDENCIES := jq kubectl minikube
29+ VENV_DIR := .venv
30+ PYTHON_CLIENT_DIR := client/python
31+ ACTIVATE_AND_CD = source $(VENV_DIR ) /bin/activate && cd $(PYTHON_CLIENT_DIR )
2932
3033# # Version information
3134BUILD_VERSION := $(shell cat version.txt)
3235GIT_COMMIT := $(shell git rev-parse HEAD)
36+ POETRY_VERSION := $(shell cat client/python/pyproject.toml | grep requires-poetry | sed 's/requires-poetry * = * "\(.* \) "/\1/')
3337
3438# #@ General
3539
@@ -41,6 +45,7 @@ help: ## Display this help
4145version : # # Display version information
4246 @echo " Build version: ${BUILD_VERSION} "
4347 @echo " Git commit: ${GIT_COMMIT} "
48+ @echo " Poetry version: ${POETRY_VERSION} "
4449
4550# #@ Polaris Build
4651
@@ -99,6 +104,79 @@ spotless-apply: check-dependencies ## Apply code formatting using Spotless Gradl
99104 @./gradlew spotlessApply
100105 @echo " --- Spotless formatting applied ---"
101106
107+ # #@ Polaris Client
108+
109+ # Target to create the virtual environment directory
110+ $(VENV_DIR ) :
111+ @echo " Setting up Python virtual environment at $( VENV_DIR) ..."
112+ @python3 -m venv $(VENV_DIR )
113+ @echo " Virtual environment created."
114+
115+ .PHONY : client-install-dependencies
116+ client-install-dependencies : $(VENV_DIR )
117+ @echo " Installing Poetry and project dependencies into $( VENV_DIR) ..."
118+ @$(VENV_DIR ) /bin/pip install --upgrade pip
119+ @if [ ! -f " $( VENV_DIR) /bin/poetry" ]; then \
120+ $(VENV_DIR ) /bin/pip install --upgrade " poetry$( POETRY_VERSION) " ; \
121+ fi
122+ @$(ACTIVATE_AND_CD ) && poetry install --all-extras
123+ @echo " Poetry and dependencies installed."
124+
125+ .PHONY : client-setup-env
126+ client-setup-env : $(VENV_DIR ) client-install-dependencies
127+
128+ .PHONY : client-lint
129+ client-lint : client-setup-env # # Run linting checks for Polaris client
130+ @echo " --- Running client linting checks ---"
131+ @$(ACTIVATE_AND_CD ) && poetry run pre-commit run --files integration_tests/* python/cli/*
132+ @echo " --- Client linting checks complete ---"
133+
134+ .PHONY : client-regenerate
135+ client-regenerate : client-setup-env # # Regenerate the client code
136+ @echo " --- Regenerating client code ---"
137+ @client/templates/regenerate.sh
138+ @echo " --- Client code regeneration complete ---"
139+
140+ .PHONY : client-unit-test
141+ client-unit-test : client-setup-env # # Run client unit tests
142+ @echo " --- Running client unit tests ---"
143+ @$(ACTIVATE_AND_CD ) && SCRIPT_DIR=" non-existing-mock-directory" poetry run pytest test/
144+ @echo " --- Client unit tests complete ---"
145+
146+ .PHONY : client-integration-test
147+ client-integration-test : client-setup-env # # Run client integration tests
148+ @echo " --- Starting client integration tests ---"
149+ @echo " Ensuring Docker Compose services are stopped and removed..."
150+ @$(CONTAINER_TOOL ) compose -f $(PYTHON_CLIENT_DIR ) /docker-compose.yml kill || true # `|| true` prevents make from failing if containers don't exist
151+ @$(CONTAINER_TOOL ) compose -f $(PYTHON_CLIENT_DIR ) /docker-compose.yml rm -f || true # `|| true` prevents make from failing if containers don't exist
152+ @echo " Bringing up Docker Compose services in detached mode..."
153+ @$(CONTAINER_TOOL ) compose -f $(PYTHON_CLIENT_DIR ) /docker-compose.yml up -d
154+ @echo " Waiting for Polaris HTTP health check to pass..."
155+ @until curl -s -f http://localhost:8182/q/health > /dev/null; do \
156+ echo " Still waiting for HTTP 200 from /q/health (sleeping 2s)..." ; \
157+ sleep 2; \
158+ done
159+ @echo " Polaris is healthy. Starting integration tests..."
160+ @$(ACTIVATE_AND_CD ) && poetry run pytest integration_tests/
161+ @echo " --- Client integration tests complete ---"
162+ @echo " Tearing down Docker Compose services..."
163+ @$(CONTAINER_TOOL ) compose -f $(PYTHON_CLIENT_DIR ) /docker-compose.yml down || true # Ensure teardown even if tests fail
164+
165+ .PHONY : client-cleanup
166+ client-cleanup : # # Cleanup virtual environment and Python cache files
167+ @echo " --- Cleaning up virtual environment and Python cache files ---"
168+ @echo " Attempting to remove virtual environment directory: $( VENV_DIR) ..."
169+ @if [ -n " $( VENV_DIR) " ] && [ -d " $( VENV_DIR) " ]; then \
170+ rm -rf " $( VENV_DIR) " ; \
171+ echo " Virtual environment removed." ; \
172+ else \
173+ echo " Virtual environment directory '$( VENV_DIR) ' not found or VENV_DIR is empty. No action taken." ; \
174+ fi
175+ @echo " Cleaning up Python cache files..."
176+ @find $(PYTHON_CLIENT_DIR ) -type f -name " *.pyc" -delete
177+ @find $(PYTHON_CLIENT_DIR ) -type d -name " __pycache__" -delete
178+ @echo " --- Virtual environment and Python cache cleanup complete ---"
179+
102180# #@ Helm
103181
104182helm-doc-generate : DEPENDENCIES := helm-docs
@@ -178,7 +256,7 @@ minikube-cleanup: check-dependencies ## Cleanup the Minikube cluster
178256# #@ Pre-commit
179257
180258.PHONY : pre-commit
181- pre-commit : spotless-apply helm-doc-generate # # Run tasks for pre-commit
259+ pre-commit : spotless-apply helm-doc-generate client-lint # # Run tasks for pre-commit
182260
183261# #@ Dependencies
184262
0 commit comments