-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathMakefile
More file actions
192 lines (168 loc) Β· 7.98 KB
/
Makefile
File metadata and controls
192 lines (168 loc) Β· 7.98 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
# MCPProxy Makefile
.PHONY: help build build-server build-docker build-deb swagger swagger-verify frontend-build frontend-dev backend-dev clean test test-coverage test-e2e test-e2e-oauth lint dev-setup docs-setup docs-dev docs-build docs-clean
SWAGGER_BIN ?= $(HOME)/go/bin/swag
SWAGGER_OUT ?= oas
SWAGGER_ENTRY ?= cmd/mcpproxy/main.go
# Default target
help:
@echo "MCPProxy Build Commands:"
@echo " make build - Build complete project (swagger + frontend + backend)"
@echo " make swagger - Generate OpenAPI specification"
@echo " make swagger-verify - Regenerate OpenAPI and fail if artifacts are dirty"
@echo " make frontend-build - Build frontend for production"
@echo " make frontend-dev - Start frontend development server"
@echo " make backend-dev - Build backend with dev flag (loads frontend from disk)"
@echo " make clean - Clean build artifacts"
@echo " make test - Run unit tests"
@echo " make test-coverage - Run tests with coverage"
@echo " make test-e2e - Run all E2E tests"
@echo " make test-e2e-oauth - Run OAuth E2E tests with Playwright"
@echo " make lint - Run linter"
@echo " make dev-setup - Install development dependencies (swag, frontend, Playwright)"
@echo ""
@echo "Server Edition:"
@echo " make build-server - Build Server edition binary (with -tags server)"
@echo " make build-docker - Build Server Docker image"
@echo " make build-deb - Build Server .deb package (TODO)"
@echo ""
@echo "Documentation Commands:"
@echo " make docs-setup - Install documentation dependencies"
@echo " make docs-dev - Start docs dev server (http://localhost:3000)"
@echo " make docs-build - Build documentation site locally"
@echo " make docs-clean - Clean documentation build artifacts"
# Generate OpenAPI specification
swagger:
@echo "π Generating OpenAPI 3.1 specification..."
@[ -x "$(SWAGGER_BIN)" ] || { echo "β οΈ swag binary not found at $(SWAGGER_BIN). Run 'go install github.com/swaggo/swag/v2/cmd/swag@v2.0.0-rc4'"; exit 1; }
@mkdir -p $(SWAGGER_OUT)
$(SWAGGER_BIN) init -g $(SWAGGER_ENTRY) --output $(SWAGGER_OUT) --outputTypes go,yaml --v3.1 --exclude specs
@echo "β
OpenAPI 3.1 spec generated: $(SWAGGER_OUT)/swagger.yaml and $(SWAGGER_OUT)/docs.go"
swagger-verify: swagger
@echo "π Verifying OpenAPI artifacts are committed..."
@if git status --porcelain -- $(SWAGGER_OUT)/swagger.yaml $(SWAGGER_OUT)/docs.go | grep -q .; then \
echo "β OpenAPI artifacts are out of date. Run 'make swagger' and commit the regenerated files."; \
git diff --stat -- $(SWAGGER_OUT)/swagger.yaml $(SWAGGER_OUT)/docs.go || true; \
exit 1; \
fi
@echo "β
OpenAPI artifacts are up to date."
# Version detection for builds
VERSION ?= $(shell git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0-dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(BUILD_DATE) -X github.com/smart-mcp-proxy/mcpproxy-go/internal/httpapi.buildVersion=$(VERSION) -s -w
# Build complete project
build: swagger frontend-build
@echo "π¨ Building Go binary with embedded frontend (version: $(VERSION))..."
go build -ldflags "$(LDFLAGS)" -o mcpproxy ./cmd/mcpproxy
go build -ldflags "$(LDFLAGS)" -o mcpproxy-tray ./cmd/mcpproxy-tray
@echo "β
Build completed! Run: ./mcpproxy serve"
@echo "π Web UI: http://localhost:8080/ui/"
@echo "π API Docs: http://localhost:8080/swagger/"
# Build frontend for production
frontend-build:
@echo "π¨ Generating TypeScript types from Go contracts..."
go run ./cmd/generate-types
@echo "π¨ Building frontend for production..."
cd frontend && npm install && npm run build
@echo "π Copying dist files for embedding..."
rm -rf web/frontend
mkdir -p web/frontend
cp -r frontend/dist web/frontend/
@echo "β
Frontend build completed"
# Start frontend development server
frontend-dev:
@echo "π¨ Starting frontend development server..."
cd frontend && npm install && npm run dev
# Build backend with dev flag (for development with frontend hot reload)
backend-dev:
@echo "π¨ Building backend in development mode (version: $(VERSION))..."
go build -tags dev -ldflags "$(LDFLAGS)" -o mcpproxy-dev ./cmd/mcpproxy
@echo "β
Development backend ready!"
@echo "π Run: ./mcpproxy-dev serve"
@echo "π In dev mode, make sure frontend dev server is running on port 3000"
# Build Server edition
build-server: swagger frontend-build
@echo "π¨ Building Server edition binary (version: $(VERSION))..."
go build -tags server -ldflags "$(LDFLAGS)" -o mcpproxy-server ./cmd/mcpproxy
@echo "β
Server build completed! Run: ./mcpproxy-server serve"
# Build Server Docker image
build-docker:
@echo "π³ Building Server Docker image (version: $(VERSION))..."
docker build --build-arg VERSION=$(VERSION) --build-arg COMMIT=$(COMMIT) --build-arg BUILD_DATE=$(BUILD_DATE) -t mcpproxy-server:$(VERSION) -t mcpproxy-server:latest .
@echo "β
Docker image built: mcpproxy-server:$(VERSION)"
# Build Server .deb package (placeholder)
build-deb:
@echo "π¦ Building Server .deb package..."
@echo "β οΈ TODO: Implement deb package build (nfpm or dpkg-deb)"
@echo " See: https://nfpm.goreleaser.com/"
# Clean build artifacts
clean:
@echo "π§Ή Cleaning build artifacts..."
rm -f mcpproxy mcpproxy-dev mcpproxy-tray mcpproxy-server
rm -rf frontend/dist frontend/node_modules web/frontend
go clean
@echo "β
Cleanup completed"
# Run tests
test:
@echo "π§ͺ Running Go tests..."
go test ./internal/... -v
@echo "π§ͺ Running frontend tests..."
cd frontend && npm install && npm run test
# Run tests with coverage
test-coverage:
@echo "π§ͺ Running tests with coverage..."
go test -coverprofile=coverage.out ./internal/...
go tool cover -html=coverage.out -o coverage.html
cd frontend && npm install && npm run coverage
# Run linter
lint:
@echo "π Running Go linter..."
golangci-lint run ./...
@echo "π Running frontend linter..."
cd frontend && npm install && npm run lint
# Install development dependencies
dev-setup:
@echo "π οΈ Setting up development environment..."
@echo "π¦ Installing swag (OpenAPI generator)..."
go install github.com/swaggo/swag/v2/cmd/swag@v2.0.0-rc4
@echo "π¦ Installing frontend dependencies..."
cd frontend && npm install
@echo "π¦ Installing Playwright E2E test dependencies..."
cd e2e/playwright && npm install
@echo "π¦ Installing Playwright browsers..."
cd e2e/playwright && npx playwright install chromium
@echo "π¦ Installing pre-commit hooks..."
@if command -v prek >/dev/null 2>&1; then \
prek install && prek install --hook-type pre-push; \
echo "β
Git hooks installed (prek)"; \
else \
echo "β οΈ prek not found. Install with: brew install prek"; \
fi
@echo "β
Development setup completed"
# Run OAuth E2E tests with Playwright
test-e2e-oauth:
@echo "π§ͺ Running OAuth E2E tests..."
./scripts/run-oauth-e2e.sh
# Run all E2E tests
test-e2e: test-e2e-oauth
@echo "π§ͺ Running E2E tests..."
./scripts/test-api-e2e.sh
# Documentation site commands
docs-setup:
@echo "π¦ Installing documentation dependencies..."
@if [ ! -d "website" ]; then echo "β website/ directory not found. Run after Phase 1 setup."; exit 1; fi
cd website && npm install
@echo "β
Documentation setup complete"
docs-dev:
@echo "π Starting documentation dev server..."
@if [ ! -d "website" ]; then echo "β website/ directory not found. Run after Phase 1 setup."; exit 1; fi
cd website && ./prepare-docs.sh && npm run start
docs-build:
@echo "π¨ Building documentation site..."
@if [ ! -d "website" ]; then echo "β website/ directory not found. Run after Phase 1 setup."; exit 1; fi
cd website && ./prepare-docs.sh && npm run build
@echo "β
Documentation built to website/build/"
docs-clean:
@echo "π§Ή Cleaning documentation artifacts..."
rm -rf website/build website/.docusaurus website/node_modules website/docs
@echo "β
Documentation cleanup complete"