mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
* Use gometalinter and enforcing go fmt/lint/vet Before this PR go fmt is enabled, go lint is suggest only. From time to time we have to manually check for go lint and go vet for any issues. This fix uses gometalinter and enforcing go fmt/lint/vet. Several reasons: - gometalinter could handle multiple linters concurrently - gometalinter supports suppression with `// nolint[: <linter>]` Previously one reason we didn't enable go lint was due to the ``` warning: context.Context should be the first parameter of a function (golint) ``` this is now possible with gometalinter and `// nolint: golint` (See changes). This fix also discovered several go vet issues and fixes it. Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Fix several issues reported by gometalinter (go vet) This commit fixes several issues reported by gometalinter (go vet). Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Increase deadline Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
75 lines
2.0 KiB
Makefile
75 lines
2.0 KiB
Makefile
GITCOMMIT:=$(shell git describe --dirty --always)
|
|
BINARY:=coredns
|
|
SYSTEM:=
|
|
|
|
all: coredns
|
|
|
|
# Phony this to ensure we always build the binary.
|
|
# TODO: Add .go file dependencies.
|
|
.PHONY: coredns
|
|
coredns: check godeps
|
|
CGO_ENABLED=0 $(SYSTEM) go build -v -ldflags="-s -w -X github.com/coredns/coredns/coremain.gitCommit=$(GITCOMMIT)" -o $(BINARY)
|
|
|
|
.PHONY: check
|
|
check: linter core/zplugin.go core/dnsserver/zdirectives.go godeps
|
|
|
|
.PHONY: test
|
|
test: check
|
|
go test -race -v ./test ./plugin/...
|
|
|
|
.PHONY: testk8s
|
|
testk8s: check
|
|
go test -race -v -tags=k8s -run 'TestKubernetes' ./test ./plugin/kubernetes/...
|
|
|
|
.PHONY: godeps
|
|
godeps:
|
|
go get github.com/mholt/caddy
|
|
go get github.com/miekg/dns
|
|
go get golang.org/x/net/context
|
|
go get golang.org/x/text
|
|
|
|
.PHONY: travis
|
|
travis: check
|
|
ifeq ($(TEST_TYPE),core)
|
|
( cd request ; go test -v -tags 'etcd k8s' -race ./... )
|
|
( cd core ; go test -v -tags 'etcd k8s' -race ./... )
|
|
( cd coremain go test -v -tags 'etcd k8s' -race ./... )
|
|
endif
|
|
ifeq ($(TEST_TYPE),integration)
|
|
( cd test ; go test -v -tags 'etcd k8s' -race ./... )
|
|
endif
|
|
ifeq ($(TEST_TYPE),plugin)
|
|
( cd plugin ; go test -v -tags 'etcd k8s' -race ./... )
|
|
endif
|
|
ifeq ($(TEST_TYPE),coverage)
|
|
for d in `go list ./... | grep -v vendor`; do \
|
|
t=$$(date +%s); \
|
|
go test -i -tags 'etcd k8s' -coverprofile=cover.out -covermode=atomic $$d || exit 1; \
|
|
go test -v -tags 'etcd k8s' -coverprofile=cover.out -covermode=atomic $$d || exit 1; \
|
|
echo "Coverage test $$d took $$(($$(date +%s)-t)) seconds"; \
|
|
if [ -f cover.out ]; then \
|
|
cat cover.out >> coverage.txt; \
|
|
rm cover.out; \
|
|
fi; \
|
|
done
|
|
endif
|
|
|
|
|
|
core/zplugin.go core/dnsserver/zdirectives.go: plugin.cfg
|
|
go generate coredns.go
|
|
|
|
.PHONY: gen
|
|
gen:
|
|
go generate coredns.go
|
|
|
|
.PHONY: linter
|
|
linter:
|
|
go get -u github.com/alecthomas/gometalinter
|
|
gometalinter --install golint
|
|
gometalinter --deadline=1m --disable-all --enable=gofmt --enable=golint --enable=vet --exclude=^vendor/ --exclude=^pb/ ./...
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
go clean
|
|
rm -f coredns
|