# ==========================================================================
# Local gate. CI additionally runs typos, codeql, dependency-review and the
# parity corpus. Keep this fast and deterministic; `--locked` everywhere.
# ==========================================================================

.PHONY: check fmt clippy test deny layer versions gen doc doctest audit auditor-test

# The local gate: everything a change must pass before review.
check: fmt clippy test deny layer versions

fmt:
	cargo fmt --all -- --check

# The second clippy line is NOT optional: `--all-targets` silently skips the
# feature-gated `rpmcrab-gen` bin, so it must be built explicitly with the
# `gen` feature on.
clippy:
	cargo clippy --workspace --all-targets --locked -- -D warnings
	cargo clippy --workspace --all-targets --features gen --locked -- -D warnings

test:
	cargo test --workspace --all-targets --locked

deny:
	cargo deny check

# Architectural layering: `rpmcrab-core` must not depend on CLI concerns.
layer:
	bash scripts/check-rust-layering.sh

# Version consistency: every restatement of the release version agrees
# with [workspace.package] (docs/DESIGN.md §9).
versions:
	bash scripts/check-version-consistency.sh

# Regenerate man pages and shell completions into crates/rpmcrab/{man,completions}.
gen:
	rm -rf crates/rpmcrab/man crates/rpmcrab/completions
	cargo run --locked -p rpmcrab --features gen --bin rpmcrab-gen -- crates/rpmcrab

doc:
	RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items --locked

doctest:
	cargo test --workspace --doc --locked

audit: ## reference-vs-port coverage audit (needs .parity-ref or a checkout)
	python3 scripts/audit-reference-coverage.py

auditor-test: ## unit tests for the auditor itself
	python3 scripts/test_audit_reference_coverage.py
