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