2018-06-16 19:22:21 -05:00
|
|
|
OS := $(shell uname -s)
|
2018-07-12 08:27:07 -05:00
|
|
|
TEST_PACKAGES := $(shell go list ./... | grep -v cmd)
|
|
|
|
COVER_PACKAGES := $(shell go list ./... | grep -v cmd | paste -sd "," -)
|
2018-06-16 19:22:21 -05:00
|
|
|
LINTER := $(shell command -v gometalinter 2> /dev/null)
|
|
|
|
|
|
|
|
.PHONY: setup
|
|
|
|
|
|
|
|
setup:
|
|
|
|
ifeq ($(OS), Darwin)
|
|
|
|
brew install dep
|
|
|
|
else
|
|
|
|
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
|
|
|
endif
|
|
|
|
dep ensure -vendor-only
|
|
|
|
ifndef LINTER
|
|
|
|
@echo "Installing linter"
|
|
|
|
@go get -u github.com/alecthomas/gometalinter
|
|
|
|
@gometalinter --install
|
|
|
|
endif
|
|
|
|
|
|
|
|
build:
|
2018-06-22 07:01:36 -05:00
|
|
|
@go build -o ./gaper cmd/gaper/main.go
|
2018-06-16 19:22:21 -05:00
|
|
|
|
|
|
|
## lint: Validate golang code
|
|
|
|
lint:
|
|
|
|
@gometalinter \
|
|
|
|
--deadline=120s \
|
|
|
|
--line-length=120 \
|
|
|
|
--enable-all \
|
2018-07-12 08:35:44 -05:00
|
|
|
--disable=gochecknoinits --disable=gochecknoglobals \
|
2018-06-16 19:22:21 -05:00
|
|
|
--vendor ./...
|
|
|
|
|
|
|
|
test:
|
2018-06-22 07:01:36 -05:00
|
|
|
@go test -p=1 -coverpkg $(COVER_PACKAGES) \
|
2018-07-12 08:48:17 -05:00
|
|
|
-covermode=atomic -coverprofile=coverage.txt $(TEST_PACKAGES)
|
2018-06-16 19:22:21 -05:00
|
|
|
|
|
|
|
cover: test
|
2018-07-12 08:48:17 -05:00
|
|
|
@go tool cover -html=coverage.txt
|
2018-06-16 19:22:21 -05:00
|
|
|
|
|
|
|
fmt:
|
|
|
|
@find . -name '*.go' -not -wholename './vendor/*' | \
|
|
|
|
while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
|