From 6a692453dcf0c391a203377102462810a402432d Mon Sep 17 00:00:00 2001 From: cong Date: Sat, 1 Apr 2023 11:41:17 +0800 Subject: [PATCH] chore(ci): fail lint ci when gofmt or tidy check failed (#3085) --- .github/workflows/go.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 4692e228..f53fe073 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -29,8 +29,17 @@ jobs: - name: Lint run: | go vet -stdmethods=false $(go list ./...) - go install mvdan.cc/gofumpt@latest - test -z "$(gofumpt -l -extra .)" || echo "Please run 'gofumpt -l -w -extra .'" + + if ! test -z "$(gofmt -l .)"; then + echo "Please run 'gofmt -l -w .'" + exit 1 + fi + + go mod tidy + if ! test -z "$(git status --porcelain)"; then + echo "Please run 'go mod tidy'" + exit 1 + fi - name: Test run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...