forked from thrasher-corp/gocryptotrader
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
68 lines (54 loc) · 1.83 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
LDFLAGS = -ldflags "-w -s"
GCTPKG = github.com/thrasher-corp/gocryptotrader
LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.31.0
LINTBIN = $(GOPATH)/bin/golangci-lint
GCTLISTENPORT=9050
GCTPROFILERLISTENPORT=8085
CRON = $(TRAVIS_EVENT_TYPE)
DRIVER ?= psql
RACE_FLAG := $(if $(NO_RACE_TEST),,-race)
CONFIG_FLAG = $(if $(CONFIG),-config $(CONFIG),)
.PHONY: get linter check test build install update_deps
all: check build
get:
GO111MODULE=on go get $(GCTPKG)
linter:
GO111MODULE=on go get $(GCTPKG)
GO111MODULE=on go get $(LINTPKG)
test -z "$$($(LINTBIN) run --verbose | tee /dev/stderr)"
check: linter test
test:
ifeq ($(CRON), cron)
go test $(RACE_FLAG) -tags=mock_test_off -coverprofile=coverage.txt -covermode=atomic ./...
else
go test $(RACE_FLAG) -coverprofile=coverage.txt -covermode=atomic ./...
endif
build:
GO111MODULE=on go build $(LDFLAGS)
install:
GO111MODULE=on go install $(LDFLAGS)
fmt:
gofmt -l -w -s $(shell find . -type f -name '*.go')
update_deps:
GO111MODULE=on go mod verify
GO111MODULE=on go mod tidy
rm -rf vendor
GO111MODULE=on go mod vendor
.PHONY: profile_heap
profile_heap:
go tool pprof -http "localhost:$(GCTPROFILERLISTENPORT)" 'http://localhost:$(GCTLISTENPORT)/debug/pprof/heap'
.PHONY: profile_cpu
profile_cpu:
go tool pprof -http "localhost:$(GCTPROFILERLISTENPORT)" 'http://localhost:$(GCTLISTENPORT)/debug/pprof/profile'
.PHONY: gen_db_models
gen_db_models: target/sqlboiler.json
ifeq ($(DRIVER), psql)
sqlboiler -c $< -o database/models/postgres -p postgres --no-auto-timestamps --wipe $(DRIVER)
else ifeq ($(DRIVER), sqlite3)
sqlboiler -c $< -o database/models/sqlite3 -p sqlite3 --no-auto-timestamps --wipe $(DRIVER)
else
$(error Driver '$(DRIVER)' not supported)
endif
target/sqlboiler.json:
mkdir -p $(@D)
go run ./cmd/gen_sqlboiler_config/main.go $(CONFIG_FLAG) -outdir $(@D)