-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathMakefile
More file actions
181 lines (139 loc) · 5.37 KB
/
Makefile
File metadata and controls
181 lines (139 loc) · 5.37 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
.PHONY: build test lint fmt check bench clean install-deps doc
.PHONY: build-llvm test-llvm check-llvm
# Default target
all: check test
# Build all crates
build:
cargo build --workspace
# Build in release mode
build-release:
cargo build --workspace --release
# macOS: build/test using LLVM lld for faster linking (requires ld64.lld on PATH)
check-llvm:
@if [ "$$(uname -s)" != "Darwin" ]; then echo "check-llvm is macOS-only"; exit 1; fi
@if ! command -v ld64.lld >/dev/null 2>&1; then echo "Missing ld64.lld (install LLVM and add it to PATH)"; exit 1; fi
build-llvm: check-llvm
RUSTFLAGS="-C link-arg=-fuse-ld=lld" cargo build --workspace
test-llvm: check-llvm
RUSTFLAGS="-C link-arg=-fuse-ld=lld" cargo test --workspace
# Build MCP server with AutoAgents experimental feature
build-mcp-autoagents:
LIBRARY_PATH=/opt/homebrew/lib:$$LIBRARY_PATH cargo build --release -p codegraph-mcp --bin codegraph --features "ai-enhanced,autoagents-experimental,embeddings-ollama,embeddings-lmstudio,codegraph-ai/anthropic,codegraph-ai/openai-llm,codegraph-ai/openai-compatible"
# Build MCP HTTP server with experimental HTTP transport
.PHONY: build-mcp-http
build-mcp-http:
cargo build --release -p codegraph-mcp --bin codegraph --features "ai-enhanced,autoagents-experimental,embeddings-ollama,embeddings-lmstudio,server-http"
# Run HTTP server (depends on build)
.PHONY: run-http-server
run-http-server: build-mcp-http
./target/release/codegraph start http --port 3000
# Build API with size-optimized profile and strip/compress
build-api-size:
cargo build --profile release-size --bin codegraph-api
./scripts/strip_compress.sh target/release-size/codegraph-api
size:
@echo "Sizes for codegraph-api binaries (if present):"
@for p in target/release/codegraph-api target/release-size/codegraph-api; do \
if [ -f $$p ]; then echo "$$p: $$(du -h $$p | cut -f1)"; fi; \
done
# Run all tests
test:
cargo test --workspace
# Run tests with coverage (requires cargo-tarpaulin)
test-coverage:
cargo tarpaulin --workspace --out Html
# Lint with clippy
lint:
# Limit clippy to default member(s) to avoid compiling experimental crates
cargo clippy -p codegraph-core -- -A clippy::all -A warnings
# Format code
fmt:
cargo fmt --all
# Check formatting
fmt-check:
cargo fmt --all -- --check
# Full check (format, lint, test)
check: fmt lint test
# Run benchmarks
bench:
@echo "Running benchmarks and saving baseline: $${BASELINE_NAME:-baseline} (ENABLE_FAISS_BENCH=$${ENABLE_FAISS_BENCH:-0})"
BASELINE_NAME=$${BASELINE_NAME:-baseline} ENABLE_FAISS_BENCH=$${ENABLE_FAISS_BENCH:-0} scripts/run_benchmarks.sh
bench-report:
@echo "Generating benchmark report from latest results"
python3 scripts/generate_bench_report.py --output benchmarks/reports/benchmark_report_latest.md
bench-compare:
@echo "Comparing current benchmark results to baseline: $${BASELINE_NAME:-baseline}"
python3 scripts/compare_bench.py --baseline $${BASELINE_NAME:-baseline} --threshold $${THRESHOLD:-0.10}
# Clean build artifacts
clean:
cargo clean
# Install development dependencies
install-deps:
cargo install cargo-tarpaulin
cargo install cargo-audit
cargo install cargo-outdated
# Generate documentation
doc:
cargo doc --workspace --no-deps --open
# Security audit
audit:
cargo audit
# Check for outdated dependencies
outdated:
cargo outdated --workspace
# Run the API server
run-api:
RUST_LOG=debug cargo run --bin codegraph-api
# Sync validation stress tests (standalone harness)
sync-validate:
cargo run --manifest-path high_perf_test/Cargo.toml
# Development workflow
dev: fmt lint test
# CI workflow
ci: fmt-check lint test
# Quick check without tests
quick: fmt lint
# Run API E2E/integration tests (API crate)
e2e:
cargo test -p codegraph-api -- --nocapture
# Load testing using k6 (requires k6 installed)
load-test:
BASE_URL=$${BASE_URL:-http://localhost:3000} scripts/load/run.sh
# Deployment validation against a running endpoint
deploy-validate:
BASE_URL=$${BASE_URL:-http://localhost:3000} scripts/deploy/validate.sh
# Performance regression check (Criterion benches vs baseline)
perf-regression:
BASELINE_NAME=$${BASELINE_NAME:-baseline} THRESHOLD=$${THRESHOLD:-0.10} scripts/perf/regression.sh
# Cross-platform build (local)
build-cross:
@echo "Building release binaries for Linux, macOS, Windows targets"
bash scripts/build_cross.sh
# Build and run specific examples
example-parse:
cargo run --bin codegraph-api &
sleep 2
curl -X POST http://localhost:3000/parse \
-H "Content-Type: application/json" \
-d '{"file_path": "src/main.rs"}'
pkill -f codegraph-api
# ===================== Memory Safety / Leak Detection =====================
# Run API with leak detection enabled (feature-gated)
run-api-leaks:
RUST_LOG=debug cargo run --bin codegraph-api --features leak-detect
# Export on-demand leak report to target/memory_reports
leak-report:
curl -s http://localhost:3000/memory/leaks | jq .
# View runtime memory stats (requires leak-detect)
leak-stats:
curl -s http://localhost:3000/memory/stats | jq .
# Run tests under Miri (requires nightly toolchain + miri component)
miri:
rustup toolchain install nightly --component miri || true
cargo +nightly miri test --workspace
# Run tests with Address/Leak Sanitizer (requires nightly)
asan-test:
rustup toolchain install nightly || true
RUSTFLAGS="-Zsanitizer=address" \
RUSTDOCFLAGS="-Zsanitizer=address" \
cargo +nightly test --workspace -Zbuild-std --target x86_64-apple-darwin