Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
247 lines (211 loc) · 9.78 KB
/
Copy pathMakefile
File metadata and controls
247 lines (211 loc) · 9.78 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# 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.
# Configures the shell for recipes to use bash, enabling bash commands and ensuring
# that recipes exit on any command failure (including within pipes).
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
## Variables
UV ?= uv
PRECOMMIT ?= $(UV) run --no-project --with pre-commit pre-commit
DUCKDB ?= duckdb
PYTHON_DIR := python
ONTOLOGY_SCHEMA := ontology/ontology.json
MAPPING_SCHEMA := ontology/mapping.json
DEPENDENCIES ?= uv git
OPTIONAL_DEPENDENCIES := java duckdb
define check_deps
@echo "--- Checking for requested dependencies ---"
@for dependency in $(1); do \
echo "Checking for $$dependency..."; \
if command -v $$dependency >/dev/null 2>&1; then \
echo "$$dependency is installed."; \
else \
echo "$$dependency is NOT installed."; \
echo "--- ERROR: Dependency '$$dependency' is missing. Please install it to proceed. Exiting. ---"; \
exit 1; \
fi; \
done
@echo "--- All checks complete. ---"
endef
## Version information
SPEC_VERSION := $(shell sed -n 's/^version = "\(.*\)"/\1/p' $(PYTHON_DIR)/pyproject.toml)
GIT_COMMIT := $(shell git rev-parse HEAD 2>/dev/null || echo unknown)
UV_REQUIRED_VERSION := $(shell sed -n 's/^required-version = "\(.*\)"/\1/p' $(PYTHON_DIR)/pyproject.toml)
UV_VERSION := $(shell $(UV) --version 2>/dev/null | awk '{print $$2}')
##@ General
.PHONY: help
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9\.-]+:.*?##/ { printf " \033[36m%-40s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: version
version: ## Display version information
@echo "Ossie version: ${SPEC_VERSION}"
@echo "Git commit: ${GIT_COMMIT}"
@echo "uv required: ${UV_REQUIRED_VERSION}"
@echo "uv installed: ${UV_VERSION}"
.PHONY: setup
setup: python-setup ## Set up the local development environment
.PHONY: clean
clean: python-clean ## Remove caches, build artifacts, and virtual environments
@echo "--- Removing root caches, virtual environment, and Python bytecode ---"
@rm -rf .coverage .hypothesis .mypy_cache .pytest_cache .ruff_cache .venv
@find python validation scripts compliance -type d \( -name "__pycache__" -o -name ".pytest_cache" -o -name ".mypy_cache" -o -name ".ruff_cache" \) -prune -exec rm -rf {} +
@echo "--- Cleanup complete ---"
.PHONY: test
test: test-validation test-python test-scripts compliance-test ## Run all test suites
.PHONY: check
check: test validate spec-check compliance-validate ## Run tests, validation, and generated-spec checks
##@ Validation
.PHONY: validate
validate: DEPENDENCIES := $(UV)
validate: ## Validate all canonical example documents
$(call check_deps,$(DEPENDENCIES))
@echo "--- Validating canonical examples ---"
@$(UV) run --no-project validation/validate.py examples/tpcds_semantic_model.yaml
@$(UV) run --no-project validation/validate.py examples/renamed_fields.yaml
@$(UV) run --no-project validation/validate.py examples/flights.yaml --schema $(ONTOLOGY_SCHEMA)
@$(UV) run --no-project validation/validate.py examples/flights.ontology.yaml --schema $(ONTOLOGY_SCHEMA)
@$(UV) run --no-project validation/validate.py examples/flights.semantic_model.yaml
@$(UV) run --no-project validation/validate.py examples/flights.mapping.yaml --schema $(MAPPING_SCHEMA)
@echo "--- Canonical example validation complete ---"
.PHONY: test-validation
test-validation: DEPENDENCIES := $(UV)
test-validation: ## Run validator unit and pytest suites
$(call check_deps,$(DEPENDENCIES))
@echo "--- Running validator unit tests ---"
@$(UV) run --no-project validation/test_validate.py
@echo "--- Running validator pytest tests ---"
@$(UV) run --no-project --with pytest --with pyyaml --with jsonschema --with sqlglot -m pytest validation/tests/
@echo "--- Validator tests complete ---"
##@ Python SDK
.PHONY: python-setup
python-setup: DEPENDENCIES := $(UV)
python-setup: ## Create and sync the Python SDK virtual environment
$(call check_deps,$(DEPENDENCIES))
@echo "--- Syncing Python SDK environment ---"
@$(UV) sync --directory $(PYTHON_DIR)
@echo "--- Python SDK environment ready ---"
.PHONY: test-python
test-python: python-setup ## Run Python SDK tests
@echo "--- Running Python SDK tests ---"
@$(UV) run --directory $(PYTHON_DIR) pytest
@echo "--- Python SDK tests complete ---"
.PHONY: python-build
python-build: python-setup ## Build Python SDK sdist and wheel
@echo "--- Building Python SDK distributions ---"
@$(UV) build --directory $(PYTHON_DIR) --clear
@echo "--- Python SDK distributions built ---"
.PHONY: python-clean
python-clean: ## Remove Python SDK build artifacts and environment
@echo "--- Removing Python SDK environment and build artifacts ---"
@rm -rf $(PYTHON_DIR)/.mypy_cache $(PYTHON_DIR)/.pytest_cache $(PYTHON_DIR)/.ruff_cache $(PYTHON_DIR)/.venv $(PYTHON_DIR)/dist
@find $(PYTHON_DIR) -type d -name "__pycache__" -prune -exec rm -rf {} +
@echo "--- Python SDK cleanup complete ---"
##@ Spec
.PHONY: spec-check
spec-check: DEPENDENCIES := $(UV)
spec-check: ## Verify spec.yaml enums match ossie-schema.json
$(call check_deps,$(DEPENDENCIES))
@echo "--- Checking generated spec types ---"
@$(UV) run --no-project scripts/generate-spec-types.py --check
@echo "--- Generated spec types are in sync ---"
.PHONY: spec-generate
spec-generate: DEPENDENCIES := $(UV)
spec-generate: ## Regenerate spec.yaml enums from ossie-schema.json
$(call check_deps,$(DEPENDENCIES))
@echo "--- Regenerating spec types ---"
@$(UV) run --no-project scripts/generate-spec-types.py --apply
@echo "--- Generated spec types updated ---"
.PHONY: test-scripts
test-scripts: DEPENDENCIES := $(UV) git
test-scripts: ## Run specification script unit tests
$(call check_deps,$(DEPENDENCIES))
@echo "--- Running specification script unit tests ---"
@$(UV) run --no-project -m unittest discover -s scripts/tests
@echo "--- Specification script unit tests complete ---"
##@ Compliance
.PHONY: compliance
compliance: compliance-test compliance-validate ## Run compliance tests and validate fixtures
.PHONY: compliance-test
compliance-test: DEPENDENCIES := $(UV)
compliance-test: ## Run portability grader tests
$(call check_deps,$(DEPENDENCIES))
@echo "--- Running compliance grader tests ---"
@PYTHONPATH=compliance/portability/grader $(UV) run --no-project --with pytest --with pyyaml --with sqlglot -m pytest compliance/portability/grader/test_grade.py
@echo "--- Compliance grader tests complete ---"
.PHONY: compliance-validate
compliance-validate: DEPENDENCIES := $(UV)
compliance-validate: ## Validate compliance models and portability fixtures
$(call check_deps,$(DEPENDENCIES))
@echo "--- Validating compliance fixtures ---"
@$(UV) run --no-project validation/validate.py compliance/portability/m*/*.ossie.yaml compliance/query/scott/scott_model.ossie.yaml compliance/wide_table/retail/retail_model.ossie.yaml
@echo "--- Compliance fixture validation complete ---"
.PHONY: compliance-query
compliance-query: DEPENDENCIES := $(DUCKDB)
compliance-query: ## Run query compliance reference cases with DuckDB
$(call check_deps,$(DEPENDENCIES))
@echo "--- Running query compliance reference cases ---"
@cat compliance/query/scott/scott.sql compliance/query/cases/*/reference.duckdb.sql | $(DUCKDB)
@echo "--- Query compliance reference cases complete ---"
##@ Quality
.PHONY: license
license: DEPENDENCIES := java curl
license: ## Run Apache RAT license header check
$(call check_deps,$(DEPENDENCIES))
@echo "--- Running license header check ---"
@dev/check-license
@echo "--- License header check complete ---"
.PHONY: pre-commit
pre-commit: DEPENDENCIES := $(UV)
pre-commit: ## Run all pre-commit hooks
$(call check_deps,$(DEPENDENCIES))
@echo "--- Running pre-commit hooks ---"
@$(PRECOMMIT) run --all-files
@echo "--- Pre-commit hooks complete ---"
##@ Dependencies
.PHONY: check-dependencies
check-dependencies: ## Check if all requested dependencies are present
$(call check_deps,$(DEPENDENCIES))
.PHONY: check-brew
check-brew: ## Check Homebrew installation
@echo "--- Checking Homebrew installation ---"
@if command -v brew >/dev/null 2>&1; then \
echo "--- Homebrew is installed ---"; \
else \
echo "--- Homebrew is not installed. Aborting ---"; \
exit 1; \
fi
.PHONY: install-dependencies-brew
install-dependencies-brew: check-brew ## Install missing dependencies with Homebrew
@echo "--- Checking and installing dependencies for this target ---"
@for dependency in $(DEPENDENCIES); do \
if command -v $$dependency >/dev/null 2>&1; then \
echo "$$dependency is installed."; \
else \
case $$dependency in \
java) \
echo "Java is required for 'make license'. Install Java 11+ manually or run 'brew install openjdk'." ;; \
*) \
echo "Installing $$dependency with Homebrew..."; \
brew install $$dependency; \
echo "$$dependency installed." ;; \
esac; \
fi; \
done
@echo "--- All requested dependencies checked/installed ---"
.PHONY: install-optional-dependencies-brew
install-optional-dependencies-brew: ## Install optional dependencies with Homebrew
@$(MAKE) --no-print-directory install-dependencies-brew DEPENDENCIES="$(OPTIONAL_DEPENDENCIES)"