-
Notifications
You must be signed in to change notification settings - Fork 595
Expand file tree
/
Copy pathMakefile
More file actions
155 lines (132 loc) · 5.57 KB
/
Copy pathMakefile
File metadata and controls
155 lines (132 loc) · 5.57 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
.PHONY: help install install-dev langgraph-dev test test-unit test-provider openai anthropic nv_build test-integration test-cov test-ci lint lint-fix format format-check clean build docker-build docker-smoke
# Prefer uv if available, else use pip (set when Makefile is parsed)
UV := $(shell command -v uv 2>/dev/null)
# LangGraph Studio URL for `make langgraph-dev`. Defaults to the hosted
# LangSmith UI. Override per invocation with:
# make langgraph-dev LANGGRAPH_STUDIO_URL=https://your-studio.example
LANGGRAPH_STUDIO_URL = https://smith.langchain.com
PROVIDER_TEST_SELECTION := $(filter openai anthropic nv_build,$(MAKECMDGOALS))
ifneq ($(PROVIDER_TEST_SELECTION),)
PROVIDER_TEST_PROVIDERS := $(PROVIDER_TEST_SELECTION)
PROVIDER_TEST_TARGETS :=
ifneq ($(filter openai,$(PROVIDER_TEST_SELECTION)),)
PROVIDER_TEST_TARGETS += tests/provider/test_provider_endpoint.py::test_openai_provider_makes_live_structured_request
endif
ifneq ($(filter anthropic,$(PROVIDER_TEST_SELECTION)),)
PROVIDER_TEST_TARGETS += tests/provider/test_provider_endpoint.py::test_anthropic_provider_makes_live_structured_request
endif
ifneq ($(filter nv_build,$(PROVIDER_TEST_SELECTION)),)
PROVIDER_TEST_TARGETS += tests/provider/test_provider_endpoint.py::test_nv_build_provider_makes_live_structured_request
endif
else
PROVIDER_TEST_PROVIDERS := openai anthropic nv_build
PROVIDER_TEST_TARGETS := tests/provider
endif
# Default target. All targets assume the virtual env is already created and activated.
help:
@echo "Available targets (venv must be created and activated first):"
@echo " make install - Install the package (uses uv if available, else pip)"
@echo " make install-dev - Install with dev dependencies (uses uv if available, else pip)"
@echo " make langgraph-dev - Run LangGraph dev server (Studio at \$$LANGGRAPH_STUDIO_URL)"
@echo " make test - Run unit + integration tests"
@echo " make test-unit - Run unit tests only (no LLM calls)"
@echo " make test-provider [openai|anthropic|nv_build] - Run live provider tests"
@echo " make test-integration - Run integration tests only (invokes full graph, may call LLMs)"
@echo " make test-cov - Run tests with coverage report"
@echo " make lint - Run linters (ruff only)"
@echo " make lint-fix - Auto-fix lint errors with ruff"
@echo " make format - Format code with ruff"
@echo " make format-check - Check code formatting with ruff"
@echo " make clean - Remove build artifacts and cache files"
@echo " make build - Build the package"
@echo " make docker-build - Build the Docker image"
@echo " make docker-smoke - Build and smoke test the Docker image"
install:
@if [ -n "$(UV)" ]; then uv sync; else pip install -e .; fi
install-dev:
@if [ -n "$(UV)" ]; then uv sync --all-extras; else pip install -e ".[dev]"; fi
# Run LangGraph dev server, opening Studio at LANGGRAPH_STUDIO_URL.
langgraph-dev:
langgraph dev --studio-url $(LANGGRAPH_STUDIO_URL)
# Run unit + integration tests
test: test-unit test-integration
# Run unit tests only (excludes provider and integration markers)
test-unit:
pytest -m "not integration and not provider" tests/
# Run live provider tests (requires provider-specific API keys)
test-provider:
@missing_keys=0; \
if [ -n "$${PROVIDER_TEST_MISSING_KEYS_FILE:-}" ]; then \
rm -f "$$PROVIDER_TEST_MISSING_KEYS_FILE"; \
fi; \
for provider in $(PROVIDER_TEST_PROVIDERS); do \
case "$$provider" in \
openai) env_name=OPENAI_API_KEY; label=OpenAI ;; \
anthropic) env_name=ANTHROPIC_API_KEY; label=Anthropic ;; \
nv_build) env_name=NVIDIA_INFERENCE_KEY; label="NV Build" ;; \
esac; \
eval "value=\$${$${env_name}:-}"; \
if [ -z "$$value" ]; then \
echo "WARNING: $$env_name is not set; $$label provider test will be skipped"; \
missing_keys=1; \
fi; \
done; \
pytest -m provider $(PROVIDER_TEST_TARGETS); \
pytest_status=$$?; \
if [ "$$pytest_status" -ne 0 ]; then \
exit "$$pytest_status"; \
fi; \
if [ "$$missing_keys" -ne 0 ] && [ -n "$${PROVIDER_TEST_MISSING_KEYS_FILE:-}" ]; then \
printf "missing provider keys\n" > "$$PROVIDER_TEST_MISSING_KEYS_FILE"; \
fi
openai anthropic nv_build:
@:
# Run integration tests only (invokes full graph, may call LLMs)
test-integration:
pytest -m integration tests/
# Run tests with coverage
test-cov:
pytest -m "not integration and not provider" --cov=src/skillspector --cov-report=html --cov-report=term-missing tests/
# Run tests with coverage for CI (Cobertura XML + terminal)
test-ci:
pytest -m "not integration and not provider" --cov=src/skillspector --cov-report=term-missing --cov-report=xml tests/
# Run linters (fast: ruff only)
lint:
@echo "Running ruff..."
ruff check src/ tests/
# Auto-fix lint errors with ruff
lint-fix:
@echo "Running ruff with auto-fix..."
ruff check --fix src/ tests/
# Format code
format:
@echo "Formatting with ruff..."
ruff check --fix src/ tests/
ruff format src/ tests/
# Check code formatting without modifying files
format-check:
@echo "Checking formatting with ruff..."
ruff format --check src/ tests/
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
rm -rf build/
rm -rf dist/
rm -rf src/*.egg-info
rm -rf .pytest_cache/
rm -rf .ruff_cache/
rm -rf .mypy_cache/
rm -rf htmlcov/
rm -rf .coverage
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
@echo "Clean complete!"
# Build the package
build: clean
python -m build
# Build the Docker image
docker-build:
docker build -t skillspector .
# Build and smoke test the Docker image
docker-smoke: docker-build
tests/docker/smoke.sh