-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
233 lines (202 loc) · 5.78 KB
/
Makefile
File metadata and controls
233 lines (202 loc) · 5.78 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# Makefile for obs-tools-usage
# Variables
PROTO_DIR = api/proto
PROTO_FILES = $(shell find $(PROTO_DIR) -name "*.proto")
GO_OUT_DIR = .
# Go modules
.PHONY: mod-tidy
mod-tidy:
go mod tidy
# Generate protobuf files
.PHONY: proto
proto: $(PROTO_FILES)
@echo "Generating protobuf files..."
protoc --go_out=$(GO_OUT_DIR) --go_opt=paths=source_relative \
--go-grpc_out=$(GO_OUT_DIR) --go-grpc_opt=paths=source_relative \
$(PROTO_FILES)
@echo "Protobuf files generated successfully!"
# Install protobuf dependencies
.PHONY: install-proto-deps
install-proto-deps:
@echo "Installing protobuf dependencies..."
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
@echo "Protobuf dependencies installed!"
# Development
.PHONY: dev
dev:
@echo "Starting development server..."
@chmod +x scripts/dev.sh
@./scripts/dev.sh
# Build the application
.PHONY: build
build:
@echo "Building application..."
@chmod +x scripts/build.sh
@./scripts/build.sh
# Build notification service
.PHONY: build-notification
build-notification:
@echo "Building notification service..."
go build -o bin/notification-service cmd/notification/main.go
# Run tests
.PHONY: test
test:
@echo "Running tests..."
@chmod +x scripts/test.sh
@./scripts/test.sh
# Run tests with coverage
.PHONY: test-coverage
test-coverage:
@echo "Running tests with coverage..."
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
# Lint and format code
.PHONY: lint
lint:
@echo "Running linter..."
@chmod +x scripts/lint.sh
@./scripts/lint.sh
# Format code
.PHONY: fmt
fmt:
@echo "Formatting code..."
@chmod +x scripts/lint.sh
@./scripts/lint.sh format --fix
# Database operations
.PHONY: db-migrate
db-migrate:
@echo "Running database migrations..."
@chmod +x scripts/db.sh
@./scripts/db.sh migrate
.PHONY: db-seed
db-seed:
@echo "Seeding database..."
@chmod +x scripts/db.sh
@./scripts/db.sh seed
.PHONY: db-backup
db-backup:
@echo "Creating database backup..."
@chmod +x scripts/db.sh
@./scripts/db.sh backup
.PHONY: db-status
db-status:
@echo "Checking database status..."
@chmod +x scripts/db.sh
@./scripts/db.sh status
# Docker operations
.PHONY: docker-build
docker-build:
@echo "Building Docker images..."
@chmod +x scripts/docker.sh
@./scripts/docker.sh build
.PHONY: docker-run
docker-run:
@echo "Running Docker containers..."
@chmod +x scripts/docker.sh
@./scripts/docker.sh run
.PHONY: docker-stop
docker-stop:
@echo "Stopping Docker containers..."
@chmod +x scripts/docker.sh
@./scripts/docker.sh stop
.PHONY: docker-clean
docker-clean:
@echo "Cleaning Docker resources..."
@chmod +x scripts/docker.sh
@./scripts/docker.sh clean
# Cleanup
.PHONY: clean
clean:
@echo "Cleaning build artifacts..."
@chmod +x scripts/clean.sh
@./scripts/clean.sh build
.PHONY: clean-all
clean-all:
@echo "Cleaning everything..."
@chmod +x scripts/clean.sh
@./scripts/clean.sh all --force
# Generate all (proto + build)
.PHONY: generate
generate: proto build
# Install development dependencies
.PHONY: install-deps
install-deps: install-proto-deps
@echo "Installing development dependencies..."
go install github.com/google/wire/cmd/wire@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/securecodewarrior/gosec/v2/cmd/gosec@latest
@echo "Development dependencies installed!"
# Setup project
.PHONY: setup
setup: install-deps mod-tidy proto
@echo "Project setup completed!"
# Run the application
.PHONY: run
run: build
@echo "Running microservices..."
@chmod +x scripts/services.sh
@./scripts/services.sh start --service all
# Services management
.PHONY: services-start
services-start:
@chmod +x scripts/services.sh
@./scripts/services.sh start
.PHONY: services-stop
services-stop:
@chmod +x scripts/services.sh
@./scripts/services.sh stop
.PHONY: services-restart
services-restart:
@chmod +x scripts/services.sh
@./scripts/services.sh restart
.PHONY: services-status
services-status:
@chmod +x scripts/services.sh
@./scripts/services.sh status
.PHONY: services-logs
services-logs:
@chmod +x scripts/services.sh
@./scripts/services.sh logs
# Help
.PHONY: help
help:
@echo "Available targets:"
@echo " setup - Setup project (install deps, generate proto)"
@echo " dev - Start development server"
@echo " build - Build the application"
@echo " run - Run microservices"
@echo " test - Run tests"
@echo " test-coverage - Run tests with coverage"
@echo " lint - Run linter and format checks"
@echo " fmt - Format code"
@echo " proto - Generate protobuf files"
@echo " mod-tidy - Tidy go modules"
@echo " install-deps - Install development dependencies"
@echo ""
@echo "Services management:"
@echo " services-start - Start services"
@echo " services-stop - Stop services"
@echo " services-restart - Restart services"
@echo " services-status - Show service status"
@echo " services-logs - Show service logs"
@echo ""
@echo "Database targets:"
@echo " db-migrate - Run database migrations"
@echo " db-seed - Seed database with initial data"
@echo " db-backup - Create database backup"
@echo " db-status - Show database status"
@echo ""
@echo "Docker targets:"
@echo " docker-build - Build Docker images"
@echo " docker-run - Run Docker containers"
@echo " docker-stop - Stop Docker containers"
@echo " docker-clean - Clean Docker resources"
@echo ""
@echo "Cleanup targets:"
@echo " clean - Clean build artifacts"
@echo " clean-all - Clean everything"
@echo ""
@echo " help - Show this help message"