Makefile 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. .PHONY: check check-fmt check-test check-clippy check-lines fmt clippy test addon-image addon-push help
  2. # Run all quality gates (delegates to the shared script for use in CI).
  3. check:
  4. @./scripts/check.sh
  5. # Individual gates (for iterating on a single failure).
  6. check-fmt:
  7. cargo fmt --check
  8. check-test:
  9. cargo test
  10. check-clippy:
  11. cargo clippy --all-targets -- -D warnings
  12. # Ensure no Rust source file exceeds 500 lines (see AGENTS.md).
  13. check-lines:
  14. @exit_code=0; \
  15. max=500; \
  16. for f in src/**/*.rs src/*.rs; do \
  17. [ -f "$$f" ] || continue; \
  18. lines=$$(wc -l < "$$f"); \
  19. if [ "$$lines" -gt "$$max" ]; then \
  20. echo "FAIL: $$f has $$lines lines (max $$max)"; \
  21. exit_code=1; \
  22. fi; \
  23. done; \
  24. if [ "$$exit_code" -eq 0 ]; then \
  25. echo "✅ All Rust source files are under $$max lines"; \
  26. else \
  27. exit "$$exit_code"; \
  28. fi
  29. # Auto-fix formatting (not a gate; use sparingly before committing).
  30. fmt:
  31. cargo fmt --all
  32. # The sm121 HA add-on image (docker-images/sm121-addon/): multi-stage
  33. # docker build from the repo root (src/ compiled in-container — the binary
  34. # always matches the container's arch; .dockerignore trims the context).
  35. # Smoke test: scripts/smoke-addon.sh.
  36. # The add-on image lives in the sibling sm121-ha-integration repo (the HA
  37. # add-on store: repository.json + sm121/ + the GitHub Actions workflows)
  38. # and is built + pushed THERE by CI (ghcr.io/kilork/sm121-addon, OIDC —
  39. # no docker login). Local build for dev / smoke:
  40. addon-image:
  41. docker build -t sm121-addon:latest -f ../sm121-ha-integration/sm121/Dockerfile ../sm121-ha-integration/sm121/
  42. # No push target: GitHub Actions (sm121-ha-integration) publishes
  43. # ghcr.io/kilork/sm121-addon on push to main (aarch64 + amd64 + manifest).
  44. # The GHCR package must be set public (first time only) so HA can pull it.
  45. # Auto-fix lints (clippy --fix); review the diff before committing.
  46. clippy-fix:
  47. cargo clippy --all-targets --fix --allow-dirty --allow-staged
  48. help:
  49. @echo "make check Run all quality gates (fmt, test, clippy, lines)"
  50. @echo "make check-fmt Run cargo fmt --check"
  51. @echo "make check-test Run cargo test"
  52. @echo "make check-clippy Run cargo clippy --all-targets -- -D warnings"
  53. @echo "make check-lines Verify all src/**/*.rs are ≤500 lines"
  54. @echo "make fmt Auto-fix formatting"
  55. @echo "make clippy-fix Apply clippy suggestions (review diff)"