cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.52.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

Makefile

81lines · 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
36tidy:
37 go mod tidy
38 @for f in $(wildcard tools/*/go.mod) ; do echo ">>> $$f" && cd $(CURDIR)/`dirname "$$f"` && go mod tidy && cd $(CURDIR) ; done
39
40
41.PHONY: test
42test:
43 mkdir -p $(COVER_DIR)
44 echo 'mode: atomic' > $(COVER_PROFILE)
45 go test \
46 -covermode=atomic \
47 -coverprofile=$(COVER_PROFILE) \
48 -coverpkg=./... \
49 -race \
50 -count=3 \
51 -timeout=15m \
52 ./...
53
54.PHONY: debug-testscript
55debug-testscript:
56 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
57
58.PHONY: update-snapshots
59update-snapshots:
60 UPDATE_SNAPS=true UPDATE_SNAPSHOTS=1 go test -count=1 ./...
61 $(MAKE) test
62
63.PHONY: cover
64cover: test
65 go tool cover -func=$(COVER_PROFILE)
66
67.PHONY: coverhtml
68coverhtml: test
69 go tool cover -html=$(COVER_PROFILE)
70
71.PHONY: benchmark
72benchmark:
73 go test \
74 -v \
75 -count=10 \
76 -run=none \
77 -bench=. \
78 -benchmem \
79 -cpuprofile cpu.prof \
80 -memprofile mem.prof \
81 ./cmd/pint
82