SHELL := /bin/bash
.SUFFIXES:
.DELETE_ON_ERROR:
.PHONY: all build test test-fast lint fmt fmt-check coverage coverage-open bench clean doc check ci examples book
all: test-fast lint
build:
cargo build
test-fast:
@echo "โก Running fast tests (target: <30s)..."
@if command -v cargo-nextest >/dev/null 2>&1; then \
time cargo nextest run --lib \
--status-level skip \
--failure-output immediate; \
else \
echo "๐ก Install cargo-nextest for faster tests: cargo install cargo-nextest"; \
time cargo test --lib; \
fi
@echo "โ
Fast tests passed"
test:
@echo "๐งช Running standard tests..."
@if command -v cargo-nextest >/dev/null 2>&1; then \
time cargo nextest run \
--status-level skip \
--failure-output immediate; \
else \
time cargo test; \
fi
@echo "โ
Standard tests passed"
lint:
cargo clippy -- -D warnings
fmt:
cargo fmt
fmt-check:
cargo fmt --check
coverage:
@echo "๐ Running coverage analysis (target: <5 min)..."
@echo "๐ Checking for cargo-llvm-cov and cargo-nextest..."
@which cargo-llvm-cov > /dev/null 2>&1 || (echo "๐ฆ Installing cargo-llvm-cov..." && cargo install cargo-llvm-cov --locked)
@which cargo-nextest > /dev/null 2>&1 || (echo "๐ฆ Installing cargo-nextest..." && cargo install cargo-nextest --locked)
@echo "๐งน Cleaning old coverage data..."
@mkdir -p target/coverage
@echo "๐งช Phase 1: Running tests with instrumentation (no report)..."
@cargo llvm-cov --no-report nextest --no-tests=warn --workspace --no-fail-fast --all-features
@echo "๐ Phase 2: Generating coverage reports..."
@cargo llvm-cov report --html --output-dir target/coverage/html
@cargo llvm-cov report --lcov --output-path target/coverage/lcov.info
@echo ""
@echo "๐ Coverage Summary:"
@echo "=================="
@cargo llvm-cov report --summary-only
@echo ""
@echo "๐ก Reports:"
@echo "- HTML: target/coverage/html/index.html"
@echo "- LCOV: target/coverage/lcov.info"
coverage-open:
@if [ -f target/coverage/html/index.html ]; then \
xdg-open target/coverage/html/index.html 2>/dev/null || \
open target/coverage/html/index.html 2>/dev/null || \
echo "Open: target/coverage/html/index.html"; \
else \
echo "โ Run 'make coverage' first"; \
fi
bench:
cargo bench
doc:
cargo doc --no-deps --open
clean:
cargo clean
rm -rf target/coverage/
check:
cargo check
ci: fmt-check lint test
@echo "โ
All CI checks passed!"
examples:
@for example in examples/*.rs; do \
name=$$(basename "$$example" .rs); \
echo "Running $$name..."; \
cargo run --example "$$name" --quiet 2>/dev/null || echo " โ ๏ธ $$name failed"; \
done
book:
@command -v mdbook >/dev/null 2>&1 || cargo install mdbook
cd book && mdbook build
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'