| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- .PHONY: check check-fmt check-test check-clippy check-lines fmt clippy test addon-image addon-push help
- # Run all quality gates (delegates to the shared script for use in CI).
- check:
- @./scripts/check.sh
- # Individual gates (for iterating on a single failure).
- check-fmt:
- cargo fmt --check
- check-test:
- cargo test
- check-clippy:
- cargo clippy --all-targets -- -D warnings
- # Ensure no Rust source file exceeds 500 lines (see AGENTS.md).
- check-lines:
- @exit_code=0; \
- max=500; \
- for f in src/**/*.rs src/*.rs; do \
- [ -f "$$f" ] || continue; \
- lines=$$(wc -l < "$$f"); \
- if [ "$$lines" -gt "$$max" ]; then \
- echo "FAIL: $$f has $$lines lines (max $$max)"; \
- exit_code=1; \
- fi; \
- done; \
- if [ "$$exit_code" -eq 0 ]; then \
- echo "✅ All Rust source files are under $$max lines"; \
- else \
- exit "$$exit_code"; \
- fi
- # Auto-fix formatting (not a gate; use sparingly before committing).
- fmt:
- cargo fmt --all
- # The sm121 HA add-on image (docker-images/sm121-addon/): multi-stage
- # docker build from the repo root (src/ compiled in-container — the binary
- # always matches the container's arch; .dockerignore trims the context).
- # Smoke test: scripts/smoke-addon.sh.
- addon-image:
- docker build -t sm121-addon:latest -f docker-images/sm121-addon/Dockerfile .
- # Push the add-on image to the [registry] base (the HA add-on's config.yaml
- # references it). Requires `docker login ghcr.io`.
- # NOTE: single-arch (the build host's — aarch64 on the Mac / DGX nodes,
- # matching the Pi's arch). For a multi-arch manifest (x86_64 too) use:
- # docker buildx build --platform linux/aarch64,linux/x86_64 \
- # -t ghcr.io/kilork/sm121-addon:latest --push -f docker-images/sm121-addon/Dockerfile .
- # (needs qemu binfmt registered on the builder; the in-container Rust
- # compile runs under emulation for the foreign arch — slow but works).
- addon-push:
- docker tag sm121-addon:latest ghcr.io/kilork/sm121-addon:latest
- docker push ghcr.io/kilork/sm121-addon:latest
- # Auto-fix lints (clippy --fix); review the diff before committing.
- clippy-fix:
- cargo clippy --all-targets --fix --allow-dirty --allow-staged
- help:
- @echo "make check Run all quality gates (fmt, test, clippy, lines)"
- @echo "make check-fmt Run cargo fmt --check"
- @echo "make check-test Run cargo test"
- @echo "make check-clippy Run cargo clippy --all-targets -- -D warnings"
- @echo "make check-lines Verify all src/**/*.rs are ≤500 lines"
- @echo "make fmt Auto-fix formatting"
- @echo "make clippy-fix Apply clippy suggestions (review diff)"
|