-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (97 loc) · 3.35 KB
/
Copy pathMakefile
File metadata and controls
121 lines (97 loc) · 3.35 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
dependency:
@echo ">> Downloading Dependencies"
@go mod download
swag-init:
@echo ">> Running swagger init"
@swag init
run-api: dependency swag-init
@echo ">> Running Result API Server"
@go run main.go serve-http
run-consumer: dependency swag-init
@echo ">> Running Result Kafka Consumer"
@go run main.go run-consumer
# ClickHouse commands
clickhouse-up:
@echo ">> Starting ClickHouse with Docker"
@docker run -d \
--name clickhouse-server \
--ulimit nofile=262144:262144 \
-p 8123:8123 \
-p 9000:9000 \
-p 9009:9009 \
clickhouse/clickhouse-server
clickhouse-down:
@echo ">> Stopping ClickHouse"
@docker stop clickhouse-server || true
@docker rm clickhouse-server || true
clickhouse-logs:
@echo ">> Showing ClickHouse logs"
@docker logs clickhouse-server -f
# Database migration commands
migrate-up:
@echo ">> Running ClickHouse Migration Up"
@migrate -path db/migrations -database "clickhouse://localhost:19000?username=default&password=changeme&database=result" up
migrate-down:
@echo ">> Running ClickHouse Migration Down"
@migrate -path db/migrations -database "clickhouse://localhost:19000?username=default&password=changeme&database=result" down
# Create database
create-db:
@echo ">> Creating ClickHouse Database"
@clickhouse-client --host localhost --port 9000 --query "CREATE DATABASE IF NOT EXISTS vote_results"
# Development setup
dev-setup: clickhouse-up
@echo ">> Waiting for ClickHouse to start..."
@sleep 10
@make create-db
@make migrate-up
@echo ">> Development environment ready"
# Clean up development environment
dev-clean: clickhouse-down
@echo ">> Development environment cleaned"
# Test commands
test:
@echo ">> Running tests"
@go test -v ./...
test-coverage:
@echo ">> Running tests with coverage"
@go test -v -coverprofile=coverage.out ./...
@go tool cover -html=coverage.out -o coverage.html
# Build commands
build:
@echo ">> Building Result Service"
@go build -o bin/result-service main.go
build-docker:
@echo ">> Building Docker image"
@docker build -t result-service:latest .
# Mock generation
remock:
@echo ">> Generating mocks"
@mockery --all --recursive --dir ./internal/domain/repository --output ./internal/domain/repository/mocks_repository --outpkg mocks_repository
@mockery --all --dir ./internal/usecases --output ./internal/usecases/mocks_usecases --outpkg mocks_usecases
@mockery --all --recursive --dir ./internal/interfaces --output ./internal/interfaces/mocks_interfaces --outpkg mocks_interfaces
# Linting
lint:
@echo ">> Running golangci-lint"
@golangci-lint run
# Format code
fmt:
@echo ">> Formatting code"
@go fmt ./...
# Generate documentation
docs:
@echo ">> Generating API documentation"
@swag init
@echo ">> Documentation available at http://localhost:8904/docs/"
# All-in-one development commands
dev-run-api: dev-setup run-api
dev-run-consumer: dev-setup run-consumer
# Production build
prod-build:
@echo ">> Building for production"
@CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o bin/result-service main.go
# Clean build artifacts
clean:
@echo ">> Cleaning build artifacts"
@rm -rf bin/
@rm -rf coverage.out coverage.html
.PHONY: dependency swag-init run-api run-consumer clickhouse-up clickhouse-down clickhouse-logs migrate-up migrate-down create-db dev-setup dev-clean test test-coverage build build-docker remock lint fmt docs dev-run-api dev-run-consumer prod-build clean