-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (45 loc) · 2.05 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
CURDIR=$(shell pwd)
BINDIR=${CURDIR}/bin
GOVER=$(shell go version | perl -nle '/(go\d\S+)/; print $$1;')
MOCKGEN=${BINDIR}/mockgen_${GOVER}
SMARTIMPORTS=${BINDIR}/smartimports_${GOVER}
LINTVER=v1.49.0
LINTBIN=${BINDIR}/lint_${GOVER}_${LINTVER}
PACKAGE=gitlab.ozon.dev/myasnikov.alexander.s/telegram-bot/cmd/bot
all: format build test lint
build: bindir
go build -o ${BINDIR}/bot ${PACKAGE}
test:
go test -v -covermode=count -coverprofile=coverage.out -short ./...
go tool cover -func=coverage.out
go tool cover -html=coverage.out -o coverage.html
run:
go run ${PACKAGE}
generate: install-mockgen
${MOCKGEN} -source=internal/usecase/expense.go -destination=internal/usecase/mock_usecase/expense.go
${MOCKGEN} -source=internal/textrouter/texthandler/set_default_currency.go -destination=internal/textrouter/texthandler/mock_texthandler/set_default_currency.go
${MOCKGEN} -source=internal/textrouter/texthandler/add_expense.go -destination=internal/textrouter/texthandler/mock_texthandler/add_expense.go
${MOCKGEN} -source=internal/textrouter/texthandler/get_report.go -destination=internal/textrouter/texthandler/mock_texthandler/get_report.go
protoc --go_out=. --go_opt=paths=source_relative --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative ./internal/adapter/service/report/report.proto
lint: install-lint
${LINTBIN} run
precommit: generate format build test lint
echo "OK"
bindir:
mkdir -p ${BINDIR}
format: install-smartimports
${SMARTIMPORTS} -exclude internal/mocks
install-mockgen: bindir
test -f ${MOCKGEN} || \
(GOBIN=${BINDIR} go install github.com/golang/mock/[email protected] && \
mv ${BINDIR}/mockgen ${MOCKGEN})
install-lint: bindir
test -f ${LINTBIN} || \
(GOBIN=${BINDIR} go install github.com/golangci/golangci-lint/cmd/golangci-lint@${LINTVER} && \
mv ${BINDIR}/golangci-lint ${LINTBIN})
install-smartimports: bindir
test -f ${SMARTIMPORTS} || \
(GOBIN=${BINDIR} go install github.com/pav5000/smartimports/cmd/smartimports@latest && \
mv ${BINDIR}/smartimports ${SMARTIMPORTS})
docker-run:
docker compose up