-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (74 loc) · 3.1 KB
/
Makefile
File metadata and controls
84 lines (74 loc) · 3.1 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
.PHONY: lint lint-check lint-examples lint-examples-check lint-all lint-check-all help
EXAMPLE_DIRS := examples
# Ensure venv uses pyenv-managed Python when available
define ENSURE_PYENV_VENV
if command -v pyenv >/dev/null 2>&1; then \
uv venv --python "$$(pyenv which python)" --allow-existing; \
else \
uv venv --allow-existing; \
fi
endef
help:
@echo "Available targets:"
@echo " lint - Formats python code in ak-py"
@echo " lint-check - Dry run to check code formatting in ak-py"
@echo " lint-examples - Formats python code in examples directory"
@echo " lint-examples-check - Dry run to check code formatting in examples"
@echo " lint-all - Formats python code in both ak-py and examples"
@echo " lint-check-all - Dry run to check code formatting in both ak-py and examples"
@echo " help - Show this help message"
lint: lint-fix
lint-fix:
@cd ak-py && $(ENSURE_PYENV_VENV)
@echo "Sorting imports with isort..."
cd ak-py && uv run --dev isort --skip src/agentkernel/core/__init__.py ./src ./tests
@echo "Formatting ak-py code with black..."
cd ak-py && uv run --dev black ./src ./tests
lint-check:
@cd ak-py && $(ENSURE_PYENV_VENV)
@echo "Checking import sorting with isort..."
@EXIT_CODE=0; \
(cd ak-py && uv run --dev isort --skip src/agentkernel/core/__init__.py --check-only ./src ./tests) || EXIT_CODE=$$?; \
echo "Checking ak-py code formatting with black..."; \
(cd ak-py && uv run --dev black --check ./src ./tests) || EXIT_CODE=$$?; \
if [ $$EXIT_CODE -ne 0 ]; then \
echo "❌ Linting errors found in ak-py!"; \
fi; \
exit $$EXIT_CODE
lint-examples:
@echo "Building ak-py to ensure dependencies are installed..."
cd ak-py && ./build.sh
@echo "Formatting examples..."
@for dir in $$(find $(EXAMPLE_DIRS) -maxdepth 4 -name "pyproject.toml" -type f | sed 's|/pyproject.toml||' | sort); do \
echo "Processing $$dir..."; \
if [ -f "$$dir/pyproject.toml" ]; then \
cd $$dir && \
$(ENSURE_PYENV_VENV) && \
uv run --dev isort --skip .venv --skip .terraform --skip dist --skip __pycache__ . || true; \
uv run --dev black --exclude '/\.venv/|/\.terraform/|/dist/|/__pycache__/' . || true; \
cd - > /dev/null; \
fi; \
done
lint-examples-check:
@echo "Building ak-py to ensure dependencies are installed..."
cd ak-py && ./build.sh
@echo "Checking examples formatting..."
@EXIT_CODE=0; \
for dir in $$(find $(EXAMPLE_DIRS) -maxdepth 4 -name "pyproject.toml" -type f | sed 's|/pyproject.toml||' | sort); do \
echo "Checking $$dir..."; \
if [ -f "$$dir/pyproject.toml" ]; then \
cd $$dir && \
$(ENSURE_PYENV_VENV) && \
uv run --dev isort --check-only --skip .venv --skip .terraform --skip dist --skip __pycache__ . || EXIT_CODE=1; \
uv run --dev black --check --exclude '/\.venv/|/\.terraform/|/dist/|/__pycache__/' . || EXIT_CODE=1; \
cd - > /dev/null; \
fi; \
done; \
if [ $$EXIT_CODE -ne 0 ]; then \
echo "❌ Linting errors found in examples!"; \
fi; \
exit $$EXIT_CODE
lint-all: lint lint-examples
@echo "All linting completed!"
lint-check-all: lint-check lint-examples-check
@echo "All lint checks completed!"