name: Validate Home Assistant Configuration on: push: branches: - '**' paths: - 'config/**' - 'utils/validation/**' - '.gitea/workflows/validate.yml' pull_request: paths: - 'config/**' - 'utils/validation/**' jobs: yamllint: name: YAML Lint runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install yamllint run: pip install yamllint>=1.35.0 - name: Run yamllint run: yamllint config/ ha-config-check: name: Home Assistant Config Check runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.12' - name: Generate secrets.yaml env: DB_USER: ${{ secrets.DB_USER }} DB_PASSWORD: ${{ secrets.DB_PASSWORD }} POSTGRES_HOST: ${{ secrets.POSTGRES_HOST }} POSTGRES_PORT: ${{ secrets.POSTGRES_PORT }} DB_NAME: ${{ secrets.DB_NAME }} run: | python3 << 'EOF' import os from urllib.parse import quote_plus # URL-encode password for PostgreSQL connection string db_user = os.environ['DB_USER'] db_password = quote_plus(os.environ['DB_PASSWORD']) db_host = os.environ['POSTGRES_HOST'] db_port = os.environ['POSTGRES_PORT'] db_name = os.environ['DB_NAME'] # Generate secrets.yaml secrets_content = f"""# Auto-generated secrets.yaml for CI validation recorder_db: "postgresql://{db_user}:{db_password}@{db_host}:{db_port}/{db_name}" """ with open('config/secrets.yaml', 'w') as f: f.write(secrets_content) print("✓ Generated secrets.yaml") EOF - name: Validate HA Config with Docker run: | docker run --rm \ -v $(pwd)/config:/config \ homeassistant/home-assistant:latest \ python -m homeassistant --script check_config -c /config validate-entities: name: Validate Entity IDs runs-on: ubuntu-latest continue-on-error: true steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install dependencies run: | pip install -e . - name: Run entity validation env: POSTGRES_HOST: ${{ secrets.POSTGRES_HOST }} POSTGRES_PORT: ${{ secrets.POSTGRES_PORT }} DB_NAME: ${{ secrets.DB_NAME }} DB_READONLY_USER: ${{ secrets.DB_READONLY_USER }} DB_READONLY_PASSWORD: ${{ secrets.DB_READONLY_PASSWORD }} run: | python utils/validation/validate_entities.py config/ validate-devices: name: Validate Device IDs runs-on: ubuntu-latest continue-on-error: true steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install dependencies run: | pip install -e . - name: Run device validation env: HA_HOST: ${{ secrets.HA_HOST }} HA_TOKEN: ${{ secrets.HA_TOKEN }} run: | python utils/validation/validate_devices.py config/