validate.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. name: Validate
  2. on:
  3. push:
  4. branches: [main]
  5. pull_request:
  6. branches: [main]
  7. jobs:
  8. lint:
  9. name: Lint & validate integration
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: Checkout
  13. uses: actions/checkout@v4
  14. - name: Set up Python
  15. uses: actions/setup-python@v5
  16. with:
  17. python-version: "3.12"
  18. - name: Install dependencies
  19. run: |
  20. pip install --quiet --upgrade pip
  21. pip install --quiet homeassistant voluptuous requests
  22. - name: Validate manifest.json
  23. run: |
  24. python3 - <<'PY'
  25. import json, sys
  26. m = json.load(open("manifest.json"))
  27. required = ["domain","name","version","config_flow","iot_class","requirements"]
  28. missing = [k for k in required if k not in m]
  29. if missing:
  30. print(f"manifest.json missing keys: {missing}")
  31. sys.exit(1)
  32. print(f"manifest.json OK (version={m['version']})")
  33. PY
  34. - name: Validate hacs.json
  35. run: |
  36. python3 - <<'PY'
  37. import json, sys
  38. h = json.load(open("hacs.json"))
  39. required = ["name","homeassistant"]
  40. missing = [k for k in required if k not in h]
  41. if missing:
  42. print(f"hacs.json missing keys: {missing}")
  43. sys.exit(1)
  44. print(f"hacs.json OK (name={h['name']})")
  45. PY
  46. - name: Validate strings / translations
  47. run: |
  48. python3 - <<'PY'
  49. import json
  50. s = json.load(open("strings.json"))
  51. t = json.load(open("translations/en.json"))
  52. print("strings.json OK")
  53. print("translations/en.json OK")
  54. PY
  55. - name: Check Python syntax (all .py files)
  56. run: |
  57. python3 -m py_compile __init__.py api.py config_flow.py \
  58. const.py sensor.py number.py select.py switch.py
  59. echo "Python syntax OK"
  60. - name: Run unit tests (if present)
  61. run: |
  62. pip install --quiet pytest pytest-asyncio pytest-homeassistant-custom-component || true
  63. if [ -d tests ]; then
  64. python3 -m pytest tests/ -v --tb=short || echo "Tests done (failures allowed on CI without HA fixtures)"
  65. else
  66. echo "No tests directory found"
  67. fi