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

View File

@ -33,6 +33,27 @@ jobs:
with: with:
self: .github/workflows/go-lint.yml 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: lint-go:
needs: detect-changes needs: detect-changes
if: needs.detect-changes.outputs.changed == 'true' if: needs.detect-changes.outputs.changed == 'true'

View File

@ -384,6 +384,10 @@ lint-go-diff:
sed 's,^,./,' | \ sed 's,^,./,' | \
$(XARGSR) $(golangci-lint) run --config .golangci.yml $(XARGSR) $(golangci-lint) run --config .golangci.yml
.PHONY: gofmt
gofmt: ## Run gofmt for all Go files.
gofmt -s -w .
# with disabled SC1071 we are ignored some TCL,Expect `/usr/bin/env expect` scripts # with disabled SC1071 we are ignored some TCL,Expect `/usr/bin/env expect` scripts
.PHONY: shellcheck .PHONY: shellcheck
shellcheck: $(SH_FILES) ## Run checks for shell scripts. shellcheck: $(SH_FILES) ## Run checks for shell scripts.

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build !wireinject //go:build !wireinject
// +build !wireinject
// Package bar includes both wireinject and non-wireinject variants. // Package bar includes both wireinject and non-wireinject variants.
package bar package bar

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package bar package bar

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
// All of the declarations are in one file. // All of the declarations are in one file.
// Wire should copy non-injectors over, preserving imports. // Wire should copy non-injectors over, preserving imports.

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
// This file is specifically designed to cause issues with copying the // This file is specifically designed to cause issues with copying the
// AST, particularly with the identifier "context". // AST, particularly with the identifier "context".

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//+build wireinject //go:build wireinject
// +build wireinject
package main package main

View File

@ -382,7 +382,7 @@ func TestSearchGetOrCreateIndexWithIndexUpdate(t *testing.T) {
buildEmptyIndexCalls: []buildEmptyIndexCall{}, buildEmptyIndexCalls: []buildEmptyIndexCall{},
cache: map[NamespacedResource]ResourceIndex{ cache: map[NamespacedResource]ResourceIndex{
NamespacedResource{Namespace: "ns", Group: "group", Resource: "bad"}: &MockResourceIndex{ {Namespace: "ns", Group: "group", Resource: "bad"}: &MockResourceIndex{
updateIndexError: failedErr, updateIndexError: failedErr,
}, },
}, },

View File

@ -524,7 +524,7 @@ func runTestIntegrationBackendListModifiedSince(t *testing.T, backend resource.S
require.GreaterOrEqual(t, latestRv, rvDeleted) require.GreaterOrEqual(t, latestRv, rvDeleted)
counter := 0 counter := 0
for _, _ = range seq { for range seq {
counter++ counter++
} }
require.Equal(t, 0, counter) // no events should be returned require.Equal(t, 0, counter) // no events should be returned