go-clean-template

Форк
0
74 строки · 2.4 Кб
1
include .env.example
2
export
3

4
LOCAL_BIN:=$(CURDIR)/bin
5
PATH:=$(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

12
help: ## 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

15
compose-up: ### Run docker-compose
16
	docker-compose up --build -d postgres rabbitmq && docker-compose logs -f
17
.PHONY: compose-up
18

19
compose-up-integration-test: ### Run docker-compose with integration test
20
	docker-compose up --build --abort-on-container-exit --exit-code-from integration
21
.PHONY: compose-up-integration-test
22

23
compose-down: ### Down docker-compose
24
	docker-compose down --remove-orphans
25
.PHONY: compose-down
26

27
swag-v1: ### swag init
28
	swag init -g internal/controller/http/v1/router.go
29
.PHONY: swag-v1
30

31
run: swag-v1 ### swag run
32
	go mod tidy && go mod download && \
33
	DISABLE_SWAGGER_HTTP_HANDLER='' GIN_MODE=debug CGO_ENABLED=0 go run -tags migrate ./cmd/app
34
.PHONY: run
35

36
docker-rm-volume: ### remove docker volume
37
	docker volume rm go-clean-template_pg-data
38
.PHONY: docker-rm-volume
39

40
linter-golangci: ### check by golangci linter
41
	golangci-lint run
42
.PHONY: linter-golangci
43

44
linter-hadolint: ### check by hadolint linter
45
	git ls-files --exclude='Dockerfile*' --ignored | xargs hadolint
46
.PHONY: linter-hadolint
47

48
linter-dotenv: ### check by dotenv linter
49
	dotenv-linter
50
.PHONY: linter-dotenv
51

52
test: ### run test
53
	go test -v -cover -race ./internal/...
54
.PHONY: test
55

56
integration-test: ### run integration-test
57
	go clean -testcache && go test -v ./integration-test/...
58
.PHONY: integration-test
59

60
mock: ### run mockgen
61
	mockgen -source ./internal/usecase/interfaces.go -package usecase_test > ./internal/usecase/mocks_test.go
62
.PHONY: mock
63

64
migrate-create:  ### create new migration
65
	migrate create -ext sql -dir migrations 'migrate_name'
66
.PHONY: migrate-create
67

68
migrate-up: ### migration up
69
	migrate -path migrations -database '$(PG_URL)?sslmode=disable' up
70
.PHONY: migrate-up
71

72
bin-deps:
73
	GOBIN=$(LOCAL_BIN) go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
74
	GOBIN=$(LOCAL_BIN) go install github.com/golang/mock/mockgen@latest
75

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.