parent
1c8f4bce24
commit
ed0d04b2d8
@ -0,0 +1,21 @@
|
||||
# Repository validation
|
||||
|
||||
Run the same tracked checks used by Config Validation before pushing:
|
||||
|
||||
```powershell
|
||||
pwsh -NoProfile -File .github/scripts/check_public_repo_safety.ps1
|
||||
python -m unittest discover -s .github/scripts -p test_validate_dashboards.py -v
|
||||
pwsh -NoProfile -File .github/scripts/validate_dashboards.ps1
|
||||
pwsh -NoProfile -File .github/scripts/holiday_lighting_coverage.ps1
|
||||
node --check .github/scripts/ha_ui_smoke.mjs
|
||||
```
|
||||
|
||||
Dashboard entity references must be present in repository configuration or in
|
||||
`dashboard_entity_allowlist.txt`. For integration, UI-created, or generated entities,
|
||||
verify the exact entity against Home Assistant before adding its ID to that sorted
|
||||
list. Keep only IDs already referenced by public dashboards; never export registry
|
||||
metadata. Unused entries fail validation.
|
||||
|
||||
Private runtime storage provides an additional check of allowlisted entities when
|
||||
available. It cannot make an otherwise undocumented reference pass locally, so a
|
||||
clean checkout and a live checkout enforce the same public reference requirement.
|
||||
@ -0,0 +1,43 @@
|
||||
"""Protect dashboard reference parity between runtime and clean checkouts."""
|
||||
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from validate_dashboards import ValidationError, validate_entity_references
|
||||
|
||||
|
||||
class EntityReferenceParityTests(unittest.TestCase):
|
||||
def test_runtime_registry_cannot_hide_missing_public_reference(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
storage = root / "config" / ".storage"
|
||||
storage.mkdir(parents=True)
|
||||
(storage / "core.entity_registry").write_text(
|
||||
'{"entities": [{"entity_id": "sensor.runtime_only"}]}',
|
||||
encoding="utf-8",
|
||||
)
|
||||
with self.assertRaisesRegex(ValidationError, "unknown static dashboard entity"):
|
||||
validate_entity_references(root, {"sensor.runtime_only"})
|
||||
|
||||
def test_public_allowlist_supports_clean_and_runtime_checkouts(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
(root / "config").mkdir()
|
||||
scripts = root / ".github" / "scripts"
|
||||
scripts.mkdir(parents=True)
|
||||
(scripts / "dashboard_entity_allowlist.txt").write_text(
|
||||
"sensor.runtime_only\n", encoding="utf-8"
|
||||
)
|
||||
validate_entity_references(root, {"sensor.runtime_only"})
|
||||
storage = root / "config" / ".storage"
|
||||
storage.mkdir()
|
||||
(storage / "core.entity_registry").write_text(
|
||||
'{"entities": [{"entity_id": "sensor.runtime_only"}]}',
|
||||
encoding="utf-8",
|
||||
)
|
||||
validate_entity_references(root, {"sensor.runtime_only"})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Reference in new issue