-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (58 loc) · 2.14 KB
/
Makefile
File metadata and controls
72 lines (58 loc) · 2.14 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
.PHONY: build test lint clean install run help
# Build variables
BINARY_NAME=momorph
VERSION?=dev
COMMIT_SHA?=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
GO_VERSION?=$(shell go version | awk '{print $$3}')
# Go build flags
LDFLAGS=-ldflags "-X github.com/momorph/cli/internal/version.Version=$(VERSION) \
-X github.com/momorph/cli/internal/version.CommitSHA=$(COMMIT_SHA) \
-X github.com/momorph/cli/internal/version.BuildDate=$(BUILD_DATE) \
-X github.com/momorph/cli/internal/version.GoVersion=$(GO_VERSION)"
help: ## Display this help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
build: ## Build the binary
@echo "Building $(BINARY_NAME)..."
@go build $(LDFLAGS) -o $(BINARY_NAME) main.go
@echo "Build complete: $(BINARY_NAME)"
test: ## Run tests
@echo "Running tests..."
@go test -v -race -coverprofile=coverage.out ./...
@echo "Tests complete"
test-coverage: test ## Run tests with coverage report
@echo "Generating coverage report..."
@go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
lint: ## Run linter
@echo "Running linter..."
@if command -v golangci-lint > /dev/null; then \
golangci-lint run ./...; \
else \
echo "golangci-lint not installed. Install with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
go vet ./...; \
fi
fmt: ## Format code
@echo "Formatting code..."
@go fmt ./...
@echo "Format complete"
clean: ## Clean build artifacts
@echo "Cleaning..."
@rm -f $(BINARY_NAME)
@rm -f coverage.out coverage.html
@rm -rf bin/ dist/
@echo "Clean complete"
install: build ## Install binary to $GOPATH/bin
@echo "Installing $(BINARY_NAME)..."
@go install $(LDFLAGS)
@echo "Install complete"
run: build ## Build and run the binary
@./$(BINARY_NAME)
deps: ## Download dependencies
@echo "Downloading dependencies..."
@go mod download
@go mod tidy
@echo "Dependencies ready"
dev: ## Run in development mode with debug logging
@go run main.go --debug
.DEFAULT_GOAL := help