SHELL := /bin/bash
.SUFFIXES:
.DELETE_ON_ERROR:
.ONESHELL:
.PHONY: all build test test-fast test-full lint fmt fmt-check clean doc bench coverage coverage-open tier1 tier2 tier3 check book book-build book-serve examples
all: tier2
build:
cargo build --release
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 (target: <2min)..."
@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"
test-full:
@echo "๐ฌ Running full comprehensive tests..."
@if command -v cargo-nextest >/dev/null 2>&1; then \
time cargo nextest run --all-features; \
else \
time cargo test --all-features; \
fi
@echo "โ
Full tests passed"
lint:
cargo clippy -- -D warnings
fmt:
cargo fmt
fmt-check:
cargo fmt --check
clean:
cargo clean
doc:
cargo doc --no-deps --open
bench:
cargo bench
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 "โ๏ธ Temporarily disabling global cargo config (sccache/mold break coverage)..."
@test -f ~/.cargo/config.toml && mv ~/.cargo/config.toml ~/.cargo/config.toml.cov-backup || true
@echo "๐งน Cleaning old coverage data..."
@cargo llvm-cov clean --workspace
@mkdir -p target/coverage
@echo "๐งช Phase 1: Running tests with instrumentation (no report)..."
@cargo llvm-cov --no-report nextest --no-tests=warn --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 "โ๏ธ Restoring global cargo config..."
@test -f ~/.cargo/config.toml.cov-backup && mv ~/.cargo/config.toml.cov-backup ~/.cargo/config.toml || true
@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
tier1:
@echo "Running Tier 1: Fast feedback..."
@cargo fmt --check
@cargo clippy -- -W clippy::all
@cargo check
@echo "โ
Tier 1: PASSED"
tier2:
@echo "Running Tier 2: Pre-commit checks..."
@cargo test --lib
@cargo clippy -- -D warnings
@echo "โ
Tier 2: PASSED"
tier3:
@echo "Running Tier 3: Full validation..."
@cargo test --all
@cargo clippy -- -D warnings
@echo "โ
Tier 3: PASSED"
check:
cargo check --all
book: book-build
book-build:
@echo "๐ Building Pacha book..."
@if command -v mdbook >/dev/null 2>&1; then \
mdbook build book; \
echo "โ
Book built: book/book/index.html"; \
else \
echo "โ mdbook not found. Install with: cargo install mdbook"; \
exit 1; \
fi
book-serve:
@echo "๐ Serving book at http://localhost:3000..."
@mdbook serve book --open
examples:
@echo "๐ฏ Running all examples..."
@for example in examples/*.rs; do \
name=$$(basename "$$example" .rs); \
echo " Running $$name..."; \
cargo run --example "$$name" --quiet 2>/dev/null && echo " โ
$$name passed" || echo " โ $$name failed"; \
done
@echo "โ
All examples complete"