Skip to content

Commit ab8bd5d

Browse files
committed
Add: Auto-formatting to CI workflows
- Adds gofmt steps to build-and-release and test.yml - to ensure consistent Go code formatting and catch - issues early in the CI process.
1 parent 997f28e commit ab8bd5d

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

.github/workflows/build-and-release.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ jobs:
6262
- name: Get dependencies
6363
run: go mod download
6464

65+
- name: Auto-format code
66+
run: |
67+
# Auto-format all Go files
68+
gofmt -s -w .
69+
70+
# Check if any files were formatted
71+
if [ -n "$(git status --porcelain 2>/dev/null)" ]; then
72+
echo "Some files were auto-formatted in the build process."
73+
git diff --name-only
74+
fi
75+
6576
- name: Run tests
6677
run: go test -v ./...
6778

.github/workflows/test.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,18 @@ jobs:
4545

4646
- name: Run go fmt
4747
run: |
48+
# Auto-format all Go files
49+
gofmt -s -w .
50+
51+
# Check if any files were formatted (would indicate pre-existing formatting issues)
52+
if [ -n "$(git status --porcelain 2>/dev/null)" ]; then
53+
echo "Some files were auto-formatted. Consider running 'gofmt -s -w .' locally before committing."
54+
git diff --name-only
55+
fi
56+
57+
# Final check to ensure all files are properly formatted
4858
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
49-
echo "The following files are not formatted:"
59+
echo "The following files are still not formatted after auto-format:"
5060
gofmt -s -l .
5161
exit 1
5262
fi

0 commit comments

Comments
 (0)