|
| 1 | +--- |
| 2 | +name: Lint |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + paths: |
| 7 | + - "**/*.yaml" |
| 8 | + - ".github/workflows/lint.yaml" |
| 9 | + pull_request: |
| 10 | + paths: |
| 11 | + - "**/*.yaml" |
| 12 | + - ".github/workflows/lint.yaml" |
| 13 | + |
| 14 | +jobs: |
| 15 | + list-configs: |
| 16 | + name: Discover ESPHome configs |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + configs: ${{ steps.collect.outputs.configs }} |
| 20 | + steps: |
| 21 | + - name: Check out repository |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Collect config files |
| 25 | + id: collect |
| 26 | + run: | |
| 27 | + python <<'PY' |
| 28 | + import json |
| 29 | + import os |
| 30 | + from pathlib import Path |
| 31 | +
|
| 32 | + configs = sorted( |
| 33 | + str(path.name) |
| 34 | + for path in Path(".").glob("*.yaml") |
| 35 | + if path.name != "secrets.yaml" |
| 36 | + ) |
| 37 | +
|
| 38 | + if not configs: |
| 39 | + raise SystemExit("No ESPHome configs found in the repository root.") |
| 40 | +
|
| 41 | + with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh: |
| 42 | + fh.write(f"configs={json.dumps(configs)}\n") |
| 43 | + PY |
| 44 | +
|
| 45 | + esphome-config: |
| 46 | + name: Validate ${{ matrix.config }} |
| 47 | + runs-on: ubuntu-latest |
| 48 | + needs: list-configs |
| 49 | + strategy: |
| 50 | + fail-fast: false |
| 51 | + matrix: |
| 52 | + config: ${{ fromJson(needs.list-configs.outputs.configs) }} |
| 53 | + steps: |
| 54 | + - name: Check out repository |
| 55 | + uses: actions/checkout@v4 |
| 56 | + |
| 57 | + - name: Set up Python |
| 58 | + uses: actions/setup-python@v5 |
| 59 | + with: |
| 60 | + python-version: "3.13" |
| 61 | + cache: pip |
| 62 | + - run: pip install esphome |
| 63 | + |
| 64 | + - name: Provide stub secrets.yaml |
| 65 | + run: | |
| 66 | + cat <<'EOF' > secrets.yaml |
| 67 | + wifi_ssid: "dummy-ssid" |
| 68 | + wifi_password: "dummy-password" |
| 69 | + api_key: "dummy-api-key" |
| 70 | + ota_password: "dummy-ota-password" |
| 71 | + EOF |
| 72 | +
|
| 73 | + - name: Run esphome config |
| 74 | + run: esphome config "${{ matrix.config }}" |
0 commit comments