forked from evrone/go-clean-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (63 loc) · 2.45 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
include .env.example
export
LOCAL_BIN:=$(CURDIR)/bin
PATH:=$(LOCAL_BIN):$(PATH)
.PHONY: help
help: ## Display this help screen
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
compose-up: ### Run docker-compose
docker-compose up --build -d postgres rabbitmq && docker-compose logs -f
.PHONY: compose-up
compose-up-integration-test: ### Run docker-compose with integration test
docker-compose up --build --abort-on-container-exit --exit-code-from integration
.PHONY: compose-up-integration-test
compose-down: ### Down docker-compose
docker-compose down --remove-orphans
.PHONY: compose-down
swag-v1: ### swag init
swag init -g internal/controller/http/v1/router.go
.PHONY: swag-v1
.prepare: swag-v1
DISABLE_SWAGGER_HTTP_HANDLER=''
GIN_MODE=debug
CGO_ENABLED=0
go mod tidy
go mod download
test: ### run test
CGO=1
go test -v -cover -race ./internal/...
.PHONY: test
build: .prepare ### run build
go build -tags migrate -o ./bin/ ./cmd/app
run: .prepare ### swag run
go run -tags migrate ./cmd/app
.PHONY: run
docker-rm-volume: ### remove docker volume
docker volume rm go-clean-template_pg-data
.PHONY: docker-rm-volume
linter-golangci: ### check by golangci linter
golangci-lint run
.PHONY: linter-golangci
linter-hadolint: ### check by hadolint linter
git ls-files --exclude='Dockerfile*' --ignored | xargs hadolint
.PHONY: linter-hadolint
linter-dotenv: ### check by dotenv linter
dotenv-linter
.PHONY: linter-dotenv
integration-test: ### run integration-test
go clean -testcache && go test -v ./integration-test/...
.PHONY: integration-test
mock: ### run mockgen
mockgen -source ./internal/usecase/interfaces.go -package usecase_test > ./internal/usecase/mocks_test.go
.PHONY: mock
migrate-create: ### create new migration
migrate create -ext sql -dir migrations 'migrate_name'
.PHONY: migrate-create
migrate-up: ### migration up
migrate -path migrations -database '$(PG_URL)?sslmode=disable' up
.PHONY: migrate-up
bin-deps:
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
go install go.uber.org/mock/mockgen@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest ### not recomended in wiki
go install github.com/swaggo/swag/cmd/swag@latest