diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2c24e9eda1..113e99f91a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -30,6 +30,16 @@ jobs: restore-keys: | ${{ runner.os }}-go- + - name: gofmt check + run: | + if [ "$(gofmt -s -l . | wc -l)" -ne 0 ] + then + echo "The following files were found to be not go formatted:" + gofmt -s -l . + echo "Please run 'make fmt' to go format the above files." + exit 1 + fi + - name: golangci-lint uses: reviewdog/action-golangci-lint@v1 diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 4be45bf092..cf8199d8d4 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -39,6 +39,16 @@ jobs: key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- + + - name: gofmt check + run: | + if [ "$(gofmt -s -l . | wc -l)" -ne 0 ] + then + echo "The following files were found to be not go formatted:" + gofmt -s -l . + echo "Please run 'make fmt' to go format the above files." + exit 1 + fi - name: golangci-lint uses: reviewdog/action-golangci-lint@v1 diff --git a/Makefile b/Makefile index 5194905057..1c9f8c2a68 100644 --- a/Makefile +++ b/Makefile @@ -208,7 +208,7 @@ endif # Run go fmt against code fmt: - go fmt ./... + gofmt -s -w . vet: go vet ./...