2018-10-14 07:39:16 +03:00
|
|
|
GO ?= go
|
2017-06-13 05:50:42 +03:00
|
|
|
GOFMT ?= gofmt "-s"
|
2018-10-14 07:39:16 +03:00
|
|
|
PACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/)
|
|
|
|
VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/ | grep -v /examples/)
|
2017-06-13 05:50:42 +03:00
|
|
|
GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
|
2018-10-14 07:39:16 +03:00
|
|
|
TESTFOLDER := $(shell $(GO) list ./... | grep -E 'gin$$|binding$$|render$$' | grep -v examples)
|
2017-06-13 05:50:42 +03:00
|
|
|
|
2018-01-24 06:06:42 +03:00
|
|
|
all: install
|
2017-06-13 05:50:42 +03:00
|
|
|
|
|
|
|
install: deps
|
|
|
|
govendor sync
|
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test:
|
2018-10-14 07:39:16 +03:00
|
|
|
echo "mode: count" > coverage.out
|
|
|
|
for d in $(TESTFOLDER); do \
|
2018-12-05 08:49:03 +03:00
|
|
|
$(GO) test -v -covermode=count -coverprofile=profile.out $$d > tmp.out; \
|
|
|
|
cat tmp.out; \
|
|
|
|
if grep -q "^--- FAIL" tmp.out; then \
|
|
|
|
rm tmp.out; \
|
2018-12-25 19:27:46 +03:00
|
|
|
exit 1; \
|
|
|
|
elif grep -q "build failed" tmp.out; then \
|
|
|
|
rm tmp.out; \
|
2019-02-21 15:32:55 +03:00
|
|
|
exit 1; \
|
|
|
|
elif grep -q "setup failed" tmp.out; then \
|
|
|
|
rm tmp.out; \
|
|
|
|
exit 1; \
|
2018-12-05 08:49:03 +03:00
|
|
|
fi; \
|
2018-10-14 07:39:16 +03:00
|
|
|
if [ -f profile.out ]; then \
|
|
|
|
cat profile.out | grep -v "mode:" >> coverage.out; \
|
|
|
|
rm profile.out; \
|
|
|
|
fi; \
|
|
|
|
done
|
2017-06-13 05:50:42 +03:00
|
|
|
|
|
|
|
.PHONY: fmt
|
|
|
|
fmt:
|
|
|
|
$(GOFMT) -w $(GOFILES)
|
|
|
|
|
|
|
|
.PHONY: fmt-check
|
|
|
|
fmt-check:
|
|
|
|
@diff=$$($(GOFMT) -d $(GOFILES)); \
|
|
|
|
if [ -n "$$diff" ]; then \
|
|
|
|
echo "Please run 'make fmt' and commit the result:"; \
|
|
|
|
echo "$${diff}"; \
|
|
|
|
exit 1; \
|
|
|
|
fi;
|
|
|
|
|
|
|
|
vet:
|
2018-10-14 07:39:16 +03:00
|
|
|
$(GO) vet $(VETPACKAGES)
|
2017-06-13 05:50:42 +03:00
|
|
|
|
|
|
|
deps:
|
|
|
|
@hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
2018-10-14 07:39:16 +03:00
|
|
|
$(GO) get -u github.com/kardianos/govendor; \
|
2017-06-13 05:50:42 +03:00
|
|
|
fi
|
|
|
|
@hash embedmd > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
2018-10-14 07:39:16 +03:00
|
|
|
$(GO) get -u github.com/campoy/embedmd; \
|
2017-06-13 05:50:42 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
embedmd:
|
|
|
|
embedmd -d *.md
|
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint:
|
|
|
|
@hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
2018-10-14 07:39:16 +03:00
|
|
|
$(GO) get -u golang.org/x/lint/golint; \
|
2017-06-13 05:50:42 +03:00
|
|
|
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 \
|
2018-10-14 07:39:16 +03:00
|
|
|
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
|
2017-06-13 05:50:42 +03:00
|
|
|
fi
|
|
|
|
misspell -error $(GOFILES)
|
|
|
|
|
|
|
|
.PHONY: misspell
|
|
|
|
misspell:
|
|
|
|
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
2018-10-14 07:39:16 +03:00
|
|
|
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
|
2017-06-13 05:50:42 +03:00
|
|
|
fi
|
|
|
|
misspell -w $(GOFILES)
|
2018-10-15 07:52:51 +03:00
|
|
|
|
|
|
|
.PHONY: tools
|
|
|
|
tools:
|
|
|
|
go install golang.org/x/lint/golint; \
|
|
|
|
go install github.com/client9/misspell/cmd/misspell; \
|
|
|
|
go install github.com/campoy/embedmd;
|