-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (97 loc) · 4.68 KB
/
Copy pathMakefile
File metadata and controls
129 lines (97 loc) · 4.68 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
.PHONY: all build test lint clean dev down watch docker-build docker-push deps help
BINARY_NAME := easctl
MAIN_PATH := ./cmd/easctl
BUILD_DIR := ./bin
DOCKER_IMAGE := engineering-at-scale
DOCKER_TAG := latest
GO_VERSION := 1.22
# ── Build ────────────────────────────────────────────────────────────────────
all: lint test build
build:
@echo "→ Building $(BINARY_NAME)..."
@mkdir -p $(BUILD_DIR)
@go build -ldflags="-s -w" -o $(BUILD_DIR)/$(BINARY_NAME) $(MAIN_PATH)
@echo "✓ $(BUILD_DIR)/$(BINARY_NAME)"
build-linux:
@echo "→ Building for linux/amd64..."
@GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 $(MAIN_PATH)
# ── Test ─────────────────────────────────────────────────────────────────────
test:
@echo "→ Running tests..."
@go test ./... -v -race -coverprofile=coverage.out
@go tool cover -html=coverage.out -o coverage.html
@echo "✓ Coverage report: coverage.html"
test-short:
@go test ./... -short
# ── Code Quality ─────────────────────────────────────────────────────────────
lint:
@echo "→ Linting..."
@golangci-lint run ./...
@echo "✓ Lint passed"
fmt:
@go fmt ./...
@goimports -w .
vet:
@go vet ./...
# ── Development ───────────────────────────────────────────────────────────────
dev:
@echo "→ Starting local development stack..."
@docker compose up -d
@echo "✓ API: http://localhost:8080"
@echo "✓ Metrics: http://localhost:9090"
@echo "✓ Grafana: http://localhost:3000"
down:
@docker compose down -v
@echo "✓ Stack stopped"
watch:
@echo "→ Starting with hot reload (requires air)..."
@air
logs:
@docker compose logs -f
# ── Docker ────────────────────────────────────────────────────────────────────
docker-build:
@echo "→ Building Docker image..."
@docker build -f docker/Dockerfile -t $(DOCKER_IMAGE):$(DOCKER_TAG) .
@echo "✓ $(DOCKER_IMAGE):$(DOCKER_TAG)"
docker-push:
@docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
# ── Dependencies ──────────────────────────────────────────────────────────────
deps:
@echo "→ Installing dependencies..."
@go mod download
@go mod verify
@echo "✓ Dependencies ready"
tidy:
@go mod tidy
# ── Database ──────────────────────────────────────────────────────────────────
migrate-up:
@echo "→ Running migrations..."
@migrate -path ./internal/storage/migrations -database "$$DATABASE_URL" up
migrate-down:
@migrate -path ./internal/storage/migrations -database "$$DATABASE_URL" down 1
migrate-create:
@read -p "Migration name: " name; \
migrate create -ext sql -dir ./internal/storage/migrations -seq $$name
seed:
@bash scripts/seed.sh
# ── Cleanup ───────────────────────────────────────────────────────────────────
clean:
@rm -rf $(BUILD_DIR)
@rm -f coverage.out coverage.html
@echo "✓ Clean"
# ── Help ─────────────────────────────────────────────────────────────────────
help:
@echo ""
@echo "Engineering at Scale — Developer Commands"
@echo ""
@echo " make build Build the easctl binary"
@echo " make test Run tests with race detector and coverage"
@echo " make lint Run golangci-lint"
@echo " make dev Start local Docker Compose stack"
@echo " make down Stop local stack"
@echo " make watch Start with hot reload (requires air)"
@echo " make docker-build Build Docker image"
@echo " make deps Install Go dependencies"
@echo " make migrate-up Run database migrations"
@echo " make clean Remove build artifacts"
@echo ""