|
14 | 14 | # KIND, either express or implied. See the License for the
|
15 | 15 | # specific language governing permissions and limitations
|
16 | 16 | # under the License.
|
17 |
| -# ======================== |
18 |
| -# Configuration Variables |
19 |
| -# ======================== |
20 | 17 |
|
21 |
| -PYTEST_ARGS ?= -v # Override with e.g. PYTEST_ARGS="-vv --tb=short" |
22 |
| -COVERAGE ?= 0 # Set COVERAGE=1 to enable coverage: make test COVERAGE=1 |
23 |
| -COVERAGE_FAIL_UNDER ?= 85 # Minimum coverage % to pass: make coverage-report COVERAGE_FAIL_UNDER=70 |
24 | 18 |
|
25 |
| -ifeq ($(COVERAGE),1) |
26 |
| - TEST_RUNNER = poetry run coverage run --parallel-mode --source=pyiceberg -m |
27 |
| -else |
28 |
| - TEST_RUNNER = poetry run |
29 |
| -endif |
| 19 | +help: ## Display this help |
| 20 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
30 | 21 |
|
31 |
| -POETRY_VERSION = 2.1.1 |
32 |
| - |
33 |
| -# ============ |
34 |
| -# Help Section |
35 |
| -# ============ |
36 |
| - |
37 |
| -##@ General |
38 |
| - |
39 |
| -help: ## Display this help message |
40 |
| - @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
41 |
| - |
42 |
| -# ================== |
43 |
| -# Installation Tasks |
44 |
| -# ================== |
45 |
| - |
46 |
| -##@ Setup |
47 |
| - |
48 |
| -install-poetry: ## Ensure Poetry is installed at the specified version |
| 22 | +POETRY_VERSION = 2.0.1 |
| 23 | +install-poetry: ## Ensure Poetry is installed and the correct version is being used. |
49 | 24 | @if ! command -v poetry &> /dev/null; then \
|
50 |
| - echo "Poetry not found. Installing..."; \ |
| 25 | + echo "Poetry could not be found. Installing..."; \ |
51 | 26 | pip install --user poetry==$(POETRY_VERSION); \
|
52 | 27 | else \
|
53 | 28 | INSTALLED_VERSION=$$(pip show poetry | grep Version | awk '{print $$2}'); \
|
54 | 29 | if [ "$$INSTALLED_VERSION" != "$(POETRY_VERSION)" ]; then \
|
55 |
| - echo "Updating Poetry to version $(POETRY_VERSION)..."; \ |
| 30 | + echo "Poetry version $$INSTALLED_VERSION does not match required version $(POETRY_VERSION). Updating..."; \ |
56 | 31 | pip install --user --upgrade poetry==$(POETRY_VERSION); \
|
57 | 32 | else \
|
58 |
| - echo "Poetry version $(POETRY_VERSION) already installed."; \ |
59 |
| - fi; \ |
| 33 | + echo "Poetry version $$INSTALLED_VERSION is already installed."; \ |
| 34 | + fi \ |
60 | 35 | fi
|
61 | 36 |
|
62 |
| -install-dependencies: ## Install all dependencies including extras |
| 37 | +install-dependencies: ## Install dependencies including dev, docs, and all extras |
63 | 38 | poetry install --all-extras
|
64 | 39 |
|
65 |
| -install: install-poetry install-dependencies ## Install Poetry and dependencies |
66 |
| - |
67 |
| -# =============== |
68 |
| -# Code Validation |
69 |
| -# =============== |
70 |
| - |
71 |
| -##@ Quality |
| 40 | +install: | install-poetry install-dependencies |
72 | 41 |
|
73 | 42 | check-license: ## Check license headers
|
74 | 43 | ./dev/check-license
|
75 | 44 |
|
76 |
| -lint: ## Run code linters via pre-commit |
| 45 | +lint: ## lint |
77 | 46 | poetry run pre-commit run --all-files
|
78 | 47 |
|
79 |
| -# =============== |
80 |
| -# Testing Section |
81 |
| -# =============== |
82 |
| - |
83 |
| -##@ Testing |
84 |
| - |
85 |
| -test: ## Run all unit tests (excluding integration) |
86 |
| - $(TEST_RUNNER) pytest tests/ -m "(unmarked or parametrize) and not integration" $(PYTEST_ARGS) |
| 48 | +test: ## Run all unit tests, can add arguments with PYTEST_ARGS="-vv" |
| 49 | + poetry run pytest tests/ -m "(unmarked or parametrize) and not integration" ${PYTEST_ARGS} |
87 | 50 |
|
88 |
| -test-integration: test-integration-setup test-integration-exec ## Run integration tests |
| 51 | +test-s3: # Run tests marked with s3, can add arguments with PYTEST_ARGS="-vv" |
| 52 | + sh ./dev/run-minio.sh |
| 53 | + poetry run pytest tests/ -m s3 ${PYTEST_ARGS} |
89 | 54 |
|
90 |
| -test-integration-setup: ## Start Docker services for integration tests |
| 55 | +test-integration: ## Run all integration tests, can add arguments with PYTEST_ARGS="-vv" |
91 | 56 | docker compose -f dev/docker-compose-integration.yml kill
|
92 | 57 | docker compose -f dev/docker-compose-integration.yml rm -f
|
93 | 58 | docker compose -f dev/docker-compose-integration.yml up -d
|
94 | 59 | sleep 10
|
95 | 60 | docker compose -f dev/docker-compose-integration.yml cp ./dev/provision.py spark-iceberg:/opt/spark/provision.py
|
96 | 61 | docker compose -f dev/docker-compose-integration.yml exec -T spark-iceberg ipython ./provision.py
|
| 62 | + poetry run pytest tests/ -v -m integration ${PYTEST_ARGS} |
97 | 63 |
|
98 |
| -test-integration-exec: ## Run integration tests (excluding provision) |
99 |
| - $(TEST_RUNNER) pytest tests/ -m integration $(PYTEST_ARGS) |
100 |
| - |
101 |
| -test-integration-rebuild: ## Rebuild integration Docker services from scratch |
| 64 | +test-integration-rebuild: |
102 | 65 | docker compose -f dev/docker-compose-integration.yml kill
|
103 | 66 | docker compose -f dev/docker-compose-integration.yml rm -f
|
104 | 67 | docker compose -f dev/docker-compose-integration.yml build --no-cache
|
105 | 68 |
|
106 |
| -test-s3: ## Run tests marked with @pytest.mark.s3 |
107 |
| - sh ./dev/run-minio.sh |
108 |
| - $(TEST_RUNNER) pytest tests/ -m s3 $(PYTEST_ARGS) |
109 |
| - |
110 |
| -test-adls: ## Run tests marked with @pytest.mark.adls |
| 69 | +test-adls: ## Run tests marked with adls, can add arguments with PYTEST_ARGS="-vv" |
111 | 70 | sh ./dev/run-azurite.sh
|
112 |
| - $(TEST_RUNNER) pytest tests/ -m adls $(PYTEST_ARGS) |
| 71 | + poetry run pytest tests/ -m adls ${PYTEST_ARGS} |
113 | 72 |
|
114 |
| -test-gcs: ## Run tests marked with @pytest.mark.gcs |
| 73 | +test-gcs: ## Run tests marked with gcs, can add arguments with PYTEST_ARGS="-vv" |
115 | 74 | sh ./dev/run-gcs-server.sh
|
116 |
| - $(TEST_RUNNER) pytest tests/ -m gcs $(PYTEST_ARGS) |
| 75 | + poetry run pytest tests/ -m gcs ${PYTEST_ARGS} |
| 76 | + |
| 77 | +test-coverage-unit: # Run test with coverage for unit tests, can add arguments with PYTEST_ARGS="-vv" |
| 78 | + poetry run coverage run --source=pyiceberg/ --data-file=.coverage.unit -m pytest tests/ -v -m "(unmarked or parametrize) and not integration" ${PYTEST_ARGS} |
117 | 79 |
|
118 |
| -test-coverage: COVERAGE=1 |
119 |
| -test-coverage: test test-integration test-s3 test-adls test-gcs coverage-report ## Run all tests with coverage and report |
| 80 | +test-coverage-integration: # Run test with coverage for integration tests, can add arguments with PYTEST_ARGS="-vv" |
| 81 | + docker compose -f dev/docker-compose-integration.yml kill |
| 82 | + docker compose -f dev/docker-compose-integration.yml rm -f |
| 83 | + docker compose -f dev/docker-compose-integration.yml up -d |
| 84 | + sh ./dev/run-azurite.sh |
| 85 | + sh ./dev/run-gcs-server.sh |
| 86 | + sleep 10 |
| 87 | + docker compose -f dev/docker-compose-integration.yml cp ./dev/provision.py spark-iceberg:/opt/spark/provision.py |
| 88 | + docker compose -f dev/docker-compose-integration.yml exec -T spark-iceberg ipython ./provision.py |
| 89 | + poetry run coverage run --source=pyiceberg/ --data-file=.coverage.integration -m pytest tests/ -v -m integration ${PYTEST_ARGS} |
120 | 90 |
|
121 |
| -coverage-report: ## Combine and report coverage |
122 |
| - poetry run coverage combine |
123 |
| - poetry run coverage report -m --fail-under=$(COVERAGE_FAIL_UNDER) |
| 91 | +test-coverage: | test-coverage-unit test-coverage-integration ## Run all tests with coverage including unit and integration tests |
| 92 | + poetry run coverage combine .coverage.unit .coverage.integration |
| 93 | + poetry run coverage report -m --fail-under=90 |
124 | 94 | poetry run coverage html
|
125 | 95 | poetry run coverage xml
|
126 | 96 |
|
127 |
| -# ================ |
128 |
| -# Documentation |
129 |
| -# ================ |
130 |
| - |
131 |
| -##@ Documentation |
132 | 97 |
|
133 |
| -docs-install: ## Install docs dependencies |
134 |
| - poetry install --with docs |
135 |
| - |
136 |
| -docs-serve: ## Serve local docs preview (hot reload) |
137 |
| - poetry run mkdocs serve -f mkdocs/mkdocs.yml |
138 |
| - |
139 |
| -docs-build: ## Build the static documentation site |
140 |
| - poetry run mkdocs build -f mkdocs/mkdocs.yml --strict |
141 |
| - |
142 |
| -# =================== |
143 |
| -# Project Maintenance |
144 |
| -# =================== |
145 |
| - |
146 |
| -##@ Maintenance |
147 |
| - |
148 |
| -clean: ## Remove build artifacts and caches |
149 |
| - @echo "Cleaning up Cython and Python cached files..." |
| 98 | +clean: ## Clean up the project Python working environment |
| 99 | + @echo "Cleaning up Cython and Python cached files" |
150 | 100 | @rm -rf build dist *.egg-info
|
151 | 101 | @find . -name "*.so" -exec echo Deleting {} \; -delete
|
152 | 102 | @find . -name "*.pyc" -exec echo Deleting {} \; -delete
|
153 | 103 | @find . -name "__pycache__" -exec echo Deleting {} \; -exec rm -rf {} +
|
154 | 104 | @find . -name "*.pyd" -exec echo Deleting {} \; -delete
|
155 | 105 | @find . -name "*.pyo" -exec echo Deleting {} \; -delete
|
156 |
| - @echo "Cleanup complete." |
| 106 | + @echo "Cleanup complete" |
| 107 | + |
| 108 | +docs-install: |
| 109 | + poetry install --with docs |
| 110 | + |
| 111 | +docs-serve: |
| 112 | + poetry run mkdocs serve -f mkdocs/mkdocs.yml |
| 113 | + |
| 114 | +docs-build: |
| 115 | + poetry run mkdocs build -f mkdocs/mkdocs.yml --strict |
0 commit comments