github.com/hhrutter/nomad@v0.6.0-rc2.0.20170723054333-80c4b03f0705/GNUmakefile (about)

     1  PACKAGES = $(shell go list ./... | grep -v '/vendor/')
     2  EXTERNAL_TOOLS=\
     3  	       github.com/kardianos/govendor \
     4  	       github.com/mitchellh/gox \
     5  	       golang.org/x/tools/cmd/cover \
     6  	       github.com/axw/gocov/gocov \
     7  	       gopkg.in/matm/v1/gocov-html \
     8  	       github.com/ugorji/go/codec/codecgen
     9  
    10  TEST_TOOLS=\
    11  	   github.com/hashicorp/vault
    12  
    13  all: test
    14  
    15  dev: format generate
    16  	@scripts/build-dev.sh
    17  
    18  bin: generate
    19  	@sh -c "'$(PWD)/scripts/build.sh'"
    20  
    21  release: generate
    22  	@sh -c "TARGETS=release '$(PWD)/scripts/build.sh'"
    23  
    24  cov:
    25  	gocov test ./... | gocov-html > /tmp/coverage.html
    26  	open /tmp/coverage.html
    27  
    28  test: generate
    29  	@echo "--> Running go fmt" ;
    30  	@if [ -n "`go fmt ${PACKAGES}`" ]; then \
    31  		echo "[ERR] go fmt updated formatting. Please commit formatted code first."; \
    32  		exit 1; \
    33  		fi
    34  	@sh -c "'$(PWD)/scripts/test.sh'"
    35  	@$(MAKE) vet
    36  
    37  cover:
    38  	go list ./... | xargs -n1 go test --cover
    39  
    40  format:
    41  	@echo "--> Running go fmt"
    42  	@go fmt $(PACKAGES)
    43  
    44  generate:
    45  	@echo "--> Running go generate"
    46  	@go generate $(PACKAGES)
    47  	@sed -i.old -e 's|github.com/hashicorp/nomad/vendor/github.com/ugorji/go/codec|github.com/ugorji/go/codec|' nomad/structs/structs.generated.go
    48  
    49  vet:
    50  	@echo "--> Running go vet $(VETARGS) ${PACKAGES}"
    51  	@go vet $(VETARGS) ${PACKAGES} ; if [ $$? -eq 1 ]; then \
    52  		echo ""; \
    53  		echo "[LINT] Vet found suspicious constructs. Please check the reported constructs"; \
    54  		echo "and fix them if necessary before submitting the code for review."; \
    55  		exit 1; \
    56  		fi
    57  	@git grep -n `echo "log"".Print"` | grep -v 'vendor/' ; if [ $$? -eq 0 ]; then \
    58  		echo "[LINT] Found "log"".Printf" calls. These should use Nomad's logger instead."; \
    59  		fi
    60  
    61  # bootstrap the build by downloading additional tools
    62  bootstrap:
    63  	@for tool in  $(EXTERNAL_TOOLS) ; do \
    64  		echo "Installing $$tool" ; \
    65  		go get $$tool; \
    66  		done
    67  	@for tool in  $(TEST_TOOLS) ; do \
    68  		echo "Installing $$tool (test dependency)" ; \
    69  		go get $$tool; \
    70  		done
    71  
    72  install: bin/nomad
    73  	install -o root -g wheel -m 0755 ./bin/nomad /usr/local/bin/nomad
    74  
    75  travis:
    76  	@sh -c "'$(PWD)/scripts/travis.sh'"
    77  
    78  .PHONY: all bin cov integ test vet test-nodep