add fmt check command (#18)

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2017-05-07 12:52:57 +08:00
committed by GitHub
parent 03bcfacb96
commit 18b163fd7b
2 changed files with 14 additions and 4 deletions
+13 -3
View File
@@ -6,10 +6,12 @@ EXECUTABLE := drone-jenkins
# for dockerhub
DEPLOY_ACCOUNT := appleboy
DEPLOY_IMAGE := $(EXECUTABLE)
GOFMT ?= gofmt "-s"
TARGETS ?= linux darwin windows
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
SOURCES ?= $(shell find . -name "*.go" -type f)
GOFILES := find . -name "*.go" -type f -not -path "./vendor/*"
TAGS ?=
LDFLAGS ?= -X 'main.Version=$(VERSION)'
@@ -28,8 +30,7 @@ endif
all: build
fmt:
find . -name "*.go" -type f -not -path "./vendor/*" | xargs gofmt -s -w
$(GOFILES) | xargs $(GOFMT) -w
vet:
go vet $(PACKAGES)
@@ -51,7 +52,16 @@ unconvert:
fi
for PKG in $(PACKAGES); do unconvert -v $$PKG || exit 1; done;
test:
.PHONY: fmt-check
fmt-check:
# get all go files and run go fmt on them
@files=$$($(GOFILES) | xargs $(GOFMT) -l); if [ -n "$$files" ]; then \
echo "Please run 'make fmt' and commit the result:"; \
echo "$${files}"; \
exit 1; \
fi;
test: fmt-check
for PKG in $(PACKAGES); do go test -v -cover -coverprofile $$GOPATH/src/$$PKG/coverage.txt $$PKG || exit 1; done;
html:
+1 -1
View File
@@ -17,7 +17,7 @@ func main() {
app.Usage = "trigger jenkins jobs"
app.Copyright = "Copyright (c) 2017 Bo-Yi Wu"
app.Authors = []cli.Author{
cli.Author{
{
Name: "Bo-Yi Wu",
Email: "appleboy.tw@gmail.com",
},