Zum Inhalt

HACS-Validierung

Validiert eine über HACS verteilte Home-Assistant-Custom-Integration mit den beiden offiziellen Actions, sodass ein konsumierendes Repository dasselbe Gate erbt, das HACS und Home Assistant Core anwenden.

  • hacs/action führt denselben Code aus, den HACS zur Validierung eines Repositories nutzt (Existenz von hacs.json, Brands, Topics, …); category ist standardmäßig integration
  • home-assistant/actions/hassfest validiert das Integrations-Manifest und die Struktur, auch für Custom Integrations

Verwendung

.github/workflows/ci.yml
on:
  push:
  pull_request:

jobs:
  hacs-validate:
    uses: nolte/gh-plumbing/.github/workflows/reusable-hacs-validate.yaml@develop

Custom-Repository vs. Default-Store

Lasse ignore leer für einen Default-Store-tauglichen Lauf — HACS verbietet ignorierte Checks für die Default-Store-Aufnahme. Ein reines Custom-Repository darf nicht erfüllbare Checks ignorieren, z. B. with: { ignore: "brands" }.


Release-ZIP-Asset

Für HACS-Integrationen baut reusable-release-publish.yml ein <domain>.zip-Asset aus custom_components/<domain>/ am Ziel-Commit des Release und hängt es vor dem Umschalten auf draft=false an den Draft — so sieht HACS nie ein Release ohne seinen Download. Das geschieht automatisch, sobald das Repository eine custom_components/<domain>/manifest.json trägt; es ist keine zusätzliche Verdrahtung nötig.

Der vollständige Release-und-Distributions-Kontrakt ist in spec/ha/hacs-release in claude-home-assistant spezifiziert.


Zentrale Konfiguration

.github/workflows/reusable-hacs-validate.yaml
name: Reusable — HACS Validate

# Validates a HACS-distributed Home Assistant custom integration with the two
# official actions, so a consuming integration inherits the same gate HACS and
# Home Assistant Core apply. Spec: claude-home-assistant spec/ha/hacs-release.
#
#   - hacs/action       — runs the same code HACS uses to validate a repository
#                         (hacs.json existence, brands, topics, …). category is
#                         required; this reusable defaults it to "integration".
#   - hassfest          — Home Assistant Core's own manifest/structure validator,
#                         able to validate standalone/custom integrations.
#
# Consumers call this on push and pull_request:
#
#   jobs:
#     validate:
#       uses: nolte/gh-plumbing/.github/workflows/reusable-hacs-validate.yaml@develop

on:
  workflow_call:
    inputs:
      category:
        description: |
          HACS repository category passed to hacs/action. One of: integration,
          plugin, theme, python_script, appdaemon, template. This reusable
          targets HACS integrations; the default is "integration".
        required: false
        type: string
        default: integration
      ignore:
        description: |
          Space-separated list of hacs/action checks to skip. Valid names:
          archived brands description hacsjson images information issues topics.
          Leave empty for a default-store-grade run — per
          spec/ha/hacs-release a default-store inclusion MUST NOT ignore any
          check. A pure custom repository MAY ignore checks it cannot satisfy.
        required: false
        type: string
        default: ""
      run_hassfest:
        description: |
          Run hassfest. Keep true for integrations (the default). Set false for
          non-integration HACS categories (plugin/theme/…) where hassfest does
          not apply.
        required: false
        type: boolean
        default: true
      hacs_action_ref:
        description: |
          Git ref of hacs/action to pin. Defaults to "main" (the action's own
          moving default). Override with a tag or commit SHA to harden, matching
          spec/ha/hacs-release §CI validation (SHOULD pin hacs/action).
        required: false
        type: string
        default: main

permissions:
  contents: read

jobs:
  hacs:
    name: HACS Action
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v6.0.0

      - name: HACS validation
        uses: hacs/action@${{ inputs.hacs_action_ref }}
        env:
          # hacs/action calls the GitHub API for the issues/topics/brands checks.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          category: ${{ inputs.category }}
          ignore: ${{ inputs.ignore }}

  hassfest:
    name: Hassfest
    if: ${{ inputs.run_hassfest }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v6.0.0

      # hassfest is canonically referenced @master per the Home Assistant
      # developer docs; pin by SHA downstream if you want it frozen.
      - name: Hassfest validation
        uses: home-assistant/actions/hassfest@master