.PHONY: help test test-fast test-unit test-integration coverage coverage-check build clean lint fmt check pre-commit examples tdg wasm wasm-release wasm-test docker docker-dev docker-test docker-clean book book-serve book-watch
help:
@echo "Batuta - Sovereign AI Stack Orchestrator"
@echo ""
@echo "EXTREME TDD Targets (time constraints):"
@echo " make test-fast - Fast tests (< 5 min) [current: ~0.3s]"
@echo " make pre-commit - Pre-commit tests (< 30 sec) [current: ~0.3s]"
@echo " make coverage - Coverage report (โฅ90% required, <10 min)"
@echo " make coverage-check - Enforce 90% threshold (BLOCKS on failure)"
@echo ""
@echo "Development Targets:"
@echo " make test - Run all tests"
@echo " make test-unit - Run unit tests only"
@echo " make test-integration - Run integration tests only"
@echo " make lint - Run clippy lints"
@echo " make fmt - Format code"
@echo " make check - Type check without building"
@echo " make build - Build debug binary"
@echo " make release - Build release binary"
@echo " make examples - Run all examples"
@echo " make tdg - Calculate TDG score"
@echo " make clean - Clean build artifacts"
@echo ""
@echo "WASM Targets:"
@echo " make wasm - Build WASM (debug)"
@echo " make wasm-release - Build WASM (optimized)"
@echo " make wasm-test - Test WASM build"
@echo ""
@echo "Docker Targets:"
@echo " make docker - Build production Docker image"
@echo " make docker-dev - Build development Docker image"
@echo " make docker-test - Run tests in Docker"
@echo " make docker-clean - Clean Docker images and volumes"
@echo ""
@echo "Documentation Targets:"
@echo " make book - Build The Batuta Book (mdBook)"
@echo " make book-serve - Build and serve book locally"
@echo " make book-watch - Watch and rebuild book on changes"
@echo ""
@echo "Quality Gates:"
@echo " make quality - Run all quality checks"
pre-commit: lint test-fast
@echo "โ
Pre-commit checks passed (< 30s)"
test-fast:
@echo "๐ Running fast test suite..."
@time cargo test --quiet --all
@echo "โ
Fast tests completed"
coverage:
@echo "๐ Generating coverage report (target: โฅ90% for ALL code, <10 min)..."
@command -v cargo-llvm-cov >/dev/null 2>&1 || { echo "Installing cargo-llvm-cov..."; cargo install cargo-llvm-cov; }
@cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
@cargo llvm-cov report --html --output-dir target/llvm-cov/html
@echo "โ
Coverage report: target/llvm-cov/html/index.html"
@echo ""
@echo "๐ Coverage Summary:"
@cargo llvm-cov report | grep TOTAL
@echo ""
@COVERAGE=$$(cargo llvm-cov report --summary-only 2>/dev/null | grep "TOTAL" | awk '{print $$NF}' | sed 's/%//' || echo "0"); \
if [ -n "$$COVERAGE" ]; then \
echo "Overall coverage: $$COVERAGE%"; \
if [ $$(echo "$$COVERAGE < 90" | bc 2>/dev/null || echo 1) -eq 1 ]; then \
echo "โ ๏ธ Below 90% minimum target (prefer 95%)"; \
elif [ $$(echo "$$COVERAGE >= 95" | bc 2>/dev/null || echo 0) -eq 1 ]; then \
echo "โ
Excellent coverage (โฅ95%)"; \
else \
echo "โ
Good coverage (โฅ90%)"; \
fi; \
fi
coverage-check:
@echo "๐ Enforcing 90% coverage threshold (BLOCKS on failure)..."
@command -v cargo-llvm-cov >/dev/null 2>&1 || { echo "Installing cargo-llvm-cov..."; cargo install cargo-llvm-cov; }
@cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info > /dev/null 2>&1
@COVERAGE=$$(cargo llvm-cov report --summary-only 2>/dev/null | grep "TOTAL" | awk '{print $$NF}' | sed 's/%//' || echo "0"); \
echo "Overall coverage: $$COVERAGE%"; \
if [ $$(echo "$$COVERAGE < 90" | bc 2>/dev/null || echo 1) -eq 1 ]; then \
echo "โ FAIL: Coverage ($$COVERAGE%) below 90% minimum"; \
echo "Target: 90% minimum, 95% preferred"; \
exit 1; \
else \
echo "โ
PASS: Coverage threshold met (โฅ90%)"; \
fi
test:
cargo test --all
test-unit:
cargo test --lib
test-integration:
cargo test --test '*'
lint:
cargo clippy --all-targets --all-features -- -D warnings
fmt:
cargo fmt --all
check:
cargo check --all-targets --all-features
build:
cargo build
release:
cargo build --release --locked
examples:
@echo "๐ฏ Backend Selection Demo"
@cargo run --example backend_selection --quiet
@echo ""
@echo "๐ Pipeline Demo"
@cargo run --example pipeline_demo --quiet
tdg:
@command -v pmat >/dev/null 2>&1 || { echo "Error: pmat not installed"; exit 1; }
pmat tdg src/
quality: lint test coverage-check tdg
@echo "โ
All quality gates passed (including 90% coverage enforcement)"
clean:
cargo clean
rm -rf target/
rm -f .batuta-state.json
install:
cargo install --path .
watch:
cargo watch -x check -x test -x run
mutants:
@command -v cargo-mutants >/dev/null 2>&1 || { echo "Installing cargo-mutants..."; cargo install cargo-mutants; }
cargo mutants --timeout 300
bench:
cargo bench
docs:
cargo doc --no-deps --open
pr-ready: fmt lint test coverage
@echo "โ
Ready for PR submission"
wasm:
@echo "๐ Building Batuta for WebAssembly (debug)..."
./scripts/build-wasm.sh debug
wasm-release:
@echo "๐ Building Batuta for WebAssembly (release)..."
./scripts/build-wasm.sh release
wasm-test:
@echo "๐งช Testing WASM build..."
cargo test --target wasm32-unknown-unknown --no-default-features --features wasm --lib
docker:
@echo "๐ณ Building production Docker image..."
./scripts/docker-build.sh prod
docker-dev:
@echo "๐ณ Building development Docker image..."
./scripts/docker-build.sh dev
docker-test:
@echo "๐งช Running tests in Docker..."
docker-compose up --abort-on-container-exit ci
docker-clean:
@echo "๐งน Cleaning Docker images and volumes..."
docker-compose down -v
docker rmi batuta:latest batuta:dev batuta:ci 2>/dev/null || true
@echo "โ
Docker cleanup complete"
book:
@echo "๐ Building The Batuta Book..."
@command -v mdbook >/dev/null 2>&1 || { echo "Error: mdbook not installed. Install with: cargo install mdbook"; exit 1; }
mdbook build book
@echo "โ
Book built: book/book/index.html"
book-serve:
@echo "๐ Serving The Batuta Book..."
@command -v mdbook >/dev/null 2>&1 || { echo "Error: mdbook not installed. Install with: cargo install mdbook"; exit 1; }
@echo "Open http://localhost:3000 in your browser"
mdbook serve book --open
book-watch:
@echo "๐ Watching The Batuta Book..."
@command -v mdbook >/dev/null 2>&1 || { echo "Error: mdbook not installed. Install with: cargo install mdbook"; exit 1; }
mdbook watch book