github.com/uber-go/tally/v4@v4.1.17/Makefile (about)

     1  # "go install"-ed binaries will be placed here during development.
     2  export GOBIN ?= $(shell pwd)/bin
     3  
     4  BENCH_FLAGS ?= -cpuprofile=cpu.pprof -memprofile=mem.pprof -benchmem
     5  GO_FILES = $(shell find . \
     6  	   '(' -path '*/.*' -o -path './thirdparty/*' -prune ')' -o \
     7  	   '(' -type f -a -name '*.go' ')' -print)
     8  MODULES = . ./tools
     9  
    10  LINT_IGNORE = m3/thrift\|thirdparty
    11  LICENSE_IGNORE = m3/thrift\|thirdparty
    12  STATICCHECK_IGNORE = m3/thrift\|thirdparty\|m3/resource_pool.go:.*releaseProto is unused\|m3/reporter.go:.* argument should be pointer-like to avoid allocations
    13  
    14  GOLINT = $(GOBIN)/golint
    15  STATICCHECK = $(GOBIN)/staticcheck
    16  
    17  .PHONY: all
    18  all: lint test
    19  
    20  .PHONY: lint
    21  lint: gofmt golint gomodtidy staticcheck license
    22  
    23  .PHONY: golint
    24  golint: $(GOLINT)
    25  	@echo "Checking lint..."
    26  	@$(eval LOG := $(shell mktemp -t log.XXXXX))
    27  	@$(GOLINT) ./... | grep -v '$(LINT_IGNORE)' > $(LOG) || true
    28  	@[ ! -s "$(LOG)" ] || \
    29  		(echo "golint failed:" | \
    30  		cat - $(LOG) && false)
    31  
    32  $(GOLINT): tools/go.mod
    33  	cd tools && go install golang.org/x/lint/golint
    34  
    35  .PHONY: staticcheck
    36  staticcheck: $(STATICCHECK)
    37  	@echo "Checking staticcheck..."
    38  	@$(eval LOG := $(shell mktemp -t log.XXXXX))
    39  	@$(STATICCHECK) ./... | grep -v '$(STATICCHECK_IGNORE)' > $(LOG) || true
    40  	@[ ! -s "$(LOG)" ] || \
    41  		(echo "staticcheck failed:" | \
    42  		cat - $(LOG) && false)
    43  
    44  $(STATICCHECK):
    45  	cd tools && go install honnef.co/go/tools/cmd/staticcheck
    46  
    47  .PHONY: gofmt
    48  gofmt:
    49  	@echo "Checking formatting..."
    50  	$(eval LOG := $(shell mktemp -t log.XXXXX))
    51  	@gofmt -e -s -l $(GO_FILES) | grep -v '$(LINT_IGNORE)' > $(LOG) || true
    52  	@[ ! -s "$(LOG)" ] || \
    53  		(echo "gofmt failed. Please reformat the following files:" | \
    54  		cat - $(LOG) && false)
    55  
    56  
    57  .PHONY: gomodtidy
    58  gomodtidy: go.mod go.sum
    59  	@echo "Checking go.mod and go.sum..."
    60  	@$(foreach mod,$(MODULES),\
    61  		(cd $(mod) && go mod tidy) &&) true
    62  	@if ! git diff --quiet $^; then \
    63  		echo "go mod tidy changed files:" && \
    64  		git status --porcelain $^ && \
    65  		false; \
    66  	fi
    67  
    68  .PHONY: license
    69  license: check_license.sh
    70  	@echo "Checking for license headers..."
    71  	$(eval LOG := $(shell mktemp -t log.XXXXX))
    72  	@./check_license.sh | grep -v '$(LICENSE_IGNORE)' > $(LOG) || true
    73  	@[ ! -s "$(LOG)" ] || \
    74  		(echo "Missing license headers in some files:" | \
    75  		cat - $(LOG) && false)
    76  
    77  .PHONY: test
    78  test:
    79  	go test -race -v ./...
    80  
    81  .PHONY: examples
    82  examples:
    83  	mkdir -p ./bin
    84  	go build -o ./bin/print_example ./example/
    85  	go build -o ./bin/m3_example ./m3/example/
    86  	go build -o ./bin/prometheus_example ./prometheus/example/
    87  	go build -o ./bin/statsd_example ./statsd/example/
    88  
    89  .PHONY: cover
    90  cover:
    91  	go test -cover -coverprofile=cover.out -coverpkg=./... -race -v ./...
    92  	go tool cover -html=cover.out -o cover.html
    93  
    94  .PHONY: bench
    95  BENCH ?= .
    96  bench:
    97  	go test -bench=$(BENCH) -run="^$$" $(BENCH_FLAGS) ./...
    98