.SUFFIXES:
.DELETE_ON_ERROR:
.ONESHELL:
.PHONY: all build test lint fmt clean doc book book-build book-serve book-test tier1 tier2 tier3 tier4 coverage profile hooks-install hooks-verify lint-scripts bashrs-score bashrs-lint-makefile chaos-test fuzz bench dev pre-push ci check run-ci run-bench audit deps-validate deny pmat-score pmat-gates quality-report semantic-search
all: tier2
build:
cargo build --release
test:
cargo test --all
test-fast:
cargo test --lib
lint:
cargo clippy -- -D warnings
fmt:
cargo fmt
fmt-check:
cargo fmt --check
clean:
cargo clean
doc:
cargo doc --no-deps --open
book: book-build
book-build:
@echo "📚 Building EXTREME TDD 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
book-test:
@echo "🔍 Testing book synchronization..."
@for example in examples/*.rs; do \
if [ -f "$$example" ]; then \
EXAMPLE_NAME=$$(basename "$$example" .rs); \
CASE_STUDY=$$(echo "$$EXAMPLE_NAME" | sed 's/_/-/g'); \
if [ ! -f "book/src/examples/$$CASE_STUDY.md" ]; then \
echo "❌ Missing case study for $$EXAMPLE_NAME"; \
exit 1; \
fi; \
fi; \
done
@echo "✅ All examples have corresponding book chapters"
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"
tier4: tier3
@echo "Running Tier 4: CI/CD validation..."
@cargo test --release
@echo "Running pmat analysis..."
-pmat tdg . --include-components
-pmat rust-project-score
-pmat quality-gates --report
@echo "Tier 4: PASSED"
coverage:
@echo "📊 Generating coverage report (target: >85%, <10 min)..."
@ @test -f ~/.cargo/config.toml && mv ~/.cargo/config.toml ~/.cargo/config.toml.cov-backup || true
@cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
@cargo llvm-cov report --html --output-dir target/coverage/html
@ @test -f ~/.cargo/config.toml.cov-backup && mv ~/.cargo/config.toml.cov-backup ~/.cargo/config.toml || true
@echo "✅ Coverage report: target/coverage/html/index.html"
@cargo llvm-cov report | grep TOTAL
profile:
renacer --function-time --source -- cargo bench
bench:
cargo bench
chaos-test:
@echo "🔥 Running chaos engineering tests..."
@cargo test --features chaos-basic --quiet
@echo "✅ Chaos tests passed"
fuzz:
@echo "🎲 Running fuzz tests (60s)..."
@cargo +nightly fuzz run fuzz_target_1 -- -max_total_time=60 || echo "⚠️ Fuzz testing requires nightly Rust: rustup default nightly"
@echo "✅ Fuzz testing complete"
dev: tier1
pre-push: tier3
ci: tier4
check:
cargo check --all
audit:
@echo "🔒 Running security audit..."
@cargo audit
@echo "✅ Security audit completed"
deps-validate:
@echo "🔍 Validating dependencies..."
@cargo tree --duplicate | grep -v "^$$" || echo "✅ No duplicate dependencies"
@cargo audit || echo "⚠️ Security issues found"
deny:
@echo "🔒 Running cargo-deny checks..."
@if command -v cargo-deny >/dev/null 2>&1; then \
cargo deny check; \
else \
echo "❌ cargo-deny not installed. Install with: cargo install cargo-deny"; \
exit 1; \
fi
@echo "✅ cargo-deny checks passed"
hooks-install:
@echo "🔧 Installing PMAT pre-commit hooks..."
@pmat hooks install || exit 1
@echo "✅ Hooks installed successfully"
hooks-verify:
@echo "🔍 Verifying PMAT hooks..."
@pmat hooks verify
@pmat hooks run
lint-scripts:
@echo "🔍 Linting shell scripts with bashrs..."
@if command -v bashrs >/dev/null 2>&1; then \
for script in scripts/*.sh; do \
echo " Linting $$script..."; \
bashrs lint "$$script" || exit 1; \
done; \
echo "✅ All shell scripts pass bashrs lint"; \
else \
echo "❌ bashrs not installed. Install with: cargo install bashrs"; \
exit 1; \
fi
bashrs-score:
@echo "📊 Scoring shell scripts..."
@for script in scripts/*.sh; do \
echo ""; \
echo "Scoring $$script:"; \
bashrs score "$$script"; \
done
bashrs-lint-makefile:
@echo "🔍 Linting Makefile with bashrs..."
@bashrs make lint Makefile || echo "⚠️ Makefile linting found issues"
run-ci:
@./scripts/ci.sh
run-bench:
@./scripts/bench.sh
pmat-score:
@echo "📊 Calculating Rust project quality score..."
@pmat rust-project-score || echo "⚠️ pmat not found. Install with: cargo install pmat"
@echo ""
pmat-gates:
@echo "🔍 Running pmat quality gates..."
@pmat quality-gates --report || echo "⚠️ pmat not found or gates failed"
@echo ""
quality-report:
@echo "📋 Generating comprehensive quality report..."
@mkdir -p docs/quality-reports
@echo "# Aprender Quality Report" > docs/quality-reports/latest.md
@echo "" >> docs/quality-reports/latest.md
@echo "Generated: $$(date)" >> docs/quality-reports/latest.md
@echo "" >> docs/quality-reports/latest.md
@echo "## Rust Project Score" >> docs/quality-reports/latest.md
@pmat rust-project-score >> docs/quality-reports/latest.md 2>&1 || echo "Error getting score" >> docs/quality-reports/latest.md
@echo "" >> docs/quality-reports/latest.md
@echo "## Quality Gates" >> docs/quality-reports/latest.md
@pmat quality-gates --report >> docs/quality-reports/latest.md 2>&1 || echo "Error running gates" >> docs/quality-reports/latest.md
@echo "" >> docs/quality-reports/latest.md
@echo "## TDG Score" >> docs/quality-reports/latest.md
@pmat tdg . --include-components >> docs/quality-reports/latest.md 2>&1 || echo "Error getting TDG" >> docs/quality-reports/latest.md
@echo "✅ Report generated: docs/quality-reports/latest.md"
semantic-search:
@echo "🔍 Semantic code search..."
@echo "First run will build embeddings (may take a few minutes)..."
@pmat semantic || echo "⚠️ pmat semantic search not available"