cloudflare/pint

Public

mirrored from https://github.com/cloudflare/pintAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.74.3

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Makefile

84lines · modecode

1PINT_BIN := pint
2PINT_GO_DIRS := cmd internal
3PINT_SRC := $(shell find $(PINT_GO_DIRS) -type f -name '*.go')
4PINT_VERSION ?= $(shell git describe --tags --always --dirty='-dev')
5PINT_COMMIT ?= $(shell git rev-parse HEAD)
6
7GOFLAGS := -tags stringlabels
8
9COVER_DIR = .cover
10COVER_PROFILE = $(COVER_DIR)/coverage.out
11
12.PHONY: build
13build: $(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
23lint:
24 go tool -modfile=tools/golangci-lint/go.mod golangci-lint run
25
26.PHONY: format
27format:
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
32test:
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
46debug-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
50update-snapshots:
51 UPDATE_SNAPS=true UPDATE_SNAPSHOTS=1 go test -count=1 ./...
52 $(MAKE) test
53
54.PHONY: cover
55cover: test
56 go tool cover -func=$(COVER_PROFILE)
57
58.PHONY: coverhtml
59coverhtml: test
60 go tool cover -html=$(COVER_PROFILE)
61
62.PHONY: benchmark
63benchmark:
64 go test \
65 $(GOFLAGS) \
66 -timeout=15m \
67 -count=5 \
68 -run=none \
69 -bench=. \
70 -benchmem \
71 ./...
72
73.PHONY: benchmark-diff
74benchmark-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
82update-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