-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
81 lines (67 loc) · 2.28 KB
/
Copy pathmakefile
File metadata and controls
81 lines (67 loc) · 2.28 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
.PHONY: help test test-coverage build run clean docker-build docker-up docker-down migrate-up migrate-down wire swagger
# Default target
help:
@echo "Available commands:"
@echo " test - Run all tests"
@echo " test-coverage - Run tests with coverage report"
@echo " build - Build the application"
@echo " run - Run the API server locally"
@echo " clean - Clean build artifacts"
@echo " docker-build - Build Docker images"
@echo " docker-up - Start all services with Docker Compose"
@echo " docker-down - Stop all services"
@echo " migrate-up - Apply database migrations"
@echo " migrate-down - Rollback database migrations"
@echo " wire - Generate Wire dependency injection"
@echo " swagger - Generate Swagger documentation"
# Testing
test:
@echo "Running tests..."
go test ./... -v
test-coverage:
@echo "Running tests with coverage..."
go test ./... -cover -coverprofile=coverage.out
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
# Building
build:
@echo "Building application..."
go build -o bin/api cmd/api/main.go
go build -o bin/worker cmd/worker/main.go
# Running
run:
@echo "Starting API server..."
go run cmd/api/main.go
# Cleaning
clean:
@echo "Cleaning build artifacts..."
rm -rf bin/
rm -f coverage.out coverage.html
# Docker commands
docker-build:
@echo "Building Docker images..."
docker-compose build
docker-up:
@echo "Starting services with Docker Compose..."
docker-compose up -d
docker-down:
@echo "Stopping services..."
docker-compose down
# Database migrations
migrate-up:
@echo "Applying database migrations..."
migrate -path migrations -database "postgres://postgres:postgres@localhost:5436/postgres?sslmode=disable" up
migrate-down:
@echo "Rolling back database migrations..."
migrate -path migrations -database "postgres://postgres:postgres@localhost:5436/postgres?sslmode=disable" down
create-mig:
@echo "Creating new migration..."
migrate create -ext sql -dir migrations -seq $(name)
swagger:
@echo "Generating Swagger documentation..."
swag init -g cmd/api/main.go -o docs
# Run tests in CI environment
ci-test:
@echo "Running CI tests..."
go test ./... -v -race -coverprofile=coverage.out
go tool cover -func=coverage.out