CI: Run gofmt on Linting action (#110159)

* CI: Run gofmt on Linting action

* Chore: Run gofmt on all packages
This commit is contained in:
Matheus Macabu
2025-08-26 16:14:03 +02:00
committed by GitHub
parent d34338be02
commit 78ac555c4d
75 changed files with 169 additions and 73 deletions
+21
View File
@@ -33,6 +33,27 @@ jobs:
with:
self: .github/workflows/go-lint.yml
go-fmt:
needs: detect-changes
if: needs.detect-changes.outputs.changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-go@v5.5.0
with:
go-version-file: ./go.mod
- name: Run gofmt
run: |
GOFMT="$(go list -m -f '{{.Dir}}' | xargs -I{} sh -c 'test ! -f {}/.nolint && echo {}' | xargs gofmt -s -e -l 2>&1 | grep -v '/pkg/build/' || true)"
if [ -n "$GOFMT" ]; then
echo "Found files that are not gofmt'ed"
echo "Run 'gofmt -s -w .' or 'make gofmt' or install the pre-commit hook with 'make lefthook-install'"
echo "${GOFMT}"
exit 1
fi
lint-go:
needs: detect-changes
if: needs.detect-changes.outputs.changed == 'true'