cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
Makefile
84lines · 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 | GOFLAGS := -tags stringlabels |
| 8 | |
| 9 | COVER_DIR = .cover |
| 10 | COVER_PROFILE = $(COVER_DIR)/coverage.out |
| 11 | |
| 12 | .PHONY: build |
| 13 | build: $(PINT_BIN) |
| 14 | |
| 15 | $(PINT_BIN): $(PINT_SRC) go.mod go.sum |
| 16 | CGO_ENABLED=0 go build \ |
| 17 | $(GOFLAGS) \ |
| 18 | -trimpath \ |
| 19 | -ldflags='-X main.version=$(PINT_VERSION) -X main.commit=$(PINT_COMMIT) -s -w' \ |
| 20 | ./cmd/pint |
| 21 | |
| 22 | .PHONY: lint |
| 23 | lint: |
| 24 | go tool -modfile=tools/golangci-lint/go.mod golangci-lint run |
| 25 | |
| 26 | .PHONY: format |
| 27 | format: |
| 28 | go tool -modfile=tools/betteralign/go.mod betteralign -test_files -apply ./... |
| 29 | go tool -modfile=tools/golangci-lint/go.mod golangci-lint fmt |
| 30 | |
| 31 | .PHONY: test |
| 32 | test: |
| 33 | mkdir -p $(COVER_DIR) |
| 34 | echo 'mode: atomic' > $(COVER_PROFILE) |
| 35 | go test \ |
| 36 | $(GOFLAGS) \ |
| 37 | -covermode=atomic \ |
| 38 | -coverprofile=$(COVER_PROFILE) \ |
| 39 | -coverpkg=./... \ |
| 40 | -race \ |
| 41 | -count=3 \ |
| 42 | -timeout=15m \ |
| 43 | ./... |
| 44 | |
| 45 | .PHONY: debug-testscript |
| 46 | debug-testscript: |
| 47 | 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 |
| 48 | |
| 49 | .PHONY: update-snapshots |
| 50 | update-snapshots: |
| 51 | UPDATE_SNAPS=true UPDATE_SNAPSHOTS=1 go test -count=1 ./... |
| 52 | $(MAKE) test |
| 53 | |
| 54 | .PHONY: cover |
| 55 | cover: test |
| 56 | go tool cover -func=$(COVER_PROFILE) |
| 57 | |
| 58 | .PHONY: coverhtml |
| 59 | coverhtml: test |
| 60 | go tool cover -html=$(COVER_PROFILE) |
| 61 | |
| 62 | .PHONY: benchmark |
| 63 | benchmark: |
| 64 | go test \ |
| 65 | $(GOFLAGS) \ |
| 66 | -timeout=15m \ |
| 67 | -count=5 \ |
| 68 | -run=none \ |
| 69 | -bench=. \ |
| 70 | -benchmem \ |
| 71 | ./... |
| 72 | |
| 73 | .PHONY: benchmark-diff |
| 74 | benchmark-diff: |
| 75 | echo "Benchmark diff:" | tee benchstat.txt |
| 76 | echo "" | tee -a benchstat.txt |
| 77 | echo '```' | tee -a benchstat.txt |
| 78 | go tool -modfile=tools/benchstat/go.mod benchstat old.txt new.txt | tee -a benchstat.txt |
| 79 | echo '```' | tee -a benchstat.txt |
| 80 | |
| 81 | .PHONY: update-major-imports |
| 82 | update-major-imports: |
| 83 | @grep '/v' go.mod | grep -v '// indirect' | cut -d/ -f -3 | while read L ; do echo ">>> $$L" ; go tool -modfile=tools/gomajor/go.mod gomajor get -major "$$L"@latest ; done |
| 84 | go mod tidy |
| 85 | |