-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
166 lines (132 loc) · 5.1 KB
/
Makefile
File metadata and controls
166 lines (132 loc) · 5.1 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
# Build configuration
BINARY_NAME := flashduty-mcp-server
BUILD_DIR := bin
GOLANGCI_LINT_VERSION := v2.2.1
GOLANGCI_LINT := $(BUILD_DIR)/golangci-lint
GCI_VERSION := v0.13.5
GCI := $(BUILD_DIR)/gci
# Go parameters
GOCMD := go
GOBUILD := $(GOCMD) build
GOTEST := $(GOCMD) test
GOFMT := gofmt
MODULE := $(shell go list -m)
# Default target
.PHONY: all
all: check
# ============================================================================
# Development targets
# ============================================================================
.PHONY: build
build: ## Build the binary
$(GOBUILD) -v -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/$(BINARY_NAME)
.PHONY: run
run: build ## Build and run the server
./$(BUILD_DIR)/$(BINARY_NAME)
# ============================================================================
# Quality assurance targets
# ============================================================================
# Directories to format (excludes openspec which contains reference code)
FMT_DIRS := cmd pkg internal e2e
.PHONY: fmt
fmt: $(GCI) ## Format Go source code and sort imports
$(GOFMT) -s -w $(FMT_DIRS)
$(GCI) write --skip-generated -s standard -s default -s "prefix($(MODULE))" $(FMT_DIRS)
.PHONY: gci
gci: $(GCI) ## Sort imports using gci
$(GCI) write --skip-generated -s standard -s default -s "prefix($(MODULE))" $(FMT_DIRS)
.PHONY: lint
lint: $(GOLANGCI_LINT) ## Run golangci-lint
$(GOLANGCI_LINT) run
.PHONY: lint-fix
lint-fix: $(GOLANGCI_LINT) ## Run golangci-lint with auto-fix
$(GOLANGCI_LINT) run --fix
.PHONY: test
test: ## Run unit tests
$(GOTEST) -race ./...
.PHONY: test-v
test-v: ## Run unit tests with verbose output
$(GOTEST) -race -v ./...
.PHONY: e2e
e2e: ## Run E2E tests (requires FLASHDUTY_E2E_APP_KEY and FLASHDUTY_E2E_BASE_URL)
@if [ -z "$$FLASHDUTY_E2E_APP_KEY" ]; then \
echo "Error: FLASHDUTY_E2E_APP_KEY environment variable is not set"; \
exit 1; \
fi
$(GOTEST) -v --tags e2e ./e2e/... -timeout 10m
.PHONY: e2e-debug
e2e-debug: ## Run E2E tests in debug mode (in-process, no Docker)
@if [ -z "$$FLASHDUTY_E2E_APP_KEY" ]; then \
echo "Error: FLASHDUTY_E2E_APP_KEY environment variable is not set"; \
exit 1; \
fi
FLASHDUTY_E2E_DEBUG=true $(GOTEST) -v --tags e2e ./e2e/... -timeout 10m
# ============================================================================
# Pre-push check (recommended before pushing)
# ============================================================================
.PHONY: check
check: fmt lint test build ## Run all checks (fmt, lint, test, build) - recommended before pushing
.PHONY: ci
ci: check ## Alias for check
# ============================================================================
# Docker targets
# ============================================================================
.PHONY: docker-build
docker-build: ## Build Docker image
docker build -t flashcat/flashduty-mcp-server .
.PHONY: docker-e2e
docker-e2e: docker-build ## Build Docker image and run E2E tests
@if [ -z "$$FLASHDUTY_E2E_APP_KEY" ]; then \
echo "Error: FLASHDUTY_E2E_APP_KEY environment variable is not set"; \
exit 1; \
fi
$(GOTEST) -v --tags e2e ./e2e/... -timeout 10m
# ============================================================================
# Dependency management
# ============================================================================
.PHONY: deps
deps: ## Download Go dependencies
$(GOCMD) mod download
.PHONY: deps-tidy
deps-tidy: ## Tidy Go modules
$(GOCMD) mod tidy
.PHONY: deps-verify
deps-verify: ## Verify Go dependencies
$(GOCMD) mod verify
# ============================================================================
# Tools installation
# ============================================================================
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(GOLANGCI_LINT): $(BUILD_DIR)
@if [ ! -f "$(GOLANGCI_LINT)" ]; then \
echo "Installing golangci-lint $(GOLANGCI_LINT_VERSION)..."; \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_LINT_VERSION); \
fi
$(GCI): $(BUILD_DIR)
@if [ ! -f "$(GCI)" ]; then \
echo "Installing gci $(GCI_VERSION)..."; \
GOBIN=$(CURDIR)/$(BUILD_DIR) $(GOCMD) install github.com/daixiang0/gci@$(GCI_VERSION); \
fi
.PHONY: tools
tools: $(GOLANGCI_LINT) $(GCI) ## Install required tools
# ============================================================================
# Cleanup
# ============================================================================
.PHONY: clean
clean: ## Remove build artifacts
rm -rf $(BUILD_DIR)
# ============================================================================
# Help
# ============================================================================
.PHONY: help
help: ## Display this help message
@echo "Available targets:"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "Quick start:"
@echo " make check - Run all pre-push checks (recommended before pushing)"
@echo " make lint - Run linter only"
@echo " make test - Run unit tests only"
@echo " make e2e - Run E2E tests (requires env vars)"