Skip to content

Commit 7d36fe8

Browse files
committed
fix(ci): run make format before committing auto-regenerated config
The regenerate workflow previously only ran gofmt on the codegen output, leaving tfplugindocs-generated docs, golangci-lint --fix changes, and other formatting out of the auto-PR. Maintainers then had to push those formatting fixups on top of the bot's commit. Run the full make format pipeline after codegen/discover-apply so the PR lands clean, and install the Terraform CLI in the workflow since make format shells out to terraform fmt for examples.
1 parent 5afeb30 commit 7d36fe8

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

.github/workflows/regenerate-config.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ jobs:
2929
with:
3030
go-version-file: go.mod
3131

32+
- name: Set up Terraform CLI (required by make format)
33+
uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85 # v4
34+
with:
35+
terraform_wrapper: false
36+
3237
- name: Download OpenAPI spec (pinned to go.mod version)
3338
run: make download-spec
3439

@@ -94,15 +99,24 @@ jobs:
9499
-mappings ./internal/codegen/mappings.yaml \
95100
-spec ./internal/codegen/openapi.yaml \
96101
-out ./internal/resources/projectconfig/
97-
gofmt -s -w ./internal/codegen/cmd/generate/ ./internal/resources/projectconfig/
98102
fi
99103
100-
- name: Check for generated file changes
101-
id: diff
104+
- name: Check for codegen changes (pre-format)
105+
id: codegen_diff
102106
run: |
103107
git diff --exit-code --quiet internal/codegen/mappings.yaml internal/resources/projectconfig/ \
104108
|| echo "changed=true" >> "$GITHUB_OUTPUT"
105109
110+
- name: Run make format (regenerate docs, gofmt, lint --fix)
111+
if: steps.codegen_diff.outputs.changed == 'true'
112+
run: make format
113+
114+
- name: Check for any file changes (post-format)
115+
id: diff
116+
run: |
117+
git diff --exit-code --quiet \
118+
|| echo "changed=true" >> "$GITHUB_OUTPUT"
119+
106120
- name: Build and test
107121
if: steps.diff.outputs.changed == 'true'
108122
run: |

0 commit comments

Comments
 (0)