.PHONY: help pre-commit ci-validate test-fast test-all lint lint-fast lint-full build run clean
.PHONY: coverage coverage-summary coverage-open coverage-ci coverage-clean coverage-report
help:
@echo "๐ Available targets:"
@echo ""
@echo "Development Workflow:"
@echo " make pre-commit - Fast pre-commit checks (<30s)"
@echo " make test-fast - Quick unit tests (<5 min)"
@echo " make test-all - All tests including integration"
@echo ""
@echo "Coverage (Toyota Way: 'make coverage' just works):"
@echo " make coverage - Generate HTML coverage report (<10min)"
@echo " make coverage-open - Open HTML coverage in browser"
@echo " make coverage-summary - Show coverage summary only"
@echo " make coverage-ci - Generate LCOV for CI/CD (fast mode)"
@echo " make coverage-clean - Clean coverage artifacts"
@echo ""
@echo "Quality & Linting:"
@echo " make lint - Quick lint check (alias for lint-fast)"
@echo " make lint-fast - Quick lint check"
@echo " make lint-full - Full lint with all features"
@echo " make ci-validate - Full CI validation pipeline"
@echo ""
@echo "Build & Run:"
@echo " make build - Build release binary"
@echo " make run - Run the CLI tool"
@echo " make clean - Clean build artifacts"
pre-commit: fmt-check lint-fast
@echo "๐งช Running fast tests..."
@cargo test --lib --bins --quiet
@echo "โ
Pre-commit checks passed (fast feedback)"
ci-validate: lint-full test-all coverage-ci
@echo "โ
All CI quality gates passed"
@echo "๐ Review coverage report: lcov.info"
fmt-check:
@echo "๐จ Checking code formatting..."
@cargo fmt --check
lint: lint-fast
lint-fast:
@echo "๐ Running quick lint..."
@cargo clippy --all-targets -- -D warnings
lint-full: fmt-check
@echo "๐ Running comprehensive lint..."
@cargo clippy --all-targets --all-features -- -D warnings -D clippy::pedantic
test-fast:
@echo "๐งช Running fast test suite..."
@cargo test --quiet --lib --bins
test-all:
@echo "๐งช Running all tests..."
@cargo test --all-features --workspace
coverage:
@echo "๐ Running comprehensive test coverage analysis (target: <10 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..."
@cargo llvm-cov clean --workspace
@mkdir -p target/coverage
@echo "โ๏ธ Temporarily disabling global cargo config (mold breaks coverage)..."
@test -f ~/.cargo/config.toml && mv ~/.cargo/config.toml ~/.cargo/config.toml.cov-backup || true
@echo "๐งช Phase 1: Running tests with instrumentation (no report)..."
@cargo llvm-cov --no-report nextest --no-tests=warn --all-features --workspace
@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 "๐ก COVERAGE INSIGHTS:"
@echo "- HTML report: target/coverage/html/index.html"
@echo "- LCOV file: target/coverage/lcov.info"
@echo "- Open HTML: make coverage-open"
@echo ""
coverage-summary:
@cargo llvm-cov report --summary-only 2>/dev/null || echo "Run 'make coverage' first"
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 "Please open: target/coverage/html/index.html"; \
else \
echo "โ Run 'make coverage' first to generate the HTML report"; \
fi
coverage-ci:
@echo "=== Code Coverage for CI/CD ==="
@echo "Phase 1: Running tests with instrumentation..."
@cargo llvm-cov clean --workspace
@cargo llvm-cov --no-report nextest --no-tests=warn --all-features --workspace
@echo "Phase 2: Generating LCOV report..."
@cargo llvm-cov report --lcov --output-path lcov.info
@echo "โ Coverage report generated: lcov.info"
coverage-clean:
@cargo llvm-cov clean --workspace
@rm -f lcov.info coverage.xml target/coverage/lcov.info
@rm -rf target/llvm-cov target/coverage
@find . -name "*.profraw" -delete
@echo "โ Coverage artifacts cleaned"
coverage-report: coverage
@echo "๐ก Use 'make coverage' directly (this is an alias)"
build:
@echo "๐จ Building release binary..."
@cargo build --release
@echo "โ
Binary available at target/release/oip"
run:
@cargo run --
clean:
@echo "๐งน Cleaning build artifacts..."
@cargo clean
@echo "โ
Clean complete"
test-makefile:
@echo "๐งช Testing Makefile targets..."
@echo " โ make help works"
@$(MAKE) help > /dev/null
@echo " โ make fmt-check (dry run)"
@echo " โ make lint-fast (dry run)"
@echo "โ
Makefile validation passed"