-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
164 lines (142 loc) · 6.18 KB
/
Copy pathMakefile
File metadata and controls
164 lines (142 loc) · 6.18 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
# Makefile for Schema Development Environment
# ---- Includes ----
include mk/infra.mk
# ---- Phony ----
.PHONY: all help validate release test up down shell build fmt lint check typecheck repo.init manifest-verify manifest-update
# Default to showing help
all: help
# =============================================================================
# Compiler Flags (can be overridden on command line, e.g., make release VERBOSE=1)
# =============================================================================
VERBOSE ?=
DEBUG ?=
DRY_RUN ?=
VERSION ?= # New: Version for release command
GIT_TIMEOUT ?= 60
VAULT_TIMEOUT ?= 10
TEST_FILE ?= # New: Specify a specific test file (e.g., tests/test_compiler.py)
TEST_NAME ?= # New: Specify a specific test function name (e.g., test_load_yaml_valid)
# Construct COMPILER_CLI_ARGS based on VERBOSE and DEBUG 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:
ifeq ($(VERSION),)
$(error VERSION is required for the release command. Usage: make release VERSION=1.0.0)
endif
@echo "--- Building and signing release schemas ---"
# Pass Git author and committer identity from host to container for commit operations
@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 release --version $(VERSION) $(COMPILER_CLI_ARGS)
# The release.sh script is no longer needed as its functionality has been integrated into compiler.py
# @tools/release.sh project.yaml
# @git add project.yaml # This is now handled by compiler.py
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
# =============================================================================
# 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 " release Build, checksum, and sign all non-dev schemas (requires Vault)."
@echo " test Run pytest for the compiler infrastructure code."
@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 'release' command."
@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 "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