forked from apache/iceberg-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
156 lines (121 loc) · 5.31 KB
/
Makefile
File metadata and controls
156 lines (121 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ========================
# Configuration Variables
# ========================
PYTEST_ARGS ?= -v # Override with e.g. PYTEST_ARGS="-vv --tb=short"
COVERAGE ?= 0 # Set COVERAGE=1 to enable coverage: make test COVERAGE=1
COVERAGE_FAIL_UNDER ?= 85 # Minimum coverage % to pass: make coverage-report COVERAGE_FAIL_UNDER=70
ifeq ($(COVERAGE),1)
TEST_RUNNER = poetry run coverage run --parallel-mode --source=pyiceberg -m
else
TEST_RUNNER = poetry run
endif
POETRY_VERSION = 2.1.1
# ============
# Help Section
# ============
##@ General
help: ## Display this help message
@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)
# ==================
# Installation Tasks
# ==================
##@ Setup
install-poetry: ## Ensure Poetry is installed at the specified version
@if ! command -v poetry &> /dev/null; then \
echo "Poetry not found. Installing..."; \
pip install --user poetry==$(POETRY_VERSION); \
else \
INSTALLED_VERSION=$$(pip show poetry | grep Version | awk '{print $$2}'); \
if [ "$$INSTALLED_VERSION" != "$(POETRY_VERSION)" ]; then \
echo "Updating Poetry to version $(POETRY_VERSION)..."; \
pip install --user --upgrade poetry==$(POETRY_VERSION); \
else \
echo "Poetry version $(POETRY_VERSION) already installed."; \
fi; \
fi
install-dependencies: ## Install all dependencies including extras
poetry install --all-extras
install: install-poetry install-dependencies ## Install Poetry and dependencies
# ===============
# Code Validation
# ===============
##@ Quality
check-license: ## Check license headers
./dev/check-license
lint: ## Run code linters via pre-commit
poetry run pre-commit run --all-files
# ===============
# Testing Section
# ===============
##@ Testing
test: ## Run all unit tests (excluding integration)
$(TEST_RUNNER) pytest tests/ -m "(unmarked or parametrize) and not integration" $(PYTEST_ARGS)
test-integration: test-integration-setup test-integration-exec ## Run integration tests
test-integration-setup: ## Start Docker services for integration tests
docker compose -f dev/docker-compose-integration.yml kill
docker compose -f dev/docker-compose-integration.yml rm -f
docker compose -f dev/docker-compose-integration.yml up -d
sleep 10
docker compose -f dev/docker-compose-integration.yml cp ./dev/provision.py spark-iceberg:/opt/spark/provision.py
docker compose -f dev/docker-compose-integration.yml exec -T spark-iceberg ipython ./provision.py
test-integration-exec: ## Run integration tests (excluding provision)
$(TEST_RUNNER) pytest tests/ -m integration $(PYTEST_ARGS)
test-integration-rebuild: ## Rebuild integration Docker services from scratch
docker compose -f dev/docker-compose-integration.yml kill
docker compose -f dev/docker-compose-integration.yml rm -f
docker compose -f dev/docker-compose-integration.yml build --no-cache
test-s3: ## Run tests marked with @pytest.mark.s3
sh ./dev/run-minio.sh
$(TEST_RUNNER) pytest tests/ -m s3 $(PYTEST_ARGS)
test-adls: ## Run tests marked with @pytest.mark.adls
sh ./dev/run-azurite.sh
$(TEST_RUNNER) pytest tests/ -m adls $(PYTEST_ARGS)
test-gcs: ## Run tests marked with @pytest.mark.gcs
sh ./dev/run-gcs-server.sh
$(TEST_RUNNER) pytest tests/ -m gcs $(PYTEST_ARGS)
test-coverage: COVERAGE=1
test-coverage: test test-integration test-s3 test-adls test-gcs coverage-report ## Run all tests with coverage and report
coverage-report: ## Combine and report coverage
poetry run coverage combine
poetry run coverage report -m --fail-under=$(COVERAGE_FAIL_UNDER)
poetry run coverage html
poetry run coverage xml
# ================
# Documentation
# ================
##@ Documentation
docs-install: ## Install docs dependencies
poetry install --with docs
docs-serve: ## Serve local docs preview (hot reload)
poetry run mkdocs serve -f mkdocs/mkdocs.yml
docs-build: ## Build the static documentation site
poetry run mkdocs build -f mkdocs/mkdocs.yml --strict
# ===================
# Project Maintenance
# ===================
##@ Maintenance
clean: ## Remove build artifacts and caches
@echo "Cleaning up Cython and Python cached files..."
@rm -rf build dist *.egg-info
@find . -name "*.so" -exec echo Deleting {} \; -delete
@find . -name "*.pyc" -exec echo Deleting {} \; -delete
@find . -name "__pycache__" -exec echo Deleting {} \; -exec rm -rf {} +
@find . -name "*.pyd" -exec echo Deleting {} \; -delete
@find . -name "*.pyo" -exec echo Deleting {} \; -delete
@echo "Cleanup complete."