-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
165 lines (150 loc) · 5.47 KB
/
Copy pathMakefile
File metadata and controls
165 lines (150 loc) · 5.47 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
.PHONY: help all validate validate-all generate generate-python generate-go generate-typescript test test-all test-python clean clean-all bump-version
# Default target
help:
@echo "Pentagi Taxonomy Makefile"
@echo ""
@echo "Available targets:"
@echo " all VERSION=N - Run full cycle: validate → generate → test"
@echo " validate VERSION=N - Validate YAML schema for version N"
@echo " validate-all - Validate all version schemas"
@echo " generate VERSION=N - Generate code for all languages (version N)"
@echo " generate-python VERSION=N - Generate only Python code (version N)"
@echo " generate-go VERSION=N - Generate only Go code (version N)"
@echo " generate-typescript VERSION=N - Generate only TypeScript code (version N)"
@echo " test VERSION=N - Run Python tests for version N"
@echo " test-all - Run Python tests for all versions"
@echo " clean VERSION=N - Remove generated files for version N"
@echo " clean-all - Remove all generated files"
@echo " bump-version - Create new major version directory"
@echo ""
@echo "Examples:"
@echo " make all VERSION=2 # Full cycle for v2"
@echo " make generate VERSION=2"
@echo " make test VERSION=1"
@echo " make validate-all"
# Full cycle: validate, generate, and test
all:
@if [ -z "$(VERSION)" ]; then \
echo "ERROR: VERSION is required. Usage: make all VERSION=N"; \
exit 1; \
fi
@echo "Running full cycle for version $(VERSION)..."
@echo ""
@$(MAKE) validate VERSION=$(VERSION)
@echo ""
@$(MAKE) generate VERSION=$(VERSION)
@echo ""
@$(MAKE) test VERSION=$(VERSION)
@echo ""
@echo "✓ Full cycle complete for version $(VERSION)!"
# Validate schema for specific version
validate:
@if [ -z "$(VERSION)" ]; then \
echo "ERROR: VERSION is required. Usage: make validate VERSION=N"; \
exit 1; \
fi
@echo "Validating schema for version $(VERSION)..."
@python codegen/shared/validator.py v$(VERSION)/entities.yml
# Validate all version schemas
validate-all:
@echo "Validating all schemas..."
@for dir in v*/; do \
if [ -f "$$dir/entities.yml" ]; then \
echo "Validating $$dir..."; \
python codegen/shared/validator.py "$$dir/entities.yml" || exit 1; \
fi \
done
@echo "✓ All schemas validated successfully"
# Generate code for all languages (specific version)
generate: generate-python generate-go generate-typescript
# Generate Python code
generate-python:
@if [ -z "$(VERSION)" ]; then \
echo "ERROR: VERSION is required. Usage: make generate-python VERSION=N"; \
exit 1; \
fi
@python codegen/python/generate.py $(VERSION)
# Generate Go code
generate-go:
@if [ -z "$(VERSION)" ]; then \
echo "ERROR: VERSION is required. Usage: make generate-go VERSION=N"; \
exit 1; \
fi
@python codegen/go/generate.py $(VERSION)
# Generate TypeScript code
generate-typescript:
@if [ -z "$(VERSION)" ]; then \
echo "ERROR: VERSION is required. Usage: make generate-typescript VERSION=N"; \
exit 1; \
fi
@python codegen/typescript/generate.py $(VERSION)
# Test specific version (Python package only)
test: test-python
# Test all versions
test-all:
@echo "Running tests for all versions..."
@for dir in v*/; do \
if [ -f "$$dir/entities.yml" ]; then \
version=$$(basename $$dir | sed 's/v//'); \
echo "Testing version $$version..."; \
$(MAKE) test VERSION=$$version || exit 1; \
fi \
done
@echo "✓ All version tests passed"
# Test Python package
test-python:
@if [ -z "$(VERSION)" ]; then \
echo "ERROR: VERSION is required. Usage: make test-python VERSION=N"; \
exit 1; \
fi
@echo "Testing Python package for version $(VERSION)..."
@cd v$(VERSION)/python && python -m pytest tests/ -v
# Clean generated files for specific version
clean:
@if [ -z "$(VERSION)" ]; then \
echo "ERROR: VERSION is required. Usage: make clean VERSION=N"; \
exit 1; \
fi
@echo "Cleaning generated files for version $(VERSION)..."
@rm -rf v$(VERSION)/python/pentagi_taxonomy
@rm -rf v$(VERSION)/go/entities
@rm -rf v$(VERSION)/typescript/src
@rm -rf v$(VERSION)/typescript/dist
@rm -rf v$(VERSION)/typescript/node_modules
@echo "✓ Cleaned version $(VERSION)"
# Clean all generated files
clean-all:
@echo "Cleaning all generated files..."
@for dir in v*/; do \
if [ -f "$$dir/entities.yml" ]; then \
version=$$(basename $$dir | sed 's/v//'); \
echo "Cleaning version $$version..."; \
$(MAKE) clean VERSION=$$version; \
fi \
done
@echo "✓ All generated files cleaned"
# Bump to new major version
bump-version:
@echo "Reading current version from version.yml..."
@current=$$(grep 'version:' version.yml | awk '{print $$2}'); \
new=$$((current + 1)); \
echo "Current version: $$current"; \
echo "New version: $$new"; \
echo ""; \
echo "Creating v$$new/ directory..."; \
mkdir -p v$$new; \
echo "Copying entities.yml from v$$current/ to v$$new/..."; \
cp v$$current/entities.yml v$$new/entities.yml; \
echo "Updating version field in v$$new/entities.yml..."; \
sed -i.bak "s/^version: $$current/version: $$new/" v$$new/entities.yml && rm v$$new/entities.yml.bak; \
echo "Updating version.yml to version $$new..."; \
echo "# Current global taxonomy version" > version.yml; \
echo "version: $$new" >> version.yml; \
echo ""; \
echo "✓ Created new version v$$new"; \
echo ""; \
echo "Next steps:"; \
echo " 1. Edit v$$new/entities.yml with your changes"; \
echo " 2. Run: make validate VERSION=$$new"; \
echo " 3. Run: make generate VERSION=$$new"; \
echo " 4. Commit the new version"