-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathMakefile
More file actions
113 lines (89 loc) · 4.38 KB
/
Copy pathMakefile
File metadata and controls
113 lines (89 loc) · 4.38 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
.PHONY: \
lock install check check-lock lint typecheck test \
check-contrib check-all build clean-build publish build-and-publish \
docs-test docs help
CORE_TY_PATHS = src tests
CONTRIB_DIRS = $(sort $(dir $(wildcard contrib/agentseek-*/pyproject.toml)))
contrib_name = $(patsubst contrib/agentseek-%,%,$(patsubst %/,%,$(1)))
CONTRIB_CHECKS = $(foreach dir,$(CONTRIB_DIRS),check-$(call contrib_name,$(dir)))
.PHONY: lock
lock: ## Update uv.lock against PyPI (ignore UV_INDEX_URL so lock stays canonical)
@echo "🚀 Updating lock file against PyPI"
@uv lock --default-index https://pypi.org/simple
.PHONY: install
install: ## Install the virtual environment and install the pre-commit hooks
@echo "🚀 Creating virtual environment using uv"
@uv sync --all-packages --all-extras --group plugins
@uv run pre-commit install
.PHONY: check
check: check-lock lint typecheck ## Run baseline code quality tools.
.PHONY: check-lock
check-lock:
@echo "🚀 Checking lock file consistency with 'pyproject.toml'"
@uv lock --locked
.PHONY: lint
lint:
@echo "🚀 Linting code: Running pre-commit"
@uv run pre-commit run -a
.PHONY: typecheck
typecheck: ## Run baseline static type checks.
@echo "🚀 Static type checking: Running ty"
@uv run ty check $(CORE_TY_PATHS)
.PHONY: test
test: ## Test the baseline code with pytest
@echo "🚀 Testing code: Running pytest"
@uv run python -m pytest --doctest-modules
define define_contrib_targets
.PHONY: typecheck-$(1) test-$(1) check-$(1)
typecheck-$(1): sync-contrib ## Run static type checks for the $(1) contrib package.
@dir="$(2)"; \
paths=$$$$(for path in src tests examples; do if [ -e "$$$$dir/$$$$path" ]; then printf '%s ' "$$$$dir/$$$$path"; fi; done); \
test -n "$$$$paths" || { echo "No typecheck paths found for $$$$dir" >&2; exit 1; }; \
echo "🚀 Static type checking: Running ty for $(1)"; \
uv run ty check $$$$paths
test-$(1): sync-contrib ## Run tests for the $(1) contrib package.
@dir="$(2)"; \
paths=$$$$(for path in tests src/tests; do if [ -e "$$$$dir/$$$$path" ]; then printf '%s ' "$$$$dir/$$$$path"; fi; done); \
test -n "$$$$paths" || { echo "No test paths found for $$$$dir" >&2; exit 1; }; \
echo "🚀 Testing code: Running pytest for $(1)"; \
uv run python -m pytest $$$$paths
check-$(1): typecheck-$(1) test-$(1) ## Run checks for the $(1) contrib package.
endef
$(foreach dir,$(CONTRIB_DIRS),$(eval $(call define_contrib_targets,$(call contrib_name,$(dir)),$(patsubst %/,%,$(dir)))))
.PHONY: sync-contrib
sync-contrib: ## Sync dependencies for all contrib packages.
@echo "🚀 Syncing dependencies for contrib packages"
@uv sync --all-packages --all-extras --group plugins
.PHONY: check-contrib
check-contrib: $(CONTRIB_CHECKS) ## Run checks for contrib packages.
.PHONY: check-all
check-all: check check-contrib ## Run baseline and contrib package checks.
.PHONY: build
build: clean-build ## Build wheel file
@echo "🚀 Creating wheel file"
@uvx --from build pyproject-build --installer uv
.PHONY: clean-build
clean-build: ## Clean build artifacts
@echo "🚀 Removing build artifacts"
@uv run python -c "import shutil; import os; shutil.rmtree('dist') if os.path.exists('dist') else None"
.PHONY: publish
publish: ## Publish a release to PyPI.
@echo "🚀 Publishing."
@uvx twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
.PHONY: build-and-publish
build-and-publish: build publish ## Build and publish.
.PHONY: docs-test
docs-test: ## Test if documentation can be built without warnings or errors
@uv run mkdocs build -s
.PHONY: docs
docs: ## Build and serve the documentation
@uv run mkdocs serve
.PHONY: help
help:
@uv run python -c "import re; \
entries = []; \
seen = set(); \
[entries.extend(re.findall(r'^([a-zA-Z0-9_-]+):.*?## (.*)$$', open(makefile).read(), re.M)) for makefile in '$(MAKEFILE_LIST)'.strip().split()]; \
[entries.append((f'{prefix}-{directory.removeprefix(\"contrib/agentseek-\").removesuffix(\"/\")}', template.format(name=directory.removeprefix('contrib/agentseek-').removesuffix('/')))) for directory in '$(CONTRIB_DIRS)'.split() for prefix, template in [('typecheck', 'Run static type checks for the {name} contrib package.'), ('test', 'Run tests for the {name} contrib package.'), ('check', 'Run checks for the {name} contrib package.')]]; \
[(seen.add(target), print(f'\033[36m{target:<20}\033[0m {description}')) for target, description in entries if target not in seen]"
.DEFAULT_GOAL := help