Debian Codegraph @

Makefile

raw
1 GO ?= GO111MODULE=on CGO_ENABLED=0 go
2 CGO ?= GO111MODULE=on CGO_ENABLED=1 go
3 GOFILES_NOVENDOR := $(shell find . -name vendor -prune -o -type f -name '*.go' -not -name '*.pb.go' -print)
4 OK := $(shell tput setaf 6; echo ' [OK]'; tput sgr0;)
5
6 crosscompile:
7 @echo ">> CROSS-COMPILE"
8
9 @echo -n " BUILDING FOR LINUX AMD64 "
10 @GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GO) build -o bin/gocopy-linux-amd64 ./cmd/gocopy || exit 1
11 @printf '%s\n' '$(OK)'
12
13 @echo -n " BUILDING FOR WINDOWS AMD64 "
14 @GOOS=windows GOARCH=amd64 CGO_ENABLED=0 $(GO) build -o bin/gocopy-linux-amd64 ./cmd/gocopy || exit 1
15 @printf '%s\n' '$(OK)'
16
17 @echo -n " BUILDING FOR MACOS AMD64 "
18 @GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 $(GO) build -o bin/gocopy-linux-amd64 ./cmd/gocopy || exit 1
19 @printf '%s\n' '$(OK)'
20
21 codequality:
22 @echo ">> CODE QUALITY"
23
24 @echo -n " GOLANGCI-LINT "
25 @which golangci-lint > /dev/null; if [ $$? -ne 0 ]; then \
26 $(GO) install github.com/golangci/golangci-lint/v2/cmd/[email protected]; \
27 fi
28 @golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 || exit 1
29
30 @printf '%s\n' '$(OK)'
31
32 test:
33 @echo ">> TEST"
34
35 @echo -n " UNIT TESTS "
36 @$(GO) test -v
37 @printf '%s\n' '$(OK)'
38
39 test-short:
40 @echo ">> TEST (SHORT)"
41
42 @echo -n " UNIT TESTS "
43 @$(GO) test -short -v
44 @printf '%s\n' '$(OK)'
45
46 test-race:
47 @echo ">> TEST (RACE)"
48
49 @echo -n " UNIT TESTS "
50 @$(CGO) test -race -v
51 @printf '%s\n' '$(OK)'
52
53 bench:
54 @echo ">> BENCH"
55
56 @echo -n " BENCHMARKS "
57 @$(GO) test -bench=. -benchmem ./...
58 @printf '%s\n' '$(OK)'
59
60 coverage:
61 @echo ">> COVERAGE"
62
63 @echo -n " TEST COVERAGE "
64 @$(GO) test -coverprofile=coverage.out ./...
65 @$(GO) tool cover -func=coverage.out | tail -1
66 @printf '%s\n' '$(OK)'
67 @$(GO) tool cover -html=coverage.out -o coverage.html
68 @which go-cover-treemap > /dev/null; if [ $$? -ne 0 ]; then \
69 $(GO) install github.com/nikolaydubina/go-cover-treemap@latest; \
70 fi
71 @go-cover-treemap -coverprofile coverage.out > coverage.svg
72
73 fmt:
74 @keep-sorted --mode fix $(GOFILES_NOVENDOR)
75 @gofumpt -w $(GOFILES_NOVENDOR)
76 @$(GO) mod tidy
77
78
79 .PHONY: clean build crosscompile test test-short test-race bench coverage codequality