From a9f1be8d40a44b661bcab6f4e43e0f8f89ce58ba Mon Sep 17 00:00:00 2001 From: Aitor Perez Cedres Date: Wed, 27 Sep 2023 12:49:05 +0100 Subject: [PATCH] Add Go format checks to CI Different contributors work on different IDEs and configurations. This check will help to catch format errors before merging. The `go fmt` tool marks the standard for formatting. Signed-off-by: Aitor Perez Cedres --- .github/workflows/static-check.yaml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/static-check.yaml b/.github/workflows/static-check.yaml index 7e68839b..9a40b761 100644 --- a/.github/workflows/static-check.yaml +++ b/.github/workflows/static-check.yaml @@ -21,4 +21,27 @@ jobs: with: version: "2023.1.3" install-go: false - build-tags: "rabbitmq.stream.test,rabbitmq.stream.e2e" \ No newline at end of file + build-tags: "rabbitmq.stream.test,rabbitmq.stream.e2e" + + format-check: + name: Check Go Formatting + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: stable + + - name: Run gofmt check + run: | + go fmt ./... + changes=$(git status --porcelain) + if [ -n "$changes" ]; then + echo "The following Go files are not formatted correctly:" + echo "$changes" + exit 1 + fi