Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. addon-image:
  37. docker build -t sm121-addon:latest -f docker-images/sm121-addon/Dockerfile docker-images/sm121-addon/
  38. # Push the add-on image to the [registry] base (the HA add-on's config.yaml
  39. # references it). Requires `docker login ghcr.io`.
  40. # The image is THIN (no sm121 binary — the entrypoint compiles it on the Pi
  41. # from the launcher repo, so the arch always matches). Built on an aarch64
  42. # host for the Pi; for a multi-arch manifest (x86_64 too) use:
  43. # docker buildx build --platform linux/aarch64,linux/x86_64 \
  44. # -t ghcr.io/kilork/sm121-addon:latest --push -f docker-images/sm121-addon/Dockerfile docker-images/sm121-addon/
  45. # (needs qemu binfmt on the builder).
  46. addon-push:
  47. docker tag sm121-addon:latest ghcr.io/kilork/sm121-addon:latest
  48. docker push ghcr.io/kilork/sm121-addon:latest
  49. # Auto-fix lints (clippy --fix); review the diff before committing.
  50. clippy-fix:
  51. cargo clippy --all-targets --fix --allow-dirty --allow-staged
  52. help:
  53. @echo "make check Run all quality gates (fmt, test, clippy, lines)"
  54. @echo "make check-fmt Run cargo fmt --check"
  55. @echo "make check-test Run cargo test"
  56. @echo "make check-clippy Run cargo clippy --all-targets -- -D warnings"
  57. @echo "make check-lines Verify all src/**/*.rs are ≤500 lines"
  58. @echo "make fmt Auto-fix formatting"
  59. @echo "make clippy-fix Apply clippy suggestions (review diff)"