-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
77 lines (58 loc) · 2.02 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
.PHONY: init configure add-commit-hook dev build-release test test_cov lint \
pb_pkg_gen pb_internal_gen pb_model_gen pb_service_gen pb_pkg_mock_gen
PKG_PATH=go.neonyx.io
PROJECT=go-swn
VERSION = 0
PATCHLEVEL = 0
SUBLEVEL = 1
EXTRAVERSION = -rc1
DEV_VERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
RELEASE_VERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))
DEPLOYMENT_DIR=./deployment
init: configure add-commit-hook
@if [ -f go.mod ]; then \
echo "[!] go.mod exists"; \
else \
go mod init $(PKG_PATH)/$(PROJECT); \
fi
configure:
@bash $(DEPLOYMENT_DIR)/configure.sh
add-commit-hook:
@echo "[*] Installing git commit hook..."
pre-commit install -t commit-msg
build-dev:
@echo "[*] Building Docker image for development..."
docker build -t $(PROJECT):$(DEV_VERSION) .
dev:
@echo "[*] Running Docker container: $(PROJECT)..."
docker run --rm --name $(PROJECT) -v $(PWD)/data:/app/data \
$(ARGS) $(PROJECT):$(DEV_VERSION) $(CMD_ARGS)
build-release:
@echo "[*] Building Docker image for release..."
docker build --build-arg GO_FLAGS=-ldflags="-s -w" -t $(PROJECT):$(RELEASE_VERSION) .
test:
@echo "[*] Running Go tests..."
go test ./... $(ARGS)
test_cov:
@echo "[*] Running Go tests with coverage..."
go test ./... -coverprofile=cover.out
go tool cover -html=cover.out
lint:
@echo "[*] Running linters..."
golangci-lint run
## Protobuf targets ##
include $(DEPLOYMENT_DIR)/proto.mk
# generate all pkg/* models and services .proto files
pb_pkg_gen: pb_pkg_model_gen pb_pkg_service_gen
pb_pkg_mock_gen:
mockgen -source=pkg/bus/pb/bus_api_grpc.pb.go \
-destination=pkg/bus/pb/bus_api_mock.go \
-package=pb
# generate all internal/* models and services .proto files
pb_internal_gen: pb_internal_model_gen pb_internal_service_gen
# generate a given model protobuf in PROTO= CLI argument
pb_model_gen:
$(call protoc_model,$(PROTO))
# generate a given service protobuf in PROTO= CLI argument
pb_service_gen:
$(call protoc_service,$(PROTO))