-
Notifications
You must be signed in to change notification settings - Fork 135
/
Makefile
106 lines (83 loc) · 3.38 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
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
103
104
105
106
.PHONY: deps gen lint format check-format test test-coverage add-license \
check-comments check-license shorten-lines shellcheck salus release mocks
# To run the the following packages as commands,
# it is necessary to use `go run <pkg>`. Running `go get` does
# not install any binaries that could be used to run
# the commands directly.
ADDLICENSE_INSTALL=go install github.com/google/addlicense@latest
ADDLICENSE_CMD=addlicense
ADDLICENSE_IGNORE=-ignore ".github/**/*" -ignore ".idea/**/*"
ADDLICENCE_SCRIPT=${ADDLICENSE_CMD} -c "Coinbase, Inc." -l "apache" -v ${ADDLICENSE_IGNORE}
GOIMPORTS_INSTALL=go install golang.org/x/tools/cmd/goimports@latest
GOIMPORTS_CMD=goimports
GOLINES_INSTALL=go install github.com/segmentio/golines@latest
GOLINES_CMD=golines
GOVERALLS_INSTALL=go install github.com/mattn/goveralls@latest
GOVERALLS_CMD=goveralls
GOLINT_CMD=go run golang.org/x/lint/golint
GO_PACKAGES=./asserter/... ./fetcher/... ./client/... ./server/... \
./parser/... ./syncer/... ./reconciler/... ./keys/... \
./statefulsyncer/... ./storage/... ./utils/... ./constructor/... ./errors/...
GO_MOD_PACKAGES=./types/...
GO_FOLDERS=$(shell echo ${GO_PACKAGES} | sed -e "s/\.\///g" | sed -e "s/\/\.\.\.//g")
GO_MOD_FOLDERS=$(shell echo ${GO_MOD_PACKAGES} | sed -e "s/\.\///g" | sed -e "s/\/\.\.\.//g")
TEST_SCRIPT=go test ${GO_PACKAGES}
LINT_SETTINGS=misspell,gocyclo,gocritic,whitespace,goconst,gocognit,bodyclose,unconvert,lll,unparam
build:
go build ./...
deps:
go get ./...
install:
go install ./...
gen:
./codegen.sh;
check-gen: | gen
git diff --exit-code
fix-imports:
./imports.sh;
check-comments:
${GOLINT_CMD} -set_exit_status ${GO_FOLDERS} .
${GOLINT_CMD} -set_exit_status ${GO_MOD_FOLDERS} .
lint-examples:
cd examples; \
golangci-lint run -v -E ${LINT_SETTINGS}
lint: | lint-examples
golangci-lint run --timeout 2m0s -v -E ${LINT_SETTINGS},gomnd
format:
gofmt -s -w -l .
${GOIMPORTS_INSTALL}
${GOIMPORTS_CMD} -w .
check-format:
! gofmt -s -l . | read;
${GOIMPORTS_INSTALL}
! ${GOIMPORTS_CMD} -l . | read;
test:
${TEST_SCRIPT}
test-cover:
${GOVERALLS_INSTALL}
if [ "${COVERALLS_TOKEN}" ]; then ${TEST_SCRIPT} -coverprofile=c.out -covermode=count; ${GOVERALLS_CMD} -coverprofile=c.out -repotoken ${COVERALLS_TOKEN}; fi
add-license:
${ADDLICENSE_INSTALL}
${ADDLICENCE_SCRIPT} .
check-license:
${ADDLICENSE_INSTALL}
${ADDLICENCE_SCRIPT} -check .
shorten-lines:
${GOLINES_INSTALL}
${GOLINES_CMD} -w --shorten-comments ${GO_FOLDERS} examples
${GOLINES_CMD} -w --shorten-comments ${GO_MOD_FOLDERS}
shellcheck:
shellcheck codegen.sh
salus:
docker run --rm -t -v ${PWD}:/home/repo coinbase/salus
release: shellcheck check-license check-format lint salus
mocks:
rm -rf mocks;
mockery --dir syncer --all --case underscore --outpkg syncer --output mocks/syncer;
mockery --dir reconciler --all --case underscore --outpkg reconciler --output mocks/reconciler;
mockery --dir constructor/worker --all --case underscore --outpkg worker --output mocks/constructor/worker;
mockery --dir constructor/coordinator --all --case underscore --outpkg coordinator --output mocks/constructor/coordinator;
mockery --dir utils --all --case underscore --outpkg utils --output mocks/utils;
mockery --dir storage/database --all --case underscore --outpkg database --output mocks/storage/database;
mockery --dir storage/modules --all --case underscore --outpkg modules --output mocks/storage/modules;
${ADDLICENCE_SCRIPT} .;