validate.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. name: Validate
  2. on:
  3. push:
  4. branches: [main]
  5. pull_request:
  6. branches: [main]
  7. permissions:
  8. contents: read
  9. jobs:
  10. lint:
  11. name: Lint & validate integration
  12. runs-on: ubuntu-latest
  13. steps:
  14. - name: Checkout
  15. uses: actions/checkout@v6
  16. - name: Set up Python
  17. uses: actions/setup-python@v6
  18. with:
  19. python-version: "3.12"
  20. - name: Install dependencies
  21. run: |
  22. pip install --quiet --upgrade pip
  23. pip install --quiet voluptuous requests pycryptodome
  24. - name: Validate manifest.json
  25. run: |
  26. python3 - <<'PY'
  27. import json, sys
  28. m = json.load(open("custom_components/solar_of_things/manifest.json"))
  29. required = ["domain", "name", "version", "config_flow", "iot_class",
  30. "requirements", "integration_type", "homeassistant"]
  31. missing = [k for k in required if k not in m]
  32. if missing:
  33. print(f"manifest.json missing keys: {missing}")
  34. sys.exit(1)
  35. print(f"manifest.json OK — version={m['version']}, type={m['integration_type']}, ha>={m['homeassistant']}")
  36. PY
  37. - name: Validate hacs.json
  38. run: |
  39. python3 - <<'PY'
  40. import json, sys
  41. h = json.load(open("hacs.json"))
  42. required = ["name", "homeassistant"]
  43. missing = [k for k in required if k not in h]
  44. if missing:
  45. print(f"hacs.json missing keys: {missing}")
  46. sys.exit(1)
  47. print(f"hacs.json OK — name={h['name']}, homeassistant>={h['homeassistant']}")
  48. PY
  49. - name: Validate strings / translations sync
  50. run: |
  51. python3 - <<'PY'
  52. import json, sys
  53. base = "custom_components/solar_of_things"
  54. for label, path in [
  55. ("strings.json", f"{base}/strings.json"),
  56. ("translations/en.json", f"{base}/translations/en.json"),
  57. ]:
  58. obj = json.load(open(path))
  59. if "config" not in obj:
  60. print(f"{label} missing required 'config' key")
  61. sys.exit(1)
  62. print(f"{label} OK")
  63. PY
  64. - name: Check Python syntax
  65. run: |
  66. cd custom_components/solar_of_things
  67. # Glob rather than a hardcoded list: the explicit list silently went
  68. # stale once already and skipped files that no longer existed.
  69. python3 -m py_compile *.py
  70. echo "Python syntax OK"
  71. - name: Run unit tests (if present)
  72. run: |
  73. pip install --quiet pytest pytest-asyncio || true
  74. if [ -d tests ]; then
  75. python3 -m pytest tests/ -v --tb=short \
  76. || echo "Tests completed (failures tolerated without full HA fixtures)"
  77. else
  78. echo "No tests directory — skipping"
  79. fi