-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (45 loc) · 1.83 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
GO_BIN?=GOTOOLCHAIN=local go
all: info test lint size-check coverage example
info:
@echo "### Go (using GO_BIN=\"$(GO_BIN)\") version:"
$(GO_BIN) version
test:
$(GO_BIN) test -race ./...
$(GO_BIN) test -tags no_json ./...
$(GO_BIN) test -tags no_http ./...
local-coverage: coverage
$(GO_BIN) test -coverprofile=coverage.out ./...
$(GO_BIN) tool cover -html=coverage.out
coverage:
$(GO_BIN) test -coverprofile=coverage1.out ./...
$(GO_BIN) test -tags no_net -coverprofile=coverage2.out ./...
$(GO_BIN) test -tags no_json -coverprofile=coverage3.out ./...
$(GO_BIN) test -tags no_http,no_json -coverprofile=coverage4.out ./...
# cat coverage*.out > coverage.out
$(GO_BIN) install github.com/wadey/gocovmerge@b5bfa59ec0adc420475f97f89b58045c721d761c
gocovmerge coverage?.out > coverage.out
example:
@echo "### Colorized (default) ###"
$(GO_BIN) run ./levelsDemo
@echo "### JSON: (redirected stderr) ###"
$(GO_BIN) run ./levelsDemo 3>&1 1>&2 2>&3 | jq -c
line:
@echo
# Suitable to make a screenshot with a bit of spaces around for updating color.png
screenshot: line example
@echo
size-check:
@echo "### Size of the binary:"
CGO_ENABLED=0 $(GO_BIN) build -ldflags="-w -s" -trimpath -o ./fullsize ./levelsDemo
ls -lh ./fullsize
CGO_ENABLED=0 $(GO_BIN) build -tags no_net -ldflags="-w -s" -trimpath -o ./smallsize ./levelsDemo
ls -lh ./smallsize
CGO_ENABLED=0 $(GO_BIN) build -tags no_http,no_json -ldflags="-w -s" -trimpath -o ./smallsize ./levelsDemo
ls -lh ./smallsize
gsa ./smallsize # go install github.com/Zxilly/go-size-analyzer/cmd/gsa@master
lint: .golangci.yml
golangci-lint run
golangci-lint run --build-tags no_json
.golangci.yml: Makefile
curl -fsS -o .golangci.yml https://raw.githubusercontent.com/fortio/workflows/main/golangci.yml
.PHONY: all info test lint size-check local-coverage example screenshot line coverage