go-clean-template
/
Makefile
74 строки · 2.4 Кб
1include .env.example
2export
3
4LOCAL_BIN:=$(CURDIR)/bin
5PATH:=$(LOCAL_BIN):$(PATH)
6
7# HELP =================================================================================================================
8# This will output the help for each task
9# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
10.PHONY: help
11
12help: ## Display this help screen
13@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)
14
15compose-up: ### Run docker-compose
16docker-compose up --build -d postgres rabbitmq && docker-compose logs -f
17.PHONY: compose-up
18
19compose-up-integration-test: ### Run docker-compose with integration test
20docker-compose up --build --abort-on-container-exit --exit-code-from integration
21.PHONY: compose-up-integration-test
22
23compose-down: ### Down docker-compose
24docker-compose down --remove-orphans
25.PHONY: compose-down
26
27swag-v1: ### swag init
28swag init -g internal/controller/http/v1/router.go
29.PHONY: swag-v1
30
31run: swag-v1 ### swag run
32go mod tidy && go mod download && \
33DISABLE_SWAGGER_HTTP_HANDLER='' GIN_MODE=debug CGO_ENABLED=0 go run -tags migrate ./cmd/app
34.PHONY: run
35
36docker-rm-volume: ### remove docker volume
37docker volume rm go-clean-template_pg-data
38.PHONY: docker-rm-volume
39
40linter-golangci: ### check by golangci linter
41golangci-lint run
42.PHONY: linter-golangci
43
44linter-hadolint: ### check by hadolint linter
45git ls-files --exclude='Dockerfile*' --ignored | xargs hadolint
46.PHONY: linter-hadolint
47
48linter-dotenv: ### check by dotenv linter
49dotenv-linter
50.PHONY: linter-dotenv
51
52test: ### run test
53go test -v -cover -race ./internal/...
54.PHONY: test
55
56integration-test: ### run integration-test
57go clean -testcache && go test -v ./integration-test/...
58.PHONY: integration-test
59
60mock: ### run mockgen
61mockgen -source ./internal/usecase/interfaces.go -package usecase_test > ./internal/usecase/mocks_test.go
62.PHONY: mock
63
64migrate-create: ### create new migration
65migrate create -ext sql -dir migrations 'migrate_name'
66.PHONY: migrate-create
67
68migrate-up: ### migration up
69migrate -path migrations -database '$(PG_URL)?sslmode=disable' up
70.PHONY: migrate-up
71
72bin-deps:
73GOBIN=$(LOCAL_BIN) go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
74GOBIN=$(LOCAL_BIN) go install github.com/golang/mock/mockgen@latest
75