github.com/aristanetworks/goarista@v0.0.0-20240514173732-cca2755bbd44/Makefile (about) 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 5 GO := go 6 TEST_TIMEOUT := 30s 7 GOTEST_FLAGS := 8 9 DEFAULT_GOPATH := $${GOPATH%%:*} 10 GOPATH_BIN := $(DEFAULT_GOPATH)/bin 11 GOPATH_PKG := $(DEFAULT_GOPATH)/pkg 12 GOLINT := $(GOPATH_BIN)/golint 13 GOFOLDERS := find . -type d ! -path "./.git/*" 14 15 all: install 16 17 install: 18 $(GO) install ./... 19 20 check: vet test fmtcheck lint 21 22 COVER_PKGS := key test 23 COVER_MODE := count 24 coverdata: 25 echo 'mode: $(COVER_MODE)' >coverage.out 26 for dir in $(COVER_PKGS); do \ 27 $(GO) test -covermode=$(COVER_MODE) -coverprofile=cov.out-t ./$$dir || exit; \ 28 tail -n +2 cov.out-t >> coverage.out && \ 29 rm cov.out-t; \ 30 done; 31 32 coverage: coverdata 33 $(GO) tool cover -html=coverage.out 34 rm -f coverage.out 35 36 fmtcheck: 37 errors=`gofmt -l .`; if test -n "$$errors"; then echo Check these files for style errors:; echo "$$errors"; exit 1; fi 38 find . -name '*.go' ! -name '*.pb.go' -exec ./check_line_len.awk {} + 39 ./check_copyright_notice.sh 40 41 vet: 42 $(GO) vet ./... 43 44 lint: 45 lint=`$(GOFOLDERS) | xargs -L 1 $(GOLINT) | fgrep -v .pb.go`; if test -n "$$lint"; then echo "$$lint"; exit 1; fi 46 # The above is ugly, but unfortunately golint doesn't exit 1 when it finds 47 # lint. See https://github.com/golang/lint/issues/65 48 49 test: 50 $(GO) test $(GOTEST_FLAGS) -timeout=$(TEST_TIMEOUT) ./... 51 52 docker: 53 docker build -f cmd/occlient/Dockerfile . 54 55 clean: 56 rm -rf $(GOPATH_PKG)/*/github.com/aristanetworks/goarista 57 $(GO) clean ./... 58 59 .PHONY: all check coverage coverdata docker fmtcheck install lint test vet