-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
152 lines (112 loc) · 4.49 KB
/
Copy pathMakefile
File metadata and controls
152 lines (112 loc) · 4.49 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
# ABOUTME: Build and development targets for diego-capacity-analyzer
# ABOUTME: Includes backend (Go) and frontend (React) commands
# Configurable ports (override with: make backend-run BACKEND_PORT=9090)
BACKEND_PORT ?= 8080
FRONTEND_PORT ?= 5173
.PHONY: help all build test lint check clean
.PHONY: backend-build backend-test backend-lint backend-clean backend-run backend-dev backend-air
.PHONY: frontend-build frontend-test frontend-lint frontend-dev frontend-preview frontend-clean
.PHONY: cli-build cli-test cli-lint cli-clean cli-install
.PHONY: openapi-validate
.DEFAULT_GOAL := help
help: ## Show this help message
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
all: check build ## Run checks and build everything
#
# Combined targets
#
build: backend-build frontend-build cli-build ## Build backend, frontend, and CLI
test: backend-test frontend-test cli-test ## Run all tests
lint: backend-lint frontend-lint cli-lint ## Run all linters
check: test lint ## Run tests and linters
clean: backend-clean frontend-clean cli-clean ## Clean all build artifacts
#
# Backend targets (Go)
#
backend-build: ## Build Go backend binary
cd backend && go build -o capacity-backend .
backend-test: ## Run backend tests
cd backend && go test ./...
backend-test-verbose: ## Run backend tests with verbose output
cd backend && go test -v ./...
backend-lint: ## Run staticcheck on backend
cd backend && staticcheck ./...
backend-clean: ## Remove backend build artifacts
rm -f backend/capacity-backend
backend-run: backend-build ## Build and run the backend server (PORT=$(BACKEND_PORT))
cd backend && PORT=$(BACKEND_PORT) ./capacity-backend
backend-dev: ## Run backend with auto-reload (PORT=$(BACKEND_PORT))
@if command -v watchexec >/dev/null 2>&1; then \
cd backend && PORT=$(BACKEND_PORT) watchexec -r -e go -- go run .; \
elif command -v air >/dev/null 2>&1; then \
cd backend && PORT=$(BACKEND_PORT) air; \
else \
echo "No auto-reload tool found. Install watchexec or air for auto-reload."; \
echo "Falling back to 'go run' (manual restart required)"; \
cd backend && PORT=$(BACKEND_PORT) go run .; \
fi
backend-air: ## Run backend with air (explicit choice over watchexec)
@if command -v air >/dev/null 2>&1; then \
cd backend && PORT=$(BACKEND_PORT) air; \
else \
echo "Error: air not found. Install with: go install github.com/air-verse/air@latest"; \
exit 1; \
fi
#
# Frontend targets (React/Vite)
#
frontend-build: ## Build frontend for production
cd frontend && npm run build
frontend-test: ## Run frontend tests
cd frontend && npm test
frontend-test-watch: ## Run frontend tests in watch mode
cd frontend && npm run test:watch
frontend-test-coverage: ## Run frontend tests with coverage
cd frontend && npm run test:coverage
frontend-lint: ## Run ESLint on frontend
cd frontend && npm run lint
frontend-dev: ## Start frontend dev server (PORT=$(FRONTEND_PORT))
cd frontend && npm run dev -- --port $(FRONTEND_PORT)
frontend-preview: frontend-build ## Build and preview production build locally
cd frontend && npm run preview
frontend-clean: ## Remove frontend build artifacts
rm -rf frontend/dist
frontend-install: ## Install frontend dependencies
cd frontend && npm install
#
# CLI targets (diego-capacity)
#
cli-build: ## Build CLI binary (diego-capacity)
cd cli && go build -o diego-capacity .
cli-test: ## Run CLI tests
cd cli && go test ./...
cli-test-verbose: ## Run CLI tests with verbose output
cd cli && go test -v ./...
cli-lint: ## Run staticcheck on CLI
cd cli && staticcheck ./...
cli-clean: ## Remove CLI build artifacts
rm -f cli/diego-capacity
cli-install: cli-build ## Install CLI to $GOPATH/bin
@GOPATH_BIN=$${GOPATH:-$$(go env GOPATH)}/bin; \
mkdir -p $$GOPATH_BIN; \
cp cli/diego-capacity $$GOPATH_BIN/
#
# OpenAPI Documentation targets
#
OPENAPI_SPEC := backend/handlers/openapi.yaml
openapi-validate: ## Validate OpenAPI spec syntax
@if [ ! -f "$(OPENAPI_SPEC)" ]; then \
echo "Error: $(OPENAPI_SPEC) not found."; \
exit 1; \
fi
@if command -v swagger-cli >/dev/null 2>&1; then \
swagger-cli validate $(OPENAPI_SPEC); \
elif command -v npx >/dev/null 2>&1; then \
npx @apidevtools/swagger-cli validate $(OPENAPI_SPEC); \
else \
echo "Validating YAML syntax only (install swagger-cli for full validation)..."; \
python3 -c "import yaml; yaml.safe_load(open('$(OPENAPI_SPEC)'))" && echo "$(OPENAPI_SPEC) is valid YAML"; \
fi