-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
91 lines (63 loc) · 1.95 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
APP=stock-sync
APP_VERSION:=0.1
APP_COMMIT:=$(shell git rev-parse HEAD)
APP_EXECUTABLE="./out/$(APP)"
ALL_PACKAGES=$(shell go list ./... | grep -v "vendor")
CONFIG_FILE="./.env"
HTTP_SERVE_COMMAND="http-serve"
MIGRATE_COMMAND="migrate"
ROLLBACK_COMMAND="rollback"
setup: copy-config migrate
infra-local:
docker-compose -f build/docker-compose.infra-basics.yml -f build/docker-compose.network.yml up -d
compile:
mkdir -p out/
go build -ldflags "-X main.version=$(APP_VERSION) -X main.commit=$(APP_COMMIT)" -o $(APP_EXECUTABLE) cmd/*.go
build: deps compile
http-serve: build
$(APP_EXECUTABLE) -configFile=$(configFile) $(HTTP_SERVE_COMMAND)
app:
docker-compose -f build/docker-compose.app-stock.yml -f build/docker-compose.network.yml up -d --build
docker logs stock-service-go
http-local-serve: build
$(APP_EXECUTABLE) -configFile=$(CONFIG_FILE) $(HTTP_SERVE_COMMAND)
grpc-serve: build
$(APP_EXECUTABLE) -configFile=$(configFile) $(GRPC_SERVE_COMMAND)
grpc-local-serve: build
$(APP_EXECUTABLE) -configFile=$(CONFIG_FILE) $(GRPC_SERVE_COMMAND)
copy-config:
cp .env.sample .env
tidy:
go mod tidy
deps:
go mod download
check: fmt vet lint
fmt:
go fmt $(ALL_PACKAGES)
vet:
go vet $(ALL_PACKAGES)
clean:
rm -rf out/
test:
go clean -testcache
go test ./...
test-cover-html:
go clean -testcache
mkdir -p out/
go test ./... -coverprofile=out/coverage.out
go tool cover -html=out/coverage.out
ci-test: init-db migrate test
migrate: build
$(APP_EXECUTABLE) -configFile=$(CONFIG_FILE) $(MIGRATE_COMMAND)
rollback: build
$(APP_EXECUTABLE) -configFile=$(CONFIG_FILE) $(ROLLBACK_COMMAND)
check-swagger:
which swagger || (go get -u github.com/go-swagger/go-swagger/cmd/swagger)
swagger: check-swagger
swagger generate spec -o ./swagger.yaml --scan-models
serve-swagger: check-swagger
swagger serve -F=swagger swagger.yaml
lint:
golangci-lint run cmd/... pkg/...
dependency-check:
go list -json -m all | nancy sleuth --exclude-vulnerability-file ./.nancy-ignore