Add Makefile to check the following thing (#947)
* Add Makefile to check the following thing. * vet check * fmt check * embedmd check * misspell check Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * remove unused variable. Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
		
							
								
								
									
										61
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,61 @@
 | 
			
		||||
GOFMT ?= gofmt "-s"
 | 
			
		||||
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
 | 
			
		||||
GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
 | 
			
		||||
 | 
			
		||||
all: build
 | 
			
		||||
 | 
			
		||||
install: deps
 | 
			
		||||
	govendor sync
 | 
			
		||||
 | 
			
		||||
.PHONY: test
 | 
			
		||||
test:
 | 
			
		||||
	go test -v -covermode=count -coverprofile=coverage.out
 | 
			
		||||
 | 
			
		||||
.PHONY: fmt
 | 
			
		||||
fmt:
 | 
			
		||||
	$(GOFMT) -w $(GOFILES)
 | 
			
		||||
 | 
			
		||||
.PHONY: fmt-check
 | 
			
		||||
fmt-check:
 | 
			
		||||
	# get all go files and run go fmt on them
 | 
			
		||||
	@diff=$$($(GOFMT) -d $(GOFILES)); \
 | 
			
		||||
	if [ -n "$$diff" ]; then \
 | 
			
		||||
		echo "Please run 'make fmt' and commit the result:"; \
 | 
			
		||||
		echo "$${diff}"; \
 | 
			
		||||
		exit 1; \
 | 
			
		||||
	fi;
 | 
			
		||||
 | 
			
		||||
vet:
 | 
			
		||||
	go vet $(PACKAGES)
 | 
			
		||||
 | 
			
		||||
deps:
 | 
			
		||||
	@hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
 | 
			
		||||
		go get -u github.com/kardianos/govendor; \
 | 
			
		||||
	fi
 | 
			
		||||
	@hash embedmd > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
 | 
			
		||||
		go get -u github.com/campoy/embedmd; \
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
embedmd:
 | 
			
		||||
	embedmd -d *.md
 | 
			
		||||
 | 
			
		||||
.PHONY: lint
 | 
			
		||||
lint:
 | 
			
		||||
	@hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
 | 
			
		||||
		go get -u github.com/golang/lint/golint; \
 | 
			
		||||
	fi
 | 
			
		||||
	for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
 | 
			
		||||
 | 
			
		||||
.PHONY: misspell-check
 | 
			
		||||
misspell-check:
 | 
			
		||||
	@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
 | 
			
		||||
		go get -u github.com/client9/misspell/cmd/misspell; \
 | 
			
		||||
	fi
 | 
			
		||||
	misspell -error $(GOFILES)
 | 
			
		||||
 | 
			
		||||
.PHONY: misspell
 | 
			
		||||
misspell:
 | 
			
		||||
	@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
 | 
			
		||||
		go get -u github.com/client9/misspell/cmd/misspell; \
 | 
			
		||||
	fi
 | 
			
		||||
	misspell -w $(GOFILES)
 | 
			
		||||
		Reference in New Issue
	
	Block a user