.PHONY: help pre-commit ci-validate test-fast test-all lint lint-fast lint-full build run clean
.PHONY: coverage coverage-summary coverage-check coverage-open coverage-ci coverage-clean coverage-report
.PHONY: wasm wasm-build wasm-test wasm-serve wasm-clean viz viz-test
.PHONY: e2e e2e-install e2e-test e2e-headed e2e-ui e2e-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"
@echo ""
@echo "WebAssembly (Browser):"
@echo " make wasm - Build WASM package (alias for wasm-build)"
@echo " make wasm-build - Build optimized WASM package"
@echo " make wasm-test - Run WASM module tests"
@echo " make wasm-serve - Serve WASM demo (ruchy preferred, port 7777)"
@echo " make wasm-clean - Clean WASM build artifacts"
@echo ""
@echo "Visualization:"
@echo " make viz - Build with visualization feature"
@echo " make viz-test - Test visualization module"
@echo ""
@echo "E2E Testing (Playwright):"
@echo " make e2e-install - Install Playwright and browsers"
@echo " make e2e - Build WASM and run e2e tests"
@echo " make e2e-headed - Run e2e tests with browser visible"
@echo " make e2e-ui - Open Playwright interactive UI"
@echo " make e2e-report - Open HTML test report"
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..."
@mkdir -p target/coverage
@echo "๐งช Phase 1: Running tests with instrumentation (no report)..."
@cargo llvm-cov --no-report --ignore-filename-regex "(alimentar/|gpu_|main\.rs)" nextest --no-tests=warn --lib --bins
@echo "๐ Phase 2: Generating coverage reports..."
@cargo llvm-cov report --ignore-filename-regex "(alimentar/|gpu_|main\.rs)" --html --output-dir target/coverage/html
@cargo llvm-cov report --ignore-filename-regex "(alimentar/|gpu_|main\.rs)" --lcov --output-path target/coverage/lcov.info
@echo ""
@echo "๐ Coverage Summary:"
@echo "=================="
@cargo llvm-cov report --ignore-filename-regex "(alimentar/|gpu_|main\.rs)" --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-check:
@echo "๐ Checking coverage threshold (minimum 90%)..."
@command -v cargo-llvm-cov > /dev/null || (echo "๐ฆ Installing cargo-llvm-cov..." && cargo install cargo-llvm-cov --locked)
@echo " Running tests with coverage instrumentation..."
@COVERAGE_OUTPUT=$$(cargo llvm-cov --ignore-filename-regex "(alimentar/|gpu_|main\.rs)" nextest --no-tests=warn --lib --bins 2>&1); \
COVERAGE=$$(echo "$$COVERAGE_OUTPUT" | grep "^TOTAL" | awk '{print $$10}' | tr -d '%'); \
echo " Line coverage: $${COVERAGE}%"; \
if [ "$$(echo "$${COVERAGE} < 90" | bc -l)" -eq 1 ]; then \
echo "โ Coverage $${COVERAGE}% is below 90% threshold"; \
exit 1; \
else \
echo "โ
Coverage $${COVERAGE}% meets 90% threshold"; \
fi
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 --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:
@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"
wasm: wasm-build
wasm-build:
@echo "๐ Building WebAssembly package..."
@which wasm-pack > /dev/null 2>&1 || (echo "๐ฆ Installing wasm-pack..." && cargo install wasm-pack)
@cd wasm-pkg && wasm-pack build --target web --release
@echo ""
@echo "โ
WASM build complete!"
@echo " Package: wasm-pkg/pkg/"
@echo " Size: $$(du -h wasm-pkg/pkg/*.wasm | cut -f1)"
@echo ""
@echo "๐ก Next steps:"
@echo " make wasm-serve - Start local server"
@echo " Open http://localhost:7777/"
wasm-test:
@echo "๐งช Testing WASM module..."
@cargo test --features wasm wasm::
@echo ""
@echo "๐งช Testing standalone WASM package..."
@cd wasm-pkg && cargo test
@echo "โ
WASM tests passed"
WASM_PORT ?= 7777
wasm-serve: wasm-build
@echo "๐ Starting local server at http://localhost:$(WASM_PORT)"
@echo " Open: http://localhost:$(WASM_PORT)/"
@echo " Press Ctrl+C to stop"
@echo " (Use WASM_PORT=XXXX to change: make wasm-serve WASM_PORT=9000)"
@if command -v ruchy > /dev/null 2>&1; then \
echo " Using ruchy (12x faster than Python)"; \
cd wasm-pkg && ruchy serve . --port $(WASM_PORT); \
else \
echo " Using Python (install ruchy for 12x faster: cargo install ruchy)"; \
cd wasm-pkg && python3 -m http.server $(WASM_PORT); \
fi
wasm-clean:
@echo "๐งน Cleaning WASM artifacts..."
@rm -rf wasm-pkg/pkg wasm-pkg/target
@echo "โ
WASM artifacts cleaned"
viz:
@echo "๐ Building with visualization feature..."
@cargo build --features viz
@echo "โ
Viz build complete"
viz-test:
@echo "๐งช Testing visualization module..."
@cargo test --features viz viz::
@echo "โ
Viz tests passed"
viz-demo:
@echo "๐ Running visualization demo..."
@cargo run --bin oip --features viz -- extract-training-data --repo . --output /tmp/viz-demo.json --max-commits 50 --viz
@echo "โ
Demo complete"
e2e-install:
@echo "๐ฆ Installing Playwright dependencies..."
@cd e2e && npm install
@cd e2e && npx playwright install
@echo "โ
Playwright installed"
e2e: wasm-build e2e-test
e2e-test:
@echo "๐งช Running e2e tests..."
@cd e2e && npm test
@echo "โ
E2E tests complete"
e2e-headed:
@echo "๐งช Running e2e tests (headed)..."
@cd e2e && npm run test:headed
e2e-ui:
@echo "๐งช Opening Playwright UI..."
@cd e2e && npm run test:ui
e2e-report:
@echo "๐ Opening test report..."
@cd e2e && npm run report