cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
Makefile
77lines · modecode
| 1 | PINT_BIN := pint |
| 2 | PINT_GO_DIRS := cmd internal |
| 3 | PINT_SRC := $(shell find $(PINT_GO_DIRS) -type f -name '*.go') |
| 4 | PINT_VERSION ?= $(shell git describe --tags --always --dirty='-dev') |
| 5 | PINT_COMMIT ?= $(shell git rev-parse HEAD) |
| 6 | |
| 7 | GOBIN := $(shell go env GOBIN) |
| 8 | ifeq ($(GOBIN),) |
| 9 | GOBIN = $(shell go env GOPATH)/bin |
| 10 | endif |
| 11 | |
| 12 | COVER_DIR = .cover |
| 13 | COVER_PROFILE = $(COVER_DIR)/coverage.out |
| 14 | |
| 15 | .PHONY: build |
| 16 | build: $(PINT_BIN) |
| 17 | |
| 18 | $(PINT_BIN): $(PINT_SRC) go.mod go.sum |
| 19 | CGO_ENABLED=0 go build -trimpath -ldflags='-X main.version=$(PINT_VERSION) -X main.commit=$(PINT_COMMIT) -s -w' ./cmd/pint |
| 20 | |
| 21 | $(GOBIN)/golangci-lint: tools/golangci-lint/go.mod tools/golangci-lint/go.sum |
| 22 | go install -modfile=tools/golangci-lint/go.mod github.com/golangci/golangci-lint/cmd/golangci-lint |
| 23 | .PHONY: lint |
| 24 | lint: $(GOBIN)/golangci-lint |
| 25 | $(GOBIN)/golangci-lint run |
| 26 | |
| 27 | $(GOBIN)/gofumpt: tools/gofumpt/go.mod tools/gofumpt/go.sum |
| 28 | go install -modfile=tools/gofumpt/go.mod mvdan.cc/gofumpt |
| 29 | $(GOBIN)/goimports: tools/goimports/go.mod tools/goimports/go.sum |
| 30 | go install -modfile=tools/goimports/go.mod golang.org/x/tools/cmd/goimports |
| 31 | .PHONY: format |
| 32 | format: $(GOBIN)/gofumpt $(GOBIN)/goimports |
| 33 | $(GOBIN)/gofumpt -extra -l -w . |
| 34 | $(GOBIN)/goimports -local github.com/cloudflare/pint -w . |
| 35 | |
| 36 | |
| 37 | .PHONY: test |
| 38 | test: |
| 39 | mkdir -p $(COVER_DIR) |
| 40 | echo 'mode: atomic' > $(COVER_PROFILE) |
| 41 | go test \ |
| 42 | -covermode=atomic \ |
| 43 | -coverprofile=$(COVER_PROFILE) \ |
| 44 | -coverpkg=./... \ |
| 45 | -race \ |
| 46 | -count=5 \ |
| 47 | -timeout=15m \ |
| 48 | ./... |
| 49 | |
| 50 | .PHONY: debug-testscript |
| 51 | debug-testscript: |
| 52 | for I in ./cmd/pint/tests/*.txt ; do T=`basename "$${I}" | cut -d. -f1`; echo ">>> $${T}" ; go test -count=1 -timeout=30s -v -run=TestScript/$${T} ./cmd/pint || exit 1 ; done |
| 53 | |
| 54 | .PHONY: update-snapshots |
| 55 | update-snapshots: |
| 56 | UPDATE_SNAPS=true UPDATE_SNAPSHOTS=1 go test -count=1 ./... |
| 57 | $(MAKE) test |
| 58 | |
| 59 | .PHONY: cover |
| 60 | cover: test |
| 61 | go tool cover -func=$(COVER_PROFILE) |
| 62 | |
| 63 | .PHONY: coverhtml |
| 64 | coverhtml: test |
| 65 | go tool cover -html=$(COVER_PROFILE) |
| 66 | |
| 67 | .PHONY: benchmark |
| 68 | benchmark: |
| 69 | go test \ |
| 70 | -v \ |
| 71 | -count=10 \ |
| 72 | -run=none \ |
| 73 | -bench=. \ |
| 74 | -benchmem \ |
| 75 | -cpuprofile cpu.prof \ |
| 76 | -memprofile mem.prof \ |
| 77 | ./cmd/pint |
| 78 | |