Skip to content

Commit

Permalink
Add CI step verifying go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
moskyb committed May 15, 2023
1 parent 9e1a13e commit ba0cd43
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
steps:
- name: ":go: go fmt"
key: test-go-fmt
command: ".buildkite/steps/test-go-fmt.sh"
plugins:
- docker#v3.1.0:
image: "golang:1.20"
workdir: /go/src/github.com/buildkite/buildkite-agent-scaler

- name: ":golang:"
command: ".buildkite/steps/tests.sh"
plugins:
Expand Down
11 changes: 11 additions & 0 deletions .buildkite/steps/test-go-fmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

if [[ $(gofmt -l ./ | head -c 1 | wc -c) != 0 ]]; then
echo "The following files haven't been formatted with \`go fmt\`:"
gofmt -l ./
echo
echo "Fix this by running \`go fmt ./...\` locally, and committing the result."
exit 1
fi

echo "Everything is formatted! 🎉"

0 comments on commit ba0cd43

Please sign in to comment.