-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
161 lines (130 loc) · 4.42 KB
/
Copy pathMakefile
File metadata and controls
161 lines (130 loc) · 4.42 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
SHELL := /bin/bash # Use bash shell on Unix
TENK_ENV ?= development
GQLGEN_CMD = github.com/99designs/gqlgen
ENV_FILE ?= .env.$(TENK_ENV)
DB_URI=mongodb+srv://$(MONGO_USER):$(MONGO_PASSWORD)@$(MONGO_ADDRESS)/$(MONGO_DATABASE_NAME)
# export .env file
-include $(ENV_FILE)
core:
@echo "Starting core service..."
ifeq ($(OS),Windows_NT)
set TENK_ENV=$(TENK_ENV) && air -c ./tools/air-configs/core.air.toml
else
export TENK_ENV=$(TENK_ENV) && air -c ./tools/air-configs/core.air.toml
endif
analytic:
@echo "Starting analytic service..."
ifeq ($(OS),Windows_NT)
set TENK_ENV=$(TENK_ENV) && air -c ./tools/air-configs/analytic.air.toml
else
export TENK_ENV=$(TENK_ENV) && air -c ./tools/air-configs/analytic.air.toml
endif
notification:
@echo "Starting notification service..."
ifeq ($(OS),Windows_NT)
set TENK_ENV=$(TENK_ENV) && air -c ./tools/air-configs/notification.air.toml
else
export TENK_ENV=$(TENK_ENV) && air -c ./tools/air-configs/notification.air.toml
endif
currency:
@echo "Starting currency service..."
ifeq ($(OS),Windows_NT)
set TENK_ENV=$(TENK_ENV) && air -c ./tools/air-configs/currency.air.toml
else
export TENK_ENV=$(TENK_ENV) && air -c ./tools/air-configs/currency.air.toml
endif
penk:
@echo "Starting penk service..."
cd services/penk && npm run start
payment:
@echo "Starting payment service..."
cd services/payment && npm run start
gateway:
@cd services/gateway && npm run dev
dev:
mkdir -p tmp
$(MAKE) -j $(SERVICE)
test:
mkdir -p tmp
$(MAKE) TENK_ENV=test -j $(SERVICE)
# Tidy go modules in workspace
tidy:
@for module in $(shell find . -name 'go.mod' -exec dirname {} \;); do \
echo "Running go mod tidy in $$module"; \
(cd $$module && go mod tidy); \
done
# Generage gqlgen code
gqlgen:
@echo "Generating gqlgen code for services: $(SERVICE)"
@for service in $(SERVICE); do \
echo "Running gqlgen for service: $$service"; \
go run -C ./services/$$service/transport $(GQLGEN_CMD); \
done
# Get new JWT token
token:
@echo "Getting new JWT token..."
@go run cmd/main.go jwt -u $(UID)
# Protocol Buffers Compiler
protoc:
@echo "Generating protobuf code..."
@find ./proto -name "*.proto" -exec \
protoc --proto_path=./proto \
--go_out=./proto/pb --go_opt=paths=source_relative \
--go-grpc_out=./proto/pb --go-grpc_opt=paths=source_relative \
{} \;
protolint:
@echo "Running protolint..."
@protolint lint ./proto
protolint-fix:
@echo "Running protolint with fix..."
@protolint lint --fix ./proto
lint:
@echo "Running linters..."
@for module in $(shell find . -name 'go.mod' -exec dirname {} \;); do \
echo "Running linters in $$module"; \
(cd $$module && golangci-lint run); \
done
lint-fix:
@echo "Running linters with fix..."
@for module in $(shell find . -name 'go.mod' -exec dirname {} \;); do \
echo "Running linters in $$module"; \
(cd $$module && golangci-lint run --fix); \
done
unit-test:
@echo "Running unit tests..."
@for module in $(shell find . -name 'go.mod' -exec dirname {} \; | grep -v './test'); do \
echo "Running unit tests in $$module"; \
(cd $$module && go test ./... -v) && \
echo "SUCCESS: Tests passed in $$module" || \
{ echo "FAIL: Tests failed in $$module"; exit 1; }; \
done
api-test:
@echo "Running API tests..."
@go run cmd/main.go api-test -f profile,character,timetracking,goal
dump:
@echo "Dumping database [$(DB_URI)]"
@mongodump --uri=$(DB_URI)
restore:
@echo "Restoring database [$(DB_URI)]"
@mongosh $(DB_URI) --eval "db.getSiblingDB('$(MONGO_DATABASE_NAME)').dropDatabase()"
@mongorestore --uri=$(DB_URI) dump/$(MONGO_DATABASE_NAME)
restore-col:
@echo "Restoring specific collection [$(COL)] in database [$(DB_URI)]"
@mongorestore --uri=$(DB_URI) --db $(MONGO_DATABASE_NAME) --collection $(COL) dump/$(MONGO_DATABASE_NAME)/$(COL).bson --drop
# Docker ----------------------------------------------------------------------
up:
@COMPOSE_BAKE=true docker compose -f docker-compose.dev.yml up -d
down:
@docker compose -f docker-compose.dev.yml down
down-rmi:
@docker compose -f docker-compose.dev.yml down --rmi all
logs:
@docker compose -f docker-compose.dev.yml logs -f
prune:
@docker system prune -af
elk-up:
@docker compose -f elk/docker-compose.dev.yml --env-file .env.development up -d
elk-down:
@docker compose -f elk/docker-compose.dev.yml --env-file .env.development down
# ------------------------------------------------------------------------------
.PHONY: core analytic timetracking notification test dump restore up down logs prune