CRATE_NAME := oai-rt-rs
GREEN := \033[0;32m
YELLOW := \033[0;33m
RED := \033[0;31m
NC := \033[0m
.PHONY: all build test test-all lint fmt audit ci clean doc release install-hooks coverage check help
all: ci
build:
@echo "$(GREEN)Building $(CRATE_NAME)...$(NC)"
cargo build
release:
@echo "$(GREEN)Building release version...$(NC)"
cargo build --release
test:
@echo "$(GREEN)Running unit tests...$(NC)"
cargo test --lib --bins
test-all:
@echo "$(GREEN)Running full test suite...$(NC)"
cargo test --all-features --all-targets
lint:
@echo "$(GREEN)Running clippy...$(NC)"
cargo clippy --all-targets --all-features -- -D warnings -D clippy::all -D clippy::pedantic
fmt-check:
@echo "$(GREEN)Checking formatting...$(NC)"
cargo fmt --all -- --check
fmt:
@echo "$(GREEN)Fixing formatting...$(NC)"
cargo fmt --all
audit:
@echo "$(GREEN)Running security audit...$(NC)"
cargo deny check
audit-alt:
@echo "$(GREEN)Running cargo-audit...$(NC)"
cargo audit
ci: fmt-check lint test-all audit
@echo "$(GREEN)CI pipeline complete!$(NC)"
check:
@echo "$(GREEN)Running cargo check...$(NC)"
cargo check --all-targets --all-features
doc:
@echo "$(GREEN)Generating documentation...$(NC)"
cargo doc --no-deps --all-features
doc-open:
@echo "$(GREEN)Opening documentation...$(NC)"
cargo doc --no-deps --all-features --open
coverage:
@echo "$(GREEN)Generating test coverage...$(NC)"
cargo tarpaulin --all-features --workspace --timeout 120 --out Html
clean:
@echo "$(YELLOW)Cleaning build artifacts...$(NC)"
cargo clean
install-hooks:
@echo "$(GREEN)Installing pre-commit hooks...$(NC)"
pre-commit install
pre-commit install --hook-type pre-push
@echo "$(GREEN)Hooks installed successfully!$(NC)"
uninstall-hooks:
@echo "$(YELLOW)Uninstalling pre-commit hooks...$(NC)"
pre-commit uninstall
pre-commit uninstall --hook-type pre-push
pre-commit-all:
@echo "$(GREEN)Running pre-commit on all files...$(NC)"
pre-commit run --all-files
update:
@echo "$(GREEN)Updating dependencies...$(NC)"
cargo update
outdated:
@echo "$(GREEN)Checking for outdated dependencies...$(NC)"
cargo outdated
verify-version:
@echo "$(GREEN)Verifying version...$(NC)"
@VERSION=$$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version'); \
TAG=$$(git describe --tags --exact-match 2>/dev/null | sed 's/^v//'); \
if [ -z "$$TAG" ]; then \
echo "$(YELLOW)No tag found on current commit$(NC)"; \
elif [ "$$VERSION" != "$$TAG" ]; then \
echo "$(RED)Version mismatch: Cargo.toml has $$VERSION but tag is $$TAG$(NC)"; \
exit 1; \
else \
echo "$(GREEN)Version $$VERSION matches tag$(NC)"; \
fi
help:
@echo "Available targets:"
@echo " $(GREEN)build$(NC) - Build the project (debug)"
@echo " $(GREEN)release$(NC) - Build optimized release version"
@echo " $(GREEN)test$(NC) - Run fast unit tests (pre-commit)"
@echo " $(GREEN)test-all$(NC) - Run full test suite (CI)"
@echo " $(GREEN)lint$(NC) - Run clippy linter"
@echo " $(GREEN)fmt$(NC) - Fix code formatting"
@echo " $(GREEN)fmt-check$(NC) - Check code formatting"
@echo " $(GREEN)audit$(NC) - Run security audit (cargo-deny)"
@echo " $(GREEN)ci$(NC) - Run full CI pipeline"
@echo " $(GREEN)check$(NC) - Quick compilation check"
@echo " $(GREEN)doc$(NC) - Generate documentation"
@echo " $(GREEN)coverage$(NC) - Generate test coverage report"
@echo " $(GREEN)clean$(NC) - Remove build artifacts"
@echo " $(GREEN)install-hooks$(NC) - Install git hooks"
@echo " $(GREEN)verify-version$(NC)- Verify Cargo.toml version matches git tag"
@echo " $(GREEN)help$(NC) - Show this help message"