edge-connect-mcp/Makefile

82 lines
1.9 KiB
Makefile

# ABOUTME: Makefile for edge-connect-mcp project.
# ABOUTME: Provides targets for building, formatting, linting, and testing.
BINARY_NAME := edge-connect-mcp
GO := go
GOLANGCI_LINT := $(GO) run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.2
GITLEAKS := $(GO) run github.com/zricethezav/gitleaks/v8@v8.30.0
# Build flags
LDFLAGS := -s -w
BUILD_FLAGS := -ldflags "$(LDFLAGS)"
default: run
.PHONY: all build clean fmt format lint gitleaks test run help vet tidy install-hooks
# Default target
all: fmt vet lint build
## Build targets
build: ## Build the binary
$(GO) build $(BUILD_FLAGS) -o $(BINARY_NAME) .
clean: ## Remove build artifacts
rm -f $(BINARY_NAME)
$(GO) clean
## Code quality targets
fmt: ## Format code using go fmt
$(GO) fmt ./...
format: fmt ## Alias for fmt
vet: ## Run go vet
$(GO) vet ./...
lint: ## Run golangci-lint
$(GOLANGCI_LINT) run ./...
gitleaks: ## Check for secrets in git history
$(GITLEAKS) git --staged
gitleaks-all: ## Check for secrets in git history
$(GITLEAKS) git .
## Dependency management
tidy: ## Tidy go modules
$(GO) mod tidy
## Testing targets
test: ## Run tests
$(GO) test -v ./...
test-coverage: ## Run tests with coverage
$(GO) test -v -coverprofile=coverage.out ./...
$(GO) tool cover -html=coverage.out -o coverage.html
## Run targets
run: build ## Build and run in stdio mode
./$(BINARY_NAME)
run-remote: build ## Build and run in remote mode
./$(BINARY_NAME) -mode=remote
## Git hooks
install-hooks: ## Install git hooks
cp scripts/hooks/pre-commit .git/hooks/pre-commit
cp scripts/hooks/commit-msg .git/hooks/commit-msg
chmod +x .git/hooks/pre-commit
chmod +x .git/hooks/commit-msg
@echo "Git hooks installed successfully"
## Help
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'