ci(regen): rustfmt generated code so regen diffs stay reviewable#46
Conversation
| # ergonomic layer is left to its own formatting (and is ignore-protected | ||
| # from the generator anyway). | ||
| - name: Format generated code | ||
| run: find src/apis src/models -name '*.rs' -print0 | xargs -0 rustfmt --edition 2021 |
There was a problem hiding this comment.
super nit: --edition 2021 is hardcoded here while the edition is also declared in Cargo.toml (edition = "2021"). If the crate edition is ever bumped, this will silently drift and format the generated code under the old edition's rules. Not worth a cargo fmt (which would touch the hand-written layer you're deliberately excluding), but you could derive it from Cargo.toml to keep them in sync, e.g. --edition "$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name=="hotdata") | .edition')". (not blocking)
There was a problem hiding this comment.
Clean, focused change. Adds the rustfmt component and formats only the generated subtrees, keeping future regen diffs reviewable. The verify-step greps target short lines that rustfmt won't reflow, so they remain intact. One non-blocking super-nit left inline.
Generator 7.22.0 emits compact, non-rustfmt output, so regen diffs are dominated by formatting churn (PR #44 was 157 files / ~3300 lines, ~95% reformatting). Adds a rustfmt pass over the generated subtrees (src/apis, src/models) after generate — leaving the hand-written layer alone — so future regen diffs show only semantic changes. Verified by reformatting #44: its diff collapsed to 11 code files / +482-3.