Skip to content

Commit 0eb4c6d

Browse files
authored
ci(regen): rustfmt generated code so regen diffs stay reviewable (#46)
* ci(regen): rustfmt generated code to keep regen diffs reviewable * ci(regen): derive rustfmt edition from Cargo.toml
1 parent c7714a1 commit 0eb4c6d

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

.github/workflows/regenerate.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
3232
with:
3333
toolchain: stable
34+
components: rustfmt
3435

3536
- name: Fetch merged OpenAPI spec
3637
env:
@@ -91,6 +92,20 @@ jobs:
9192
--http-user-agent "hotdata-rust/${PACKAGE_VERSION}" \
9293
--skip-validate-spec
9394
95+
# The 7.22.0 generator emits compact, non-rustfmt output, which buries real
96+
# spec changes under formatting churn in every regen diff. Format only the
97+
# generated subtrees so the diff shows semantic changes; the hand-written
98+
# ergonomic layer is left to its own formatting (and is ignore-protected
99+
# from the generator anyway).
100+
- name: Format generated code
101+
run: |
102+
# Derive the edition from Cargo.toml so it can't drift from the crate
103+
# if the edition is ever bumped (same source as the version bump above).
104+
edition=$(cargo metadata --no-deps --format-version 1 \
105+
| jq -r '.packages[] | select(.name=="hotdata") | .edition')
106+
find src/apis src/models -name '*.rs' -print0 \
107+
| xargs -0 rustfmt --edition "$edition"
108+
94109
- name: Clean up fetched spec
95110
run: rm -f openapi.yaml
96111

0 commit comments

Comments
 (0)