Skip to content

Commit c80be27

Browse files
authored
Fix generate-enums workflow: live logs, drop Sources line, camelCase protocolSpecifics (#2084)
A few related fixes to the `generate-enums` workflow and its generated output. ### 1. Stream fetch logs live in CI The `Fetch server data` step appeared to hang with no output, because Python block-buffers stdout when it's a pipe (as in GitHub Actions). Setting `PYTHONUNBUFFERED=1` forces unbuffered output so progress streams live. (Does not make the step faster — it's intentionally serial and rate-limited.) ### 2. Drop the `Sources:` line from generated docs `generate_device_catalog.py` emitted an internal `Sources: atlantic_cozytouch, somfy_europe` line into the `device-types.md` header note. It doesn't belong in user-facing docs — removed. ### 3. camelCase `protocolSpecifics` keys The nested keys inside `protocolSpecifics` (`clusterId`, `attributeIds`, `commandIds`, `manufacturerId`) were snake_case in the committed JSON — a leftover from the v1 fetch path that ran responses through `humps.decamelize`. Every other key in the data files is camelCase. Regenerated both `somfy_europe.json` and `atlantic_cozytouch.json` so they're consistent (pure casing change, no data differences). The catalog generator read the old snake_case `cluster_id`; updated to `clusterId` so cluster annotations aren't silently dropped. With both the data and generator on camelCase, `device-types.md` regenerates identically to `main` — verified. This also makes the weekly automated regeneration PR produce clean diffs instead of thousands of casing-flip lines (the symptom seen in #2083). ### 4. Trailing newline in fetched JSON The data files lacked a final newline, which `end-of-file-fixer` requires — so the auto-generated PR would fail the lint workflow. `fetch_server_data.py` now writes the trailing newline, and the committed files were corrected. ### 5. Format generated files before opening the PR Added a step that runs prek's auto-fixers (ruff, trailing whitespace, end-of-file) on the generated outputs *before* `create-pull-request`. This keeps the weekly auto-PR green instead of landing red and needing a manual formatting fix — exactly the failure mode that #4 would otherwise cause every week. Scoped to the generated files; type checks and the branch guard are skipped since it's a formatting pass, not a gate. (Note: the full lint matrix still runs separately on the opened PR via `lint.yaml`.)
1 parent 29bca8b commit c80be27

5 files changed

Lines changed: 7450 additions & 7436 deletions

File tree

.github/workflows/generate-enums.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636

3737
- name: Fetch server data (Somfy Europe)
3838
env:
39+
PYTHONUNBUFFERED: "1"
3940
OVERKIZ_USERNAME: ${{ secrets.OVERKIZ_USERNAME }}
4041
OVERKIZ_PASSWORD: ${{ secrets.OVERKIZ_PASSWORD }}
4142
run: uv run python utils/fetch_server_data.py --server somfy_europe
@@ -46,6 +47,22 @@ jobs:
4647
- name: Generate device catalog docs
4748
run: uv run python utils/generate_device_catalog.py
4849

50+
- name: Format generated files
51+
# Auto-fix formatting (ruff, trailing whitespace, end-of-file) on the
52+
# generated outputs so the opened PR passes the lint workflow. Type
53+
# checks and the branch guard are skipped — this is a formatting pass,
54+
# not a gate. prek exits non-zero when it modifies files, which is the
55+
# expected outcome here, so the result is committed by the next step.
56+
env:
57+
SKIP: no-commit-to-branch,mypy,ty
58+
run: |
59+
uv run prek run --files \
60+
docs/data/*.json \
61+
pyoverkiz/enums/*.py \
62+
docs/ui-profiles.md \
63+
docs/device-types.md \
64+
|| true
65+
4966
- name: Create pull request
5067
uses: peter-evans/create-pull-request@v8
5168
with:

0 commit comments

Comments
 (0)