Add gofmt checks to presubmit

This commit is contained in:
Mustafa Gezen 2022-10-30 06:03:06 +01:00
parent b05450b3b3
commit 842af93afa
Signed by untrusted user who does not match committer: mustafa
GPG Key ID: DCDF010D946438C1
2 changed files with 26 additions and 0 deletions

View File

@ -35,3 +35,14 @@ presubmits:
- image: quay.io/peridot/ci:v0.3.16 - image: quay.io/peridot/ci:v0.3.16
command: command:
- hack/non_manual_build.sh - hack/non_manual_build.sh
- name: pull-peridot-gofmt-check
branches:
- main
always_run: true
decorate: true
spec:
containers:
- image: quay.io/peridot/ci:v0.3.16
command:
- hack/gofmt_check.sh

15
hack/gofmt_check.sh Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -o errexit
bazel build --config=ci @go_sdk//...
GO_BIN="$(bazel info output_base)/external/go_sdk/bin/go"
if [[ -n $($GO_BIN fmt -n $(go list ./... | grep -v /vendor/) | sed 's/ -w//') ]]; then
echo "Go files must be formatted with gofmt. Please run:"
echo " go fmt $(go list ./... | grep -v /vendor/)"
exit 1
fi