From 8f38d8475f27487d86cb3fbbe6c08acfe306d39c Mon Sep 17 00:00:00 2001 From: Mark Kremer Date: Thu, 26 Oct 2023 22:55:56 +0200 Subject: [PATCH] Let the gofmt action fail if the source isn't properly formatted in the GitHub action --- .github/workflows/go.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index e2f3bcd..88d0aea 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -38,7 +38,11 @@ jobs: run: go test -v -covermode atomic -coverprofile=covprofile ./... - name: Gofmt - run: gofmt -d ./ + # Run gofmt, print the output and exit with status code 1 if it isn't empty. + run: | + OUTPUT=$(gofmt -d ./) + echo "$OUTPUT" + test -z "$OUTPUT" - name: Send coverage if: ${{ matrix.go-version == 'stable' && github.ref == 'refs/heads/master' }}