-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile
More file actions
271 lines (234 loc) · 8.41 KB
/
Makefile
File metadata and controls
271 lines (234 loc) · 8.41 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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
.PHONY: all format lint test test_integration lint_libs lint_apps format_libs format_apps test_libs test_apps test_integration_libs test_integration_apps unit integration dev build_devkits check_devkits publish_test_devkits publish_devkits release_test_devkits release_devkits help
# Default target executed when no arguments are given to make.
all: help
######################
# SHARED FUNCTIONS
######################
# Function to run tests for a package type
define run_tests
@echo "Testing $(1) packages..."
@failed=0; \
for dir in $(1)/*/; do \
if [ -d "$$dir/tests" ]; then \
echo "Testing $$dir..."; \
cd "$$dir" && uv run python -m pytest tests/unit/ || failed=1; \
cd - >/dev/null; \
fi \
done; \
if [ $$failed -eq 1 ]; then \
echo "❌ Some tests failed in $(1) packages"; \
exit 1; \
else \
echo "✅ All tests passed in $(1) packages"; \
fi
endef
# Function to run integration tests for a package type
define run_integration_tests
@echo "Running integration tests for $(1) packages..."
@failed=0; \
for dir in $(1)/*/; do \
if [ -d "$$dir/tests/integration" ]; then \
echo "Integration testing $$dir..."; \
cd "$$dir" && uv run python -m pytest tests/integration/ || failed=1; \
cd - >/dev/null; \
fi \
done; \
if [ $$failed -eq 1 ]; then \
echo "❌ Some integration tests failed in $(1) packages"; \
exit 1; \
else \
echo "✅ All integration tests passed in $(1) packages"; \
fi
endef
# Function to run linting for a package type
define run_lint
@echo "Linting $(1) packages..."
@for dir in $(1)/*/; do \
if [ -d "$$dir/src" ]; then \
echo "Linting $$dir..."; \
cd "$$dir" && \
uv run ruff check . && \
uv run ruff format src --diff && \
uv run ruff check --select I src && \
mkdir -p .mypy_cache && uv run mypy --strict src --cache-dir .mypy_cache; \
cd - >/dev/null; \
fi \
done
endef
# Function to run formatting for a package type
define run_format
@echo "Formatting $(1) packages..."
@for dir in $(1)/*/; do \
if [ -d "$$dir/src" ]; then \
echo "Formatting $$dir..."; \
cd "$$dir" && \
uv run ruff format src && \
uv run ruff check --select I --fix src; \
cd - >/dev/null; \
fi \
done
endef
######################
# TESTING
######################
# Run all unit tests in monorepo
test: test_libs test_apps
# Run all tests in monorepo (unit + integration)
test_all: test_libs test_apps test_integration_libs test_integration_apps
# Run all integration tests in monorepo
test_integration: test_integration_libs test_integration_apps
# Test specific package types
test_libs:
$(call run_tests,libs)
test_apps:
$(call run_tests,apps)
# Integration test specific package types
test_integration_libs:
$(call run_integration_tests,libs)
test_integration_apps:
$(call run_integration_tests,apps)
######################
# PARAMETERIZED TESTING
######################
# Parameterized test targets that accept app names
# Usage: make unit sample-agent, make integration sample-deep-agent
unit:
@if [ -z "$(filter-out $@,$(MAKECMDGOALS))" ]; then \
echo "Usage: make unit <app_name>"; \
echo "Example: make unit sample-agent"; \
exit 1; \
fi
@app_name=$(filter-out $@,$(MAKECMDGOALS)); \
if [ -d "apps/$$app_name" ]; then \
echo "Running unit tests for apps/$$app_name..."; \
cd "apps/$$app_name" && uv run python -m pytest tests/unit/ -v; \
else \
echo "❌ App 'apps/$$app_name' not found"; \
exit 1; \
fi
integration:
@if [ -z "$(filter-out $@,$(MAKECMDGOALS))" ]; then \
echo "Usage: make integration <app_name>"; \
echo "Example: make integration sample-agent"; \
exit 1; \
fi
@app_name=$(filter-out $@,$(MAKECMDGOALS)); \
if [ -d "apps/$$app_name" ]; then \
echo "Running integration tests for apps/$$app_name..."; \
cd "apps/$$app_name" && uv run python -m pytest tests/integration/ -v; \
else \
echo "❌ App 'apps/$$app_name' not found"; \
exit 1; \
fi
dev:
@goals="$(filter-out $@,$(MAKECMDGOALS))"; \
if [ -z "$$goals" ]; then \
echo "Usage: make dev <app_name> [-- args...]"; \
echo " or: ./scripts/dev.sh <app_name> [args...] (direct usage)"; \
echo "Example: make dev sample-agent"; \
echo "Example: make dev sample-agent -- --no-browser"; \
echo "Example: make dev sample-agent -- --host 0.0.0.0 --port 3000"; \
echo "Example: ./scripts/dev.sh sample-agent --no-browser"; \
exit 1; \
fi; \
case "$$goals" in \
*" -- "*) \
app_name=$${goals%% -- *}; \
dev_args=$${goals#* -- }; \
./scripts/dev.sh $$app_name $$dev_args; \
;; \
*) \
app_name="$$goals"; \
./scripts/dev.sh $$app_name; \
;; \
esac
# Dummy targets to prevent make from complaining about unknown targets
%:
@:
######################
# LINTING AND FORMATTING
######################
# Lint all packages
lint: lint_libs lint_apps
# Format all packages
format: format_libs format_apps
# Lint specific package types
lint_libs:
$(call run_lint,libs)
lint_apps:
$(call run_lint,apps)
# Format specific package types
format_libs:
$(call run_format,libs)
format_apps:
$(call run_format,apps)
######################
# PUBLISHING
######################
# Build distribution packages for langgraph-up-devkits
build_devkits:
@echo "Building langgraph-up-devkits distribution packages..."
@cd libs/langgraph-up-devkits && \
rm -rf dist/ build/ *.egg-info && \
uv run python -m build
@echo "✅ Build complete. Packages in libs/langgraph-up-devkits/dist/"
# Upload to Test PyPI
publish_test_devkits:
@echo "Uploading langgraph-up-devkits to Test PyPI..."
@cd libs/langgraph-up-devkits && \
uv run python -m twine upload --repository testpypi dist/*
@echo "✅ Uploaded to Test PyPI"
@echo "Install with: pip install --index-url https://test.pypi.org/simple/ langgraph-up-devkits"
# Upload to Production PyPI
publish_devkits:
@echo "⚠️ WARNING: About to publish to Production PyPI"
@echo "Press Ctrl+C to cancel, or Enter to continue..."
@read dummy
@cd libs/langgraph-up-devkits && \
uv run python -m twine upload dist/*
@echo "✅ Published to PyPI"
@echo "Install with: pip install langgraph-up-devkits"
# Build and publish to Test PyPI (convenience target)
release_test_devkits: build_devkits publish_test_devkits
# Build and publish to Production PyPI (convenience target)
release_devkits: build_devkits publish_devkits
# Check package before publishing
check_devkits:
@echo "Checking langgraph-up-devkits package..."
@cd libs/langgraph-up-devkits && \
uv run python -m twine check dist/*
@echo "✅ Package check complete"
######################
# HELP
######################
help:
@echo '----'
@echo 'MONOREPO COMMANDS:'
@echo 'test - run all unit tests (libs + apps)'
@echo 'test_all - run all tests: unit + integration (libs + apps)'
@echo 'test_integration - run all integration tests (libs + apps)'
@echo 'lint - run linters on all packages (libs + apps)'
@echo 'format - run formatters on all packages (libs + apps)'
@echo ''
@echo 'PACKAGE TYPE TARGETS:'
@echo 'test_libs - test libs/ packages only (unit tests)'
@echo 'test_apps - test apps/ packages only (unit tests)'
@echo 'test_integration_libs - integration test libs/ packages only'
@echo 'test_integration_apps - integration test apps/ packages only'
@echo 'lint_libs - lint libs/ packages only'
@echo 'lint_apps - lint apps/ packages only'
@echo 'format_libs - format libs/ packages only'
@echo 'format_apps - format apps/ packages only'
@echo ''
@echo 'PARAMETERIZED TARGETS:'
@echo 'make unit <app_name> - run unit tests for specific app (e.g., make unit sample-agent)'
@echo 'make integration <app_name> - run integration tests for specific app (e.g., make integration sample-agent)'
@echo 'make dev <app_name> [DEVARGS] - start LangGraph dev server (e.g., make dev sample-agent DEVARGS=\"--no-browser\")'
@echo ''
@echo 'PUBLISHING TARGETS:'
@echo 'build_devkits - build distribution packages for langgraph-up-devkits'
@echo 'check_devkits - check package validity with twine'
@echo 'publish_test_devkits - upload to Test PyPI (requires build first)'
@echo 'publish_devkits - upload to Production PyPI (requires build first, with confirmation)'
@echo 'release_test_devkits - build and publish to Test PyPI'
@echo 'release_devkits - build and publish to Production PyPI'