forked from nt0xa/sonar
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (80 loc) · 1.99 KB
/
Makefile
File metadata and controls
104 lines (80 loc) · 1.99 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
103
104
#
# Build
#
.PHONY: build
build: build-server build-client
.PHONY: build-server
build-server:
@go build -o server ./cmd/server
.PHONY: build-client
build-client:
@go build -o sonar ./cmd/client
#
# Test
#
.PHONY: test
test:
@go test ./... -v -p 1 -coverprofile coverage.out
.PHONY: coverage
coverage:
@go tool cover -func=coverage.out
.PHONY: coverage-html
coverage-html:
@go tool cover -html=coverage.out
.PHONY: mock
mock: mock-actions
.PHONY: mock-actions
mock-actions:
@mockery \
--dir internal/actions \
--output internal/actions/mock \
--outpkg actions_mock \
--name Actions
@mockery \
--dir internal/actions \
--output internal/actions/mock \
--outpkg actions_mock \
--name ResultHandler
#
# Code generation
#
.PHONY: gen
gen: gen-api gen-cmd gen-apiclient
.PHONY: gen-api
gen-api:
@go run ./internal/codegen/*.go -type api > internal/modules/api/generated.go
@go fmt ./internal/modules/api
.PHONY: gen-cmd
gen-cmd:
@go run ./internal/codegen/*.go -type cmd > internal/cmd/generated.go
@go fmt ./internal/cmd
.PHONY: gen-apiclient
gen-apiclient:
@go run ./internal/codegen/*.go -type apiclient > internal/modules/api/apiclient/generated.go
@go fmt ./internal/modules/api/apiclient
#
# Migrations
#
migrations = ./internal/database/migrations
db_url = ${SONAR_DB_DSN}
.PHONY: migrations-create
migrations-create:
@migrate create -ext sql -dir ${migrations} -seq ${name}
.PHONY: migrations-list
migrations-list:
@ls ${migrations} | grep '.sql' | cut -d '.' -f 1 | sort | uniq
.PHONY: migrations-up
migrations-up:
@migrate -path ${migrations} -database ${db_url} up ${n}
.PHONY: migrations-down
migrations-down:
@migrate -path ${migrations} -database ${db_url} down ${n}
.PHONY: migrations-goto
migrations-goto:
@migrate -path ${migrations} -database ${db_url} goto ${v}
.PHONY: migrations-drop
migrations-drop:
@migrate -path ${migrations} -database ${db_url} drop
.PHONY: migrations-force
migrations-force:
@migrate -path ${migrations} -database ${db_url} force ${v}