name: Validate
on:
  push:
  pull_request:
  schedule:
    - cron: "0 4 * * 1"
jobs:
  hacs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: HACS validation
        uses: hacs/action@main
        with:
          category: integration
  hassfest:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Hassfest validation
        uses: home-assistant/actions/hassfest@master
  frontend:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 22 }
      - run: npm ci
      - name: Typecheck
        run: npm run typecheck
      - name: Unit tests
        run: npm test
      - name: Build
        run: npm run build
      - name: Card bundle in sync with integration
        run: cmp dist/houseplan-card.js custom_components/houseplan/frontend/houseplan-card.js
  backend:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: { python-version: "3.13" }
      - run: pip install pytest voluptuous pytest-homeassistant-custom-component home-assistant-frontend
      - name: Backend unit tests (pure + HA harness)
        run: python -m pytest tests_backend/ -q
