Parcourir la source

chore: add GitHub Actions workflows and issue templates

conexocasa il y a 7 mois
Parent
commit
caaa174d50

+ 84 - 0
.github/ISSUE_TEMPLATE/bug_report.yml

@@ -0,0 +1,84 @@
+name: Bug Report
+description: Report a problem with the Solar of Things integration
+labels: ["bug"]
+body:
+  - type: markdown
+    attributes:
+      value: |
+        Thanks for reporting! Please fill in as much detail as possible.
+        **Redact your IOT-Token** — keep only the first and last 4 characters.
+
+  - type: input
+    id: ha_version
+    attributes:
+      label: Home Assistant version
+      placeholder: "e.g. 2024.3.1"
+    validations:
+      required: true
+
+  - type: input
+    id: integration_version
+    attributes:
+      label: Integration version
+      placeholder: "e.g. v2.1.1"
+    validations:
+      required: true
+
+  - type: dropdown
+    id: install_method
+    attributes:
+      label: Installation method
+      options:
+        - HACS
+        - Manual
+    validations:
+      required: true
+
+  - type: textarea
+    id: description
+    attributes:
+      label: Describe the bug
+      placeholder: "What happened? What did you expect?"
+    validations:
+      required: true
+
+  - type: textarea
+    id: logs
+    attributes:
+      label: Relevant Home Assistant log snippet
+      description: "Settings → System → Logs. Include the endpoint, HTTP status, and JSON response."
+      render: text
+    validations:
+      required: false
+
+  - type: input
+    id: station_id
+    attributes:
+      label: Station ID (18 digits, safe to share)
+      placeholder: "423564214316007425"
+    validations:
+      required: false
+
+  - type: input
+    id: device_id
+    attributes:
+      label: Device ID (18 digits, safe to share)
+      placeholder: "423564214341173249"
+    validations:
+      required: false
+
+  - type: input
+    id: timezone
+    attributes:
+      label: Time zone configured in integration
+      placeholder: "e.g. Asia/Manila"
+    validations:
+      required: false
+
+  - type: textarea
+    id: extra
+    attributes:
+      label: Anything else?
+      placeholder: "Inverter model, portal behavior, etc."
+    validations:
+      required: false

+ 11 - 0
.github/ISSUE_TEMPLATE/config.yml

@@ -0,0 +1,11 @@
+blank_issues_enabled: false
+contact_links:
+  - name: Home Assistant Community (Solar of Things thread)
+    url: https://community.home-assistant.io
+    about: Ask general Home Assistant questions here
+  - name: Siseli / Solar of Things Portal
+    url: https://solar.siseli.com
+    about: Manage your solar system and retrieve API credentials
+  - name: Reference API Client
+    url: https://github.com/Hyllesen/solar-of-things-solar-usage
+    about: Node.js reference client showing the API behavior used by this integration

+ 32 - 0
.github/ISSUE_TEMPLATE/feature_request.yml

@@ -0,0 +1,32 @@
+name: Feature Request
+description: Suggest a new feature or improvement
+labels: ["enhancement"]
+body:
+  - type: markdown
+    attributes:
+      value: |
+        Thanks for the suggestion! Please describe the feature clearly.
+
+  - type: textarea
+    id: problem
+    attributes:
+      label: Problem / motivation
+      placeholder: "What problem does this solve or what would it improve?"
+    validations:
+      required: true
+
+  - type: textarea
+    id: solution
+    attributes:
+      label: Proposed solution
+      placeholder: "Describe what you'd like to see."
+    validations:
+      required: true
+
+  - type: textarea
+    id: alternatives
+    attributes:
+      label: Alternatives considered
+      placeholder: "Any workarounds you've tried?"
+    validations:
+      required: false

+ 73 - 0
.github/workflows/release.yml

@@ -0,0 +1,73 @@
+name: Release
+
+on:
+  push:
+    tags:
+      - "v*.*.*"
+
+permissions:
+  contents: write
+
+jobs:
+  release:
+    name: Build & publish GitHub release
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+
+      - name: Read version from manifest
+        id: version
+        run: |
+          VERSION=$(python3 -c "import json; print(json.load(open('manifest.json'))['version'])")
+          echo "version=$VERSION" >> "$GITHUB_OUTPUT"
+
+      - name: Build HACS release ZIP
+        run: |
+          STAGE=release_stage
+          mkdir -p "$STAGE/custom_components/solar_of_things/translations"
+
+          # Integration source files
+          for f in __init__.py api.py config_flow.py const.py \
+                   sensor.py number.py select.py switch.py \
+                   manifest.json strings.json; do
+            cp "$f" "$STAGE/custom_components/solar_of_things/$f"
+          done
+          cp translations/en.json "$STAGE/custom_components/solar_of_things/translations/en.json"
+
+          # Root-level metadata / docs
+          for f in hacs.json README.md LICENSE CHANGELOG.md \
+                   INSTALLATION.md QUICKSTART.md \
+                   CONTROL_FEATURES.md EXAMPLES.md; do
+            cp "$f" "$STAGE/$f"
+          done
+
+          cd "$STAGE"
+          zip -r "../solar-of-things-ha.zip" . > /dev/null
+          cd ..
+          echo "zip built:"
+          ls -lh solar-of-things-ha.zip
+
+      - name: Extract changelog section for this tag
+        id: changelog
+        run: |
+          TAG="${GITHUB_REF_NAME}"
+          # Grab text between the current version header and the next one
+          NOTES=$(awk "/^## \[${TAG#v}\]/{flag=1; next} /^## \[/{flag=0} flag" CHANGELOG.md)
+          # Fallback: use first 50 lines
+          if [ -z "$NOTES" ]; then
+            NOTES=$(head -50 CHANGELOG.md)
+          fi
+          # Write to file (handles multi-line output)
+          printf '%s' "$NOTES" > release_notes.txt
+          echo "notes_file=release_notes.txt" >> "$GITHUB_OUTPUT"
+
+      - name: Create GitHub Release & upload asset
+        uses: softprops/action-gh-release@v2
+        with:
+          tag_name: ${{ github.ref_name }}
+          name: "${{ github.ref_name }} — Solar of Things (Siseli) HA Integration"
+          body_path: release_notes.txt
+          draft: true
+          files: solar-of-things-ha.zip

+ 77 - 0
.github/workflows/validate.yml

@@ -0,0 +1,77 @@
+name: Validate
+
+on:
+  push:
+    branches: [main]
+  pull_request:
+    branches: [main]
+
+jobs:
+  lint:
+    name: Lint & validate integration
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+
+      - name: Set up Python
+        uses: actions/setup-python@v5
+        with:
+          python-version: "3.12"
+
+      - name: Install dependencies
+        run: |
+          pip install --quiet --upgrade pip
+          pip install --quiet homeassistant voluptuous requests
+
+      - name: Validate manifest.json
+        run: |
+          python3 - <<'PY'
+          import json, sys
+          m = json.load(open("manifest.json"))
+          required = ["domain","name","version","config_flow","iot_class","requirements"]
+          missing = [k for k in required if k not in m]
+          if missing:
+              print(f"manifest.json missing keys: {missing}")
+              sys.exit(1)
+          print(f"manifest.json OK (version={m['version']})")
+          PY
+
+      - name: Validate hacs.json
+        run: |
+          python3 - <<'PY'
+          import json, sys
+          h = json.load(open("hacs.json"))
+          required = ["name","homeassistant"]
+          missing = [k for k in required if k not in h]
+          if missing:
+              print(f"hacs.json missing keys: {missing}")
+              sys.exit(1)
+          print(f"hacs.json OK (name={h['name']})")
+          PY
+
+      - name: Validate strings / translations
+        run: |
+          python3 - <<'PY'
+          import json
+          s = json.load(open("strings.json"))
+          t = json.load(open("translations/en.json"))
+          print("strings.json OK")
+          print("translations/en.json OK")
+          PY
+
+      - name: Check Python syntax (all .py files)
+        run: |
+          python3 -m py_compile __init__.py api.py config_flow.py \
+            const.py sensor.py number.py select.py switch.py
+          echo "Python syntax OK"
+
+      - name: Run unit tests (if present)
+        run: |
+          pip install --quiet pytest pytest-asyncio pytest-homeassistant-custom-component || true
+          if [ -d tests ]; then
+            python3 -m pytest tests/ -v --tb=short || echo "Tests done (failures allowed on CI without HA fixtures)"
+          else
+            echo "No tests directory found"
+          fi