-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
118 lines (98 loc) · 3.47 KB
/
Makefile
File metadata and controls
118 lines (98 loc) · 3.47 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
.PHONY: all build clean test test-verbose test-coverage lint fmt install help
# Variables
BINARY_NAME=coremcp
BUILD_DIR=bin
GO=go
GOFLAGS=-v
LDFLAGS=-ldflags "-s -w -X 'main.Version=$(VERSION)' -X 'main.Commit=$(COMMIT)' -X 'main.Date=$(DATE)'"
# Build info
VERSION?=$(shell git describe --tags --always --dirty)
COMMIT=$(shell git rev-parse --short HEAD)
DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
all: clean lint test build
## build: Build the application binary
build:
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BUILD_DIR)
$(GO) build $(GOFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/coremcp
@echo "Build complete: $(BUILD_DIR)/$(BINARY_NAME)"
## build-all: Build for multiple platforms
build-all:
@echo "Building for multiple platforms..."
@mkdir -p $(BUILD_DIR)
GOOS=linux GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./cmd/coremcp
GOOS=linux GOARCH=arm64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 ./cmd/coremcp
GOOS=darwin GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 ./cmd/coremcp
GOOS=darwin GOARCH=arm64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./cmd/coremcp
GOOS=windows GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./cmd/coremcp
@echo "Cross-platform build complete"
## install: Install the binary to GOPATH/bin
install:
@echo "Installing $(BINARY_NAME)..."
$(GO) install $(GOFLAGS) ./cmd/coremcp
@echo "Installed to $(shell go env GOPATH)/bin/$(BINARY_NAME)"
## test: Run tests
test:
@echo "Running tests..."
$(GO) test ./... -race -timeout 30s
## test-verbose: Run tests with verbose output
test-verbose:
@echo "Running tests (verbose)..."
$(GO) test ./... -v -race -timeout 30s
## test-coverage: Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
$(GO) test ./... -race -coverprofile=coverage.out -covermode=atomic
$(GO) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
## lint: Run linters
lint:
@echo "Running linters..."
@which golangci-lint > /dev/null || (echo "golangci-lint not found. Install: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest" && exit 1)
golangci-lint run --timeout 5m
## fmt: Format code
fmt:
@echo "Formatting code..."
$(GO) fmt ./...
@which goimports > /dev/null && goimports -w . || echo "goimports not found, skipping"
## vet: Run go vet
vet:
@echo "Running go vet..."
$(GO) vet ./...
## clean: Clean build artifacts
clean:
@echo "Cleaning..."
@rm -rf $(BUILD_DIR)
@rm -f coverage.out coverage.html
@echo "Clean complete"
## deps: Download dependencies
deps:
@echo "Downloading dependencies..."
$(GO) mod download
$(GO) mod verify
## tidy: Tidy go.mod
tidy:
@echo "Tidying go.mod..."
$(GO) mod tidy
## run: Run the application
run: build
@echo "Running $(BINARY_NAME)..."
./$(BUILD_DIR)/$(BINARY_NAME) serve
## docker-build: Build Docker image
docker-build:
@echo "Building Docker image..."
docker build -t corebasehq/coremcp:$(VERSION) .
docker tag corebasehq/coremcp:$(VERSION) corebasehq/coremcp:latest
## docker-run: Run Docker container
docker-run:
docker run --rm -v $(PWD)/coremcp.yaml:/app/coremcp.yaml corebasehq/coremcp:latest
## help: Show this help message
help:
@echo "CoreMCP Makefile"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@sed -n 's/^##//p' Makefile | column -t -s ':' | sed -e 's/^/ /'
# Default target
.DEFAULT_GOAL := help