validate.yml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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@v4
  16. - name: Set up Python
  17. uses: actions/setup-python@v5
  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 custom_components/solar_of_things/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']})")
  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. s = json.load(open("custom_components/solar_of_things/strings.json"))
  54. t = json.load(open("custom_components/solar_of_things/translations/en.json"))
  55. # Both must parse as valid JSON and have at minimum a config key
  56. for label, obj in [("strings.json", s), ("translations/en.json", t)]:
  57. if "config" not in obj:
  58. print(f"{label} missing 'config' key")
  59. sys.exit(1)
  60. print(f"{label} OK")
  61. PY
  62. - name: Check Python syntax
  63. run: |
  64. cd custom_components/solar_of_things
  65. python3 -m py_compile \
  66. __init__.py api.py config_flow.py const.py \
  67. sensor.py number.py select.py switch.py
  68. echo "Python syntax OK"
  69. - name: Run unit tests (if present)
  70. run: |
  71. pip install --quiet pytest pytest-asyncio || true
  72. if [ -d tests ]; then
  73. python3 -m pytest tests/ -v --tb=short \
  74. || echo "Tests done (failures allowed on CI without full HA fixtures)"
  75. else
  76. echo "No tests directory — skipping"
  77. fi