-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (79 loc) · 2.97 KB
/
Makefile
File metadata and controls
102 lines (79 loc) · 2.97 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
GIT_COMMIT=$(shell git log -1 --format=%H)
GIT_TAG=$(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match)
BUILD_DATE=$(shell date -Is -u)
TEST_WAIT_SHORT=5s
TEST_WAIT_LONG=20s
.PHONY: all
all: chorus proxy worker chorctl bench
.PHONY: tidy
tidy:
go mod tidy
cd tools/chorctl; go mod tidy
cd tools/bench; go mod tidy
.PHONY: gen
gen:
go generate ./...
.PHONY: vet
vet:
go vet ./...
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: imports
imports:
go tool goimports -local github.com/clyso/chorus -w ./cmd
go tool goimports -local github.com/clyso/chorus -w ./pkg
go tool goimports -local github.com/clyso/chorus -w ./service
go tool goimports -local github.com/clyso/chorus -w ./tools
.PHONY: fieldalignment
fieldalignment:
until go tool betteralign -apply ./pkg/... ./test/... ./cmd/... ; do :; done
cd ./tools/chorctl && until go tool betteralign -apply ./... ; do :; done
cd ./tools/bench && until go tool betteralign -apply ./... ; do :; done
.PHONY: lint
lint:
go tool golangci-lint run
.PHONY: vuln
vuln:
go tool govulncheck ./...
.PHONY: license-check
license-check:
find . -name "*.go" ! -name "*_test.go" | xargs go tool addlicense -check -c 'Clyso GmbH' || (echo "Missing license headers (run make license-fix):"; exit 1)
.PHONY: license-fix
license-fix:
find . -name "*.go" ! -name "*_test.go" | xargs go tool addlicense -c 'Clyso GmbH' || (echo "Missing license headers"; exit 1)
.PHONY: pretty
pretty: tidy gen fmt vet imports fieldalignment lint vuln license-check
.PHONY: mkdir-build
mkdir-build:
mkdir -p build
# This target matches all targets ending with `-bin` and allows to execute
# common goals only once per project, instead of once per every binary.
# Means, formatting and linting would be executed once for whole repository.
# `:` is a no-op operator in shell.
%-bin: pretty mkdir-build
:
.PHONY: chorus
chorus: chorus-bin
go build -ldflags="-X 'main.date=$(BUILD_DATE)' -X 'main.version=$(GIT_TAG)' -X 'main.commit=$(GIT_COMMIT)'" -o build/chorus cmd/chorus/main.go
.PHONY: proxy
proxy: proxy-bin
go build -ldflags="-X 'main.date=$(BUILD_DATE)' -X 'main.version=$(GIT_TAG)' -X 'main.commit=$(GIT_COMMIT)'" -o build/proxy cmd/proxy/main.go
.PHONY: worker
worker: worker-bin
go build -ldflags="-X 'main.date=$(BUILD_DATE)' -X 'main.version=$(GIT_TAG)' -X 'main.commit=$(GIT_COMMIT)'" -o build/worker cmd/worker/main.go
.PHONY: chorctl
chorctl: chorctl-bin
cd tools/chorctl; go build -ldflags="-X 'main.date=$(BUILD_DATE)' -X 'main.version=$(GIT_TAG)' -X 'main.commit=$(GIT_COMMIT)'" -o ../../build/chorctl main.go
.PHONY: bench
bench: bench-bin
cd tools/bench; go build -ldflags="-X 'main.date=$(BUILD_DATE)' -X 'main.version=$(GIT_TAG)' -X 'main.commit=$(GIT_COMMIT)'" -o ../../build/bench main.go
.PHONY: test
test: pretty
TEST_WAIT_SHORT=$(TEST_WAIT_SHORT) TEST_WAIT_LONG=$(TEST_WAIT_LONG) go test ./...
.PHONY: proto-gen
proto-gen:
cd proto; go tool buf generate --template "buf.gen.yaml" --config "buf.yaml"
.PHONY: clean
clean:
rm -rf build/