cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.29.3

Branches

Tags

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

Clone

HTTPS

Download ZIP

Makefile

77lines · 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
7GOBIN := $(shell go env GOBIN)
8ifeq ($(GOBIN),)
9GOBIN = $(shell go env GOPATH)/bin
10endif
11
12COVER_DIR = .cover
13COVER_PROFILE = $(COVER_DIR)/coverage.out
14
15.PHONY: build
16build: $(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
24lint: $(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
32format: $(GOBIN)/gofumpt $(GOBIN)/goimports
33 $(GOBIN)/gofumpt -extra -l -w .
34 $(GOBIN)/goimports -local github.com/cloudflare/pint -w .
35
36
37.PHONY: test
38test:
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
51debug-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
55update-snapshots:
56 UPDATE_SNAPS=true UPDATE_SNAPSHOTS=1 go test -count=1 ./...
57 $(MAKE) test
58
59.PHONY: cover
60cover: test
61 go tool cover -func=$(COVER_PROFILE)
62
63.PHONY: coverhtml
64coverhtml: test
65 go tool cover -html=$(COVER_PROFILE)
66
67.PHONY: benchmark
68benchmark:
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