|
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 | +# ======================== |
17 | 20 |
|
| 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 |
18 | 24 |
|
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) |
| 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 |
21 | 30 |
|
22 | 31 | POETRY_VERSION = 2.1.1
|
23 |
| -install-poetry: ## Ensure Poetry is installed and the correct version is being used. |
| 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 |
24 | 49 | @if ! command -v poetry &> /dev/null; then \
|
25 |
| - echo "Poetry could not be found. Installing..."; \ |
| 50 | + echo "Poetry not found. Installing..."; \ |
26 | 51 | pip install --user poetry==$(POETRY_VERSION); \
|
27 | 52 | else \
|
28 | 53 | INSTALLED_VERSION=$$(pip show poetry | grep Version | awk '{print $$2}'); \
|
29 | 54 | if [ "$$INSTALLED_VERSION" != "$(POETRY_VERSION)" ]; then \
|
30 |
| - echo "Poetry version $$INSTALLED_VERSION does not match required version $(POETRY_VERSION). Updating..."; \ |
| 55 | + echo "Updating Poetry to version $(POETRY_VERSION)..."; \ |
31 | 56 | pip install --user --upgrade poetry==$(POETRY_VERSION); \
|
32 | 57 | else \
|
33 |
| - echo "Poetry version $$INSTALLED_VERSION is already installed."; \ |
34 |
| - fi \ |
| 58 | + echo "Poetry version $(POETRY_VERSION) already installed."; \ |
| 59 | + fi; \ |
35 | 60 | fi
|
36 | 61 |
|
37 |
| -install-dependencies: ## Install dependencies including dev, docs, and all extras |
| 62 | +install-dependencies: ## Install all dependencies including extras |
38 | 63 | poetry install --all-extras
|
39 | 64 |
|
40 |
| -install: | install-poetry install-dependencies |
| 65 | +install: install-poetry install-dependencies ## Install Poetry and dependencies |
| 66 | + |
| 67 | +# =============== |
| 68 | +# Code Validation |
| 69 | +# =============== |
| 70 | + |
| 71 | +##@ Quality |
41 | 72 |
|
42 | 73 | check-license: ## Check license headers
|
43 | 74 | ./dev/check-license
|
44 | 75 |
|
45 |
| -lint: ## lint |
| 76 | +lint: ## Run code linters via pre-commit |
46 | 77 | poetry run pre-commit run --all-files
|
47 | 78 |
|
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} |
| 79 | +# =============== |
| 80 | +# Testing Section |
| 81 | +# =============== |
50 | 82 |
|
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} |
| 83 | +##@ Testing |
54 | 84 |
|
55 |
| -test-integration: | test-integration-setup test-integration-exec ## Run all integration tests, can add arguments with PYTEST_ARGS="-vv" |
| 85 | +test: ## Run all unit tests (excluding integration) |
| 86 | + $(TEST_RUNNER) pytest tests/ -m "(unmarked or parametrize) and not integration" $(PYTEST_ARGS) |
56 | 87 |
|
57 |
| -test-integration-setup: # Prepare the environment for integration |
| 88 | +test-integration: test-integration-setup test-integration-exec ## Run integration tests |
| 89 | + |
| 90 | +test-integration-setup: ## Start Docker services for integration tests |
58 | 91 | docker compose -f dev/docker-compose-integration.yml kill
|
59 | 92 | docker compose -f dev/docker-compose-integration.yml rm -f
|
60 | 93 | docker compose -f dev/docker-compose-integration.yml up -d
|
61 | 94 | sleep 10
|
62 | 95 | docker compose -f dev/docker-compose-integration.yml cp ./dev/provision.py spark-iceberg:/opt/spark/provision.py
|
63 | 96 | docker compose -f dev/docker-compose-integration.yml exec -T spark-iceberg ipython ./provision.py
|
64 | 97 |
|
65 |
| -test-integration-exec: # Execute integration tests, can add arguments with PYTEST_ARGS="-vv" |
66 |
| - poetry run pytest tests/ -v -m integration ${PYTEST_ARGS} |
| 98 | +test-integration-exec: ## Run integration tests (excluding provision) |
| 99 | + $(TEST_RUNNER) pytest tests/ -m integration $(PYTEST_ARGS) |
67 | 100 |
|
68 |
| -test-integration-rebuild: |
| 101 | +test-integration-rebuild: ## Rebuild integration Docker services from scratch |
69 | 102 | docker compose -f dev/docker-compose-integration.yml kill
|
70 | 103 | docker compose -f dev/docker-compose-integration.yml rm -f
|
71 | 104 | docker compose -f dev/docker-compose-integration.yml build --no-cache
|
72 | 105 |
|
73 |
| -test-adls: ## Run tests marked with adls, can add arguments with PYTEST_ARGS="-vv" |
| 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 |
74 | 111 | sh ./dev/run-azurite.sh
|
75 |
| - poetry run pytest tests/ -m adls ${PYTEST_ARGS} |
| 112 | + $(TEST_RUNNER) pytest tests/ -m adls $(PYTEST_ARGS) |
76 | 113 |
|
77 |
| -test-gcs: ## Run tests marked with gcs, can add arguments with PYTEST_ARGS="-vv" |
| 114 | +test-gcs: ## Run tests marked with @pytest.mark.gcs |
78 | 115 | sh ./dev/run-gcs-server.sh
|
79 |
| - poetry run pytest tests/ -m gcs ${PYTEST_ARGS} |
| 116 | + $(TEST_RUNNER) pytest tests/ -m gcs $(PYTEST_ARGS) |
80 | 117 |
|
81 |
| -test-coverage-unit: # Run test with coverage for unit tests, can add arguments with PYTEST_ARGS="-vv" |
82 |
| - poetry run coverage run --source=pyiceberg/ --data-file=.coverage.unit -m pytest tests/ -v -m "(unmarked or parametrize) and not integration" ${PYTEST_ARGS} |
83 |
| - |
84 |
| -test-coverage-integration: # Run test with coverage for integration tests, can add arguments with PYTEST_ARGS="-vv" |
85 |
| - docker compose -f dev/docker-compose-integration.yml kill |
86 |
| - docker compose -f dev/docker-compose-integration.yml rm -f |
87 |
| - docker compose -f dev/docker-compose-integration.yml up -d |
88 |
| - sh ./dev/run-azurite.sh |
89 |
| - sh ./dev/run-gcs-server.sh |
90 |
| - sleep 10 |
91 |
| - docker compose -f dev/docker-compose-integration.yml cp ./dev/provision.py spark-iceberg:/opt/spark/provision.py |
92 |
| - docker compose -f dev/docker-compose-integration.yml exec -T spark-iceberg ipython ./provision.py |
93 |
| - poetry run coverage run --source=pyiceberg/ --data-file=.coverage.integration -m pytest tests/ -v -m integration ${PYTEST_ARGS} |
| 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 |
94 | 120 |
|
95 |
| -test-coverage: | test-coverage-unit test-coverage-integration ## Run all tests with coverage including unit and integration tests |
96 |
| - poetry run coverage combine .coverage.unit .coverage.integration |
97 |
| - poetry run coverage report -m --fail-under=90 |
| 121 | +coverage-report: ## Combine and report coverage |
| 122 | + poetry run coverage combine |
| 123 | + poetry run coverage report -m --fail-under=$(COVERAGE_FAIL_UNDER) |
98 | 124 | poetry run coverage html
|
99 | 125 | poetry run coverage xml
|
100 | 126 |
|
| 127 | +# ================ |
| 128 | +# Documentation |
| 129 | +# ================ |
101 | 130 |
|
102 |
| -clean: ## Clean up the project Python working environment |
103 |
| - @echo "Cleaning up Cython and Python cached files" |
104 |
| - @rm -rf build dist *.egg-info |
105 |
| - @find . -name "*.so" -exec echo Deleting {} \; -delete |
106 |
| - @find . -name "*.pyc" -exec echo Deleting {} \; -delete |
107 |
| - @find . -name "__pycache__" -exec echo Deleting {} \; -exec rm -rf {} + |
108 |
| - @find . -name "*.pyd" -exec echo Deleting {} \; -delete |
109 |
| - @find . -name "*.pyo" -exec echo Deleting {} \; -delete |
110 |
| - @echo "Cleanup complete" |
| 131 | +##@ Documentation |
111 | 132 |
|
112 |
| -docs-install: |
| 133 | +docs-install: ## Install docs dependencies |
113 | 134 | poetry install --with docs
|
114 | 135 |
|
115 |
| -docs-serve: |
| 136 | +docs-serve: ## Serve local docs preview (hot reload) |
116 | 137 | poetry run mkdocs serve -f mkdocs/mkdocs.yml
|
117 | 138 |
|
118 |
| -docs-build: |
| 139 | +docs-build: ## Build the static documentation site |
119 | 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..." |
| 150 | + @rm -rf build dist *.egg-info |
| 151 | + @find . -name "*.so" -exec echo Deleting {} \; -delete |
| 152 | + @find . -name "*.pyc" -exec echo Deleting {} \; -delete |
| 153 | + @find . -name "__pycache__" -exec echo Deleting {} \; -exec rm -rf {} + |
| 154 | + @find . -name "*.pyd" -exec echo Deleting {} \; -delete |
| 155 | + @find . -name "*.pyo" -exec echo Deleting {} \; -delete |
| 156 | + @echo "Cleanup complete." |
0 commit comments