validate.yml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. name: Validate
  2. on:
  3. push:
  4. branches: [main]
  5. pull_request:
  6. branches: [main]
  7. permissions:
  8. contents: read
  9. env:
  10. FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
  11. jobs:
  12. lint:
  13. name: Lint & validate integration
  14. runs-on: ubuntu-latest
  15. steps:
  16. - name: Checkout
  17. uses: actions/checkout@v4
  18. - name: Set up Python
  19. uses: actions/setup-python@v5
  20. with:
  21. python-version: "3.12"
  22. - name: Install dependencies
  23. run: |
  24. pip install --quiet --upgrade pip
  25. pip install --quiet voluptuous requests pycryptodome
  26. - name: Validate custom_components/solar_of_things/manifest.json
  27. run: |
  28. python3 - <<'PY'
  29. import json, sys
  30. m = json.load(open("custom_components/solar_of_things/manifest.json"))
  31. required = ["domain","name","version","config_flow","iot_class",
  32. "requirements","integration_type","homeassistant"]
  33. missing = [k for k in required if k not in m]
  34. if missing:
  35. print(f"manifest.json missing keys: {missing}")
  36. sys.exit(1)
  37. print(f"manifest.json OK (version={m['version']}, type={m['integration_type']})")
  38. PY
  39. - name: Validate hacs.json
  40. run: |
  41. python3 - <<'PY'
  42. import json, sys
  43. h = json.load(open("hacs.json"))
  44. required = ["name", "homeassistant"]
  45. missing = [k for k in required if k not in h]
  46. if missing:
  47. print(f"hacs.json missing keys: {missing}")
  48. sys.exit(1)
  49. print(f"hacs.json OK (name={h['name']}, homeassistant={h['homeassistant']})")
  50. PY
  51. - name: Validate strings / translations sync
  52. run: |
  53. python3 - <<'PY'
  54. import json, sys
  55. s = json.load(open("custom_components/solar_of_things/strings.json"))
  56. t = json.load(open("custom_components/solar_of_things/translations/en.json"))
  57. # Both must parse as valid JSON and have at minimum a config key
  58. for label, obj in [("strings.json", s), ("translations/en.json", t)]:
  59. if "config" not in obj:
  60. print(f"{label} missing '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. python3 -m py_compile \
  68. __init__.py api.py config_flow.py const.py \
  69. sensor.py number.py select.py switch.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 done (failures allowed on CI without full HA fixtures)"
  77. else
  78. echo "No tests directory — skipping"
  79. fi