Makefile 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Copyright (c) 2015 Arista Networks, Inc.
  2. # Use of this source code is governed by the Apache License 2.0
  3. # that can be found in the COPYING file.
  4. GO := go
  5. TEST_TIMEOUT := 30s
  6. GOTEST_FLAGS :=
  7. DEFAULT_GOPATH := $${GOPATH%%:*}
  8. GOPATH_BIN := $(DEFAULT_GOPATH)/bin
  9. GOPATH_PKG := $(DEFAULT_GOPATH)/pkg
  10. GOLINT := $(GOPATH_BIN)/golint
  11. GOFOLDERS := find . -type d ! -path "./.git/*"
  12. all: install
  13. install:
  14. $(GO) install ./...
  15. check: vet test fmtcheck lint
  16. COVER_PKGS := key test
  17. COVER_MODE := count
  18. coverdata:
  19. echo 'mode: $(COVER_MODE)' >coverage.out
  20. for dir in $(COVER_PKGS); do \
  21. $(GO) test -covermode=$(COVER_MODE) -coverprofile=cov.out-t ./$$dir || exit; \
  22. tail -n +2 cov.out-t >> coverage.out && \
  23. rm cov.out-t; \
  24. done;
  25. coverage: coverdata
  26. $(GO) tool cover -html=coverage.out
  27. rm -f coverage.out
  28. fmtcheck:
  29. errors=`gofmt -l .`; if test -n "$$errors"; then echo Check these files for style errors:; echo "$$errors"; exit 1; fi
  30. find . -name '*.go' ! -name '*.pb.go' -exec ./check_line_len.awk {} +
  31. ./check_copyright_notice.sh
  32. vet:
  33. $(GO) vet ./...
  34. lint:
  35. lint=`$(GOFOLDERS) | xargs -L 1 $(GOLINT) | fgrep -v .pb.go`; if test -n "$$lint"; then echo "$$lint"; exit 1; fi
  36. # The above is ugly, but unfortunately golint doesn't exit 1 when it finds
  37. # lint. See https://github.com/golang/lint/issues/65
  38. test:
  39. $(GO) test $(GOTEST_FLAGS) -timeout=$(TEST_TIMEOUT) ./...
  40. docker:
  41. docker build -f cmd/occlient/Dockerfile .
  42. clean:
  43. rm -rf $(GOPATH_PKG)/*/notabug.org/themusicgod1/goarista
  44. $(GO) clean ./...
  45. .PHONY: all check coverage coverdata docker fmtcheck install lint test vet