Skip to content

Commit 124f59a

Browse files
committed
chore: try that again
1 parent 99dea2d commit 124f59a

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

.github/workflows/lint.yaml

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,51 @@ jobs:
2929
import os
3030
from pathlib import Path
3131
32-
configs = sorted(
33-
str(path.name)
34-
for path in Path(".").glob("*.yaml")
35-
if path.name != "secrets.yaml"
36-
)
32+
def first_friendly_name(path: Path) -> str | None:
33+
with path.open("r", encoding="utf-8", errors="ignore") as f:
34+
for raw in f:
35+
line = raw.strip()
36+
if not line or line.startswith("#"):
37+
continue
38+
if line.startswith("friendly_name:"):
39+
value = line.split(":", 1)[1].strip()
40+
if (value.startswith('"') and value.endswith('"')) or (
41+
value.startswith("'") and value.endswith("'")
42+
):
43+
value = value[1:-1].strip()
44+
return value or None
45+
return None
46+
47+
configs = []
48+
49+
for path in sorted(Path(".").glob("*.yaml")):
50+
friendly_name = first_friendly_name(path)
51+
if not friendly_name:
52+
continue
53+
54+
configs.append(
55+
{
56+
"file": str(path),
57+
"friendly_name": friendly_name,
58+
}
59+
)
3760
3861
if not configs:
39-
raise SystemExit("No ESPHome configs found in the repository root.")
62+
raise SystemExit("No ESPHome configs with 'friendly_name' found.")
4063
4164
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh:
42-
fh.write(f"configs={json.dumps(configs)}\n")
65+
fh.write(f"configs={json.dumps(configs)}\n")
4366
PY
4467
4568
esphome-config:
46-
name: Validate ${{ matrix.config }}
69+
name: Validate ${{ matrix.config.friendly_name }} (${{ matrix.config.file }})
4770
runs-on: ubuntu-latest
4871
needs: list-configs
4972
strategy:
5073
fail-fast: false
5174
matrix:
5275
config: ${{ fromJson(needs.list-configs.outputs.configs) }}
76+
5377
steps:
5478
- name: Check out repository
5579
uses: actions/checkout@v4
@@ -58,8 +82,9 @@ jobs:
5882
uses: actions/setup-python@v5
5983
with:
6084
python-version: "3.13"
61-
cache: pip
62-
- run: pip install esphome
85+
86+
- name: Install ESPHome
87+
run: pip install esphome
6388

6489
- name: Provide stub secrets.yaml
6590
run: |
@@ -71,4 +96,4 @@ jobs:
7196
EOF
7297
7398
- name: Run esphome config
74-
run: esphome config "${{ matrix.config }}"
99+
run: esphome config "${{ matrix.config.file }}"

0 commit comments

Comments
 (0)