github.com/psiphon-inc/goarista@v0.0.0-20160825065156-d002785f4c67/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  
    40  vet:
    41  	$(GO) vet ./...
    42  
    43  lint:
    44  	lint=`$(GOFOLDERS) | xargs -L 1 $(GOLINT) | fgrep -v .pb.go`; if test -n "$$lint"; then echo "$$lint"; exit 1; fi
    45  # The above is ugly, but unfortunately golint doesn't exit 1 when it finds
    46  # lint.  See https://github.com/golang/lint/issues/65
    47  
    48  test:
    49  	$(GO) test $(GOTEST_FLAGS) -timeout=$(TEST_TIMEOUT) ./...
    50  
    51  docker:
    52  	docker build -f cmd/occlient/Dockerfile .
    53  
    54  clean:
    55  	rm -rf $(GOPATH_PKG)/*/github.com/aristanetworks/goarista
    56  	$(GO) clean ./...
    57  
    58  .PHONY: all check coverage coverdata docker fmtcheck install lint test vet