-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (59 loc) · 2.17 KB
/
Makefile
File metadata and controls
79 lines (59 loc) · 2.17 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
GO ?= GO111MODULE=on CGO_ENABLED=0 go
CGO ?= GO111MODULE=on CGO_ENABLED=1 go
GOFILES_NOVENDOR := $(shell find . -name vendor -prune -o -type f -name '*.go' -not -name '*.pb.go' -print)
OK := $(shell tput setaf 6; echo ' [OK]'; tput sgr0;)
crosscompile:
@echo ">> CROSS-COMPILE"
@echo -n " BUILDING FOR LINUX AMD64 "
@GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GO) build -o bin/gocopy-linux-amd64 ./cmd/gocopy || exit 1
@printf '%s\n' '$(OK)'
@echo -n " BUILDING FOR WINDOWS AMD64 "
@GOOS=windows GOARCH=amd64 CGO_ENABLED=0 $(GO) build -o bin/gocopy-linux-amd64 ./cmd/gocopy || exit 1
@printf '%s\n' '$(OK)'
@echo -n " BUILDING FOR MACOS AMD64 "
@GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 $(GO) build -o bin/gocopy-linux-amd64 ./cmd/gocopy || exit 1
@printf '%s\n' '$(OK)'
codequality:
@echo ">> CODE QUALITY"
@echo -n " GOLANGCI-LINT "
@which golangci-lint > /dev/null; if [ $$? -ne 0 ]; then \
$(GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.1; \
fi
@golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 || exit 1
@printf '%s\n' '$(OK)'
test:
@echo ">> TEST"
@echo -n " UNIT TESTS "
@$(GO) test -v
@printf '%s\n' '$(OK)'
test-short:
@echo ">> TEST (SHORT)"
@echo -n " UNIT TESTS "
@$(GO) test -short -v
@printf '%s\n' '$(OK)'
test-race:
@echo ">> TEST (RACE)"
@echo -n " UNIT TESTS "
@$(CGO) test -race -v
@printf '%s\n' '$(OK)'
bench:
@echo ">> BENCH"
@echo -n " BENCHMARKS "
@$(GO) test -bench=. -benchmem ./...
@printf '%s\n' '$(OK)'
coverage:
@echo ">> COVERAGE"
@echo -n " TEST COVERAGE "
@$(GO) test -coverprofile=coverage.out ./...
@$(GO) tool cover -func=coverage.out | tail -1
@printf '%s\n' '$(OK)'
@$(GO) tool cover -html=coverage.out -o coverage.html
@which go-cover-treemap > /dev/null; if [ $$? -ne 0 ]; then \
$(GO) install github.com/nikolaydubina/go-cover-treemap@latest; \
fi
@go-cover-treemap -coverprofile coverage.out > coverage.svg
fmt:
@keep-sorted --mode fix $(GOFILES_NOVENDOR)
@gofumpt -w $(GOFILES_NOVENDOR)
@$(GO) mod tidy
.PHONY: clean build crosscompile test test-short test-race bench coverage codequality