-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (58 loc) · 2.58 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
DB_SSLMODE := require
# Подключаем .env файл
ifneq (,$(wildcard ./.env))
include .env
export
endif
BUILD_DIR := ./build
GOFLAGS := # Может, когда-нибудь пригодятся
LDFLAGS := -ldflags="-s -w" # Отключить дебаг-информацию
# Цели Makefile, которые не привязываются к файлам
.PHONY: build_auth build_user build_board build_poll build_utils build_all run_tests test clean coverage run generate
build_auth:
@echo "==> Building auth application..."
@CGO_ENABLED=0 GOOS=linux go build $(GOFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/auth_app ./cmd/auth
build_user:
@echo "==> Building user application..."
@CGO_ENABLED=0 GOOS=linux go build $(GOFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/user_app ./cmd/user
build_board:
@echo "==> Building board application..."
@CGO_ENABLED=0 GOOS=linux go build $(GOFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/board_app ./cmd/board
build_poll:
@echo "==> Building poll application..."
@CGO_ENABLED=0 GOOS=linux go build $(GOFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/poll_app ./cmd/poll
build_utils:
@echo "==> Building service utils program..."
@CGO_ENABLED=0 GOOS=linux go build $(GOFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/utils ./cmd/utils
build_all: build_auth build_user build_poll build_board build_utils
@echo "==> All applications are built!"
run_tests:
@echo "==> Running tests..."
@go test $(GOFLAGS) -coverprofile coverage_raw.out -v ./...
test: run_tests
@echo "==> Calculating coverage..."
@grep -vi "mock" coverage_raw.out | cat >coverage.out
@go tool cover -func=coverage.out
@go tool cover -html=coverage.out -o=coverage.html
@echo "==> Done! Check coverage.html file!"
generate:
@echo "==> Generating mocks and protobuf and easyjson..."
@go generate ./...
clean:
@echo "==> Cleaning up..."
@rm -rf $(BUILD_DIR)
migrate-up:
@which migrate
@echo "==> Running migrations..."
@migrate -path ./migrations -database $(SUPERUSER_DSN) up
make-migrations:
@echo "==> Let's generate migrations with Atlas!"
@which atlas
@echo "Provide migration name: >>> "
@read MIGRATION_NAME; echo "MIGRATION_NAME: $$MIGRATION_NAME"; \
atlas migrate diff $$MIGRATION_NAME.up --dir "file://database/migrations" --to "file://database/schema.sql" --dev-url "$(TEST_DATABASE_URL)"
gen-test-certs:
@echo "==> Lets generate certificates that are suitable for testing!"
@mkdir -p certs
@openssl req -x509 -newkey rsa:2048 -nodes -keyout certs/cert.pem -out certs/cert.crt -days 365 -subj '/CN=localhost'
@echo "==> Success! Enjoy & be happy!"