-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·204 lines (178 loc) · 7.66 KB
/
Copy pathMakefile
File metadata and controls
executable file
·204 lines (178 loc) · 7.66 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
# Makefile for Schema Development Environment
# ---- Includes ----
include mk/infra.mk
# ---- Phony ----
.PHONY: all help validate release-check release-prepare release-close test up down shell build fmt lint check typecheck repo.init manifest-verify manifest-update deps deps.local kb.gitmodules kb.gitmodules.check kb.build mcp.run mcp.run.sse mcp.run.session mcp.config
# Default to showing help
all: help
# =============================================================================
# Compiler Flags (can be overridden on command line)
# =============================================================================
VERBOSE ?=
DEBUG ?=
DRY_RUN ?=
VERSION ?=
GIT_TIMEOUT ?= 60
VAULT_TIMEOUT ?= 10
TEST_FILE ?=
TEST_NAME ?=
# Construct COMPILER_CLI_ARGS based on flags
COMPILER_CLI_ARGS =
ifeq ($(VERBOSE),1)
COMPILER_CLI_ARGS += --verbose
endif
ifeq ($(DEBUG),1)
COMPILER_CLI_ARGS += --debug
endif
ifeq ($(DRY_RUN),1)
COMPILER_CLI_ARGS += --dry-run
endif
COMPILER_CLI_ARGS += --git-timeout $(GIT_TIMEOUT)
COMPILER_CLI_ARGS += --vault-timeout $(VAULT_TIMEOUT)
# Construct PYTEST_ARGS based on TEST_FILE and TEST_NAME
PYTEST_ARGS =
ifeq ($(TEST_FILE),)
PYTEST_ARGS += tests/
else
PYTEST_ARGS += $(TEST_FILE)
endif
ifeq ($(TEST_NAME),)
# No specific test name
else
PYTEST_ARGS += -k "$(TEST_NAME)"
endif
# =============================================================================
# Container Lifecycle Management (Aliases)
# =============================================================================
up: infra.up
down: infra.down
shell: infra.shell
build: infra.build
# =============================================================================
# Main Development Tasks
# =============================================================================
validate:
@echo "--- Validating all schemas against the meta-schema ---"
@docker compose exec builder python -m tools.compiler validate $(COMPILER_CLI_ARGS)
release-check:
ifeq ($(VERSION),)
$(error VERSION is required. Usage: make release-check VERSION=1.0.0)
endif
@echo "--- Running pre-flight checks for release v$(VERSION) ---"
@docker compose exec builder python -m tools.compiler check --version $(VERSION) $(COMPILER_CLI_ARGS)
release-prepare:
ifeq ($(VERSION),)
$(error VERSION is required. Usage: make release-prepare VERSION=1.0.0)
endif
@echo "--- Preparing release v$(VERSION) ---"
@docker compose exec \
-e GIT_AUTHOR_NAME="$(shell git config user.name)" \
-e GIT_AUTHOR_EMAIL="$(shell git config user.email)" \
-e GIT_COMMITTER_NAME="$(shell git config user.name)" \
-e GIT_COMMITTER_EMAIL="$(shell git config user.email)" \
builder python -m tools.compiler prepare --version $(VERSION) $(COMPILER_CLI_ARGS)
release-close:
ifeq ($(VERSION),)
$(error VERSION is required. Usage: make release-close VERSION=1.0.0)
endif
@echo "--- Finalizing and closing release v$(VERSION) ---"
@docker compose exec \
-e GIT_AUTHOR_NAME="$(shell git config user.name)" \
-e GIT_AUTHOR_EMAIL="$(shell git config user.email)" \
-e GIT_COMMITTER_NAME="$(shell git config user.name)" \
-e GIT_COMMITTER_EMAIL="$(shell git config user.email)" \
builder python -m tools.compiler close --version $(VERSION) $(COMPILER_CLI_ARGS)
test: infra.test
# =============================================================================
# Manifest Management
# =============================================================================
manifest-verify: ##manifest-verify
@echo "--- Verifying repository manifest ---"
@docker compose exec builder sh -c 'test -f MANIFEST.sha256 && sha256sum -c MANIFEST.sha256'
manifest-update: ##manifest-update
@echo "--- Updating repository manifest ---"
@docker compose exec builder sh -c 'git ls-files -z \
| xargs -0 sha256sum' | grep -v "MANIFEST.sha256" | LC_ALL=C sort > MANIFEST.sha256
@echo "MANIFEST.sha256 updated"
# =============================================================================
# Code Quality & Formatting (Aliases)
# =============================================================================
fmt: infra.fmt
lint: infra.lint
typecheck: infra.typecheck
check: infra.check
# =============================================================================
# Repository Setup (Aliases)
# =============================================================================
repo.init: infra.repo.init
# =============================================================================
# Knowledge Base & MCP Server (p_venv based, no Docker)
# =============================================================================
deps: infra.deps
deps.local: infra.deps.local
kb.gitmodules: infra.kb.gitmodules
kb.gitmodules.check: infra.kb.gitmodules.check
kb.build: infra.kb.build
mcp.run: infra.mcp.run
mcp.run.sse: infra.mcp.run.sse
mcp.run.session: infra.mcp.run.session
mcp.config: infra.mcp.config
# =============================================================================
# Help
# =============================================================================
help:
@echo "Usage: make [target] [OPTIONS]"
@echo ""
@echo "--- High-Level Project Commands ---"
@echo "Development Environment:"
@echo " up Start the development environment."
@echo " down Stop and remove the development environment."
@echo " shell Open an interactive shell into the running environment."
@echo " build Build the development environment."
@echo ""
@echo "Main Tasks:"
@echo " validate Run fast, offline validation of all schemas."
@echo " test Run pytest for the compiler infrastructure code."
@echo ""
@echo "Release Process (multi-step):"
@echo " release-check Run pre-flight checks before starting a release."
@echo " release-prepare Step 1: Create release branch and prepare project.yaml."
@echo " release-close Step 2: Finalize, tag, merge, and clean up the release."
@echo ""
@echo "Manifest Management:"
@echo " manifest-verify Verify the integrity of the repository using MANIFEST.sha256."
@echo " manifest-update Re-generate the MANIFEST.sha256 file."
@echo ""
@echo "Options for validate/release-*:"
@echo " VERBOSE=1 Enable verbose output."
@echo " DEBUG=1 Enable debug output (most verbose)."
@echo " DRY_RUN=1 Perform a trial run without making any changes."
@echo " VERSION=X.Y.Z The semantic version to release (e.g., 1.0.0). Required for all 'release-*' commands."
@echo " GIT_TIMEOUT=N Set Git command timeout in seconds (default: 60)."
@echo " VAULT_TIMEOUT=N Set Vault API call timeout in seconds (default: 10)."
@echo ""
@echo "Options for test:"
@echo " TEST_FILE=path/to/file.py Specify a single test file to run."
@echo " TEST_NAME=test_function Specify a single test function to run (can be combined with TEST_FILE)."
@echo ""
@echo "Code Quality & Formatting:"
@echo " fmt Format all code."
@echo " lint Lint all code and files."
@echo " typecheck Run static type checking."
@echo " check Run all code quality checks (fmt, lint, typecheck)."
@echo ""
@echo "Repository Setup:"
@echo " repo.init Set up the Git hooks for this repository."
@echo ""
@echo "Knowledge Base & MCP Server:"
@echo " deps (Re)generate requirements.txt and install deps into ./p_venv (run first!)."
@echo " mcp.config Generate .mcp.json with correct paths for this repo."
@echo " kb.build Build the knowledge base from ./source."
@echo " mcp.run Start the MCP server (stdio)."
@echo " mcp.run.sse Start the MCP server (SSE/HTTP)."
@echo ""
@echo "Maintenance:"
@echo " infra.deps (Re)generate and install dependencies."
@echo " infra.coverage Generate code coverage report."
@echo " infra.clean Remove all generated files and caches."
@$(MAKE) infra.help