| 1 |
SHELL := /bin/bash -o pipefail |
| 2 |
UNAME_OS := $(shell uname -s) |
| 3 |
UNAME_ARCH := $(shell uname -m) |
| 4 |
|
| 5 |
TMP_BASE := .tmp |
| 6 |
TMP := $(TMP_BASE)/$(UNAME_OS)/$(UNAME_ARCH) |
| 7 |
TMP_BIN = $(TMP)/bin |
| 8 |
|
| 9 |
GOLINT_VERSION := 8f45f776aaf18cebc8d65861cc70c33c60471952 |
| 10 |
GOLINT := $(TMP_BIN)/golint |
| 11 |
$(GOLINT): |
| 12 |
$(eval GOLINT_TMP := $(shell mktemp -d)) |
| 13 |
@cd $(GOLINT_TMP); go get github.com/golang/lint/golint@$(GOLINT_VERSION) |
| 14 |
@rm -rf $(GOLINT_TMP) |
| 15 |
|
| 16 |
ERRCHECK_VERSION := v1.2.0 |
| 17 |
ERRCHECK := $(TMP_BIN)/errcheck |
| 18 |
$(ERRCHECK): |
| 19 |
$(eval ERRCHECK_TMP := $(shell mktemp -d)) |
| 20 |
@cd $(ERRCHECK_TMP); go get github.com/kisielk/errcheck@$(ERRCHECK_VERSION) |
| 21 |
@rm -rf $(ERRCHECK_TMP) |
| 22 |
|
| 23 |
STATICCHECK_VERSION := c2f93a96b099cbbec1de36336ab049ffa620e6d7 |
| 24 |
STATICCHECK := $(TMP_BIN)/staticcheck |
| 25 |
$(STATICCHECK): |
| 26 |
$(eval STATICCHECK_TMP := $(shell mktemp -d)) |
| 27 |
@cd $(STATICCHECK_TMP); go get honnef.co/go/tools/cmd/staticcheck@$(STATICCHECK_VERSION) |
| 28 |
@rm -rf $(STATICCHECK_TMP) |
| 29 |
|
| 30 |
unexport GOPATH |
| 31 |
export GO111MODULE := on |
| 32 |
export GOBIN := $(abspath $(TMP_BIN)) |
| 33 |
export PATH := $(GOBIN):$(PATH) |
| 34 |
|
| 35 |
.DEFAULT_GOAL := all |
| 36 |
|
| 37 |
.PHONY: all |
| 38 |
all: lint test |
| 39 |
|
| 40 |
.PHONY: install |
| 41 |
install: |
| 42 |
go install ./... |
| 43 |
|
| 44 |
.PHONY: golint |
| 45 |
golint: $(GOLINT) |
| 46 |
@# TODO: readd cmd/proto2gql when fixed |
| 47 |
@#for file in $(shell find . -name '*.go'); do |
| 48 |
for file in $(shell find . -name '*.go' | grep -v cmd/proto2gql); do \ |
| 49 |
golint $${file}; \ |
| 50 |
if [ -n "$$(golint $${file})" ]; then \ |
| 51 |
exit 1; \ |
| 52 |
fi; \ |
| 53 |
done |
| 54 |
|
| 55 |
.PHONY: vet |
| 56 |
vet: |
| 57 |
go vet ./... |
| 58 |
|
| 59 |
.PHONY: testdeps |
| 60 |
errcheck: $(ERRCHECK) |
| 61 |
errcheck ./... |
| 62 |
|
| 63 |
.PHONY: staticcheck |
| 64 |
staticcheck: $(STATICCHECK) |
| 65 |
staticcheck -checks "all -U1000" ./... |
| 66 |
|
| 67 |
.PHONY: lint |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
lint: golint vet |
| 72 |
|
| 73 |
.PHONY: test |
| 74 |
test: |
| 75 |
go test -race -coverprofile=coverage.txt -covermode=atomic ./... |
| 76 |
|
| 77 |
.PHONY: clean |
| 78 |
clean: |
| 79 |
go clean -i ./... |
| 80 |
|
| 81 |
.PHONY: integration |
| 82 |
integration: |
| 83 |
PB=y go test -cover |