-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (66 loc) · 2.39 KB
/
Copy pathMakefile
File metadata and controls
79 lines (66 loc) · 2.39 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
.PHONY: help build test lint clean install run coverage
# Variables
BINARY_NAME=mayrlabs
BUILD_DIR=build
GO=go
GOFLAGS=-v
help: ## Display this help message
@echo "MayR Labs CLI - Makefile Commands"
@echo ""
@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 $(GOFLAGS) -o $(BINARY_NAME) main.go
@echo "✅ Build complete: ./$(BINARY_NAME)"
install: ## Install the binary to GOPATH/bin
@echo "Installing $(BINARY_NAME)..."
$(GO) install $(GOFLAGS)
@echo "✅ Installed to $(GOPATH)/bin/$(BINARY_NAME)"
test: ## Run all tests
@echo "Running tests..."
$(GO) test -v -race ./...
@echo "✅ Tests complete"
coverage: ## Run tests with coverage report
@echo "Running tests with coverage..."
$(GO) test -v -race -coverprofile=coverage.out ./...
$(GO) tool cover -html=coverage.out -o coverage.html
@echo "✅ Coverage report generated: coverage.html"
lint: ## Run linter
@echo "Running linter..."
@if command -v golangci-lint > /dev/null; then \
golangci-lint run; \
else \
echo "golangci-lint not found. Install it: https://golangci-lint.run/usage/install/"; \
$(GO) vet ./...; \
fi
@echo "✅ Linting complete"
fmt: ## Format code
@echo "Formatting code..."
$(GO) fmt ./...
@echo "✅ Code formatted"
vet: ## Run go vet
@echo "Running go vet..."
$(GO) vet ./...
@echo "✅ Vet complete"
clean: ## Clean build artifacts
@echo "Cleaning..."
rm -f $(BINARY_NAME)
rm -f coverage.out coverage.html
rm -rf $(BUILD_DIR)
@echo "✅ Clean complete"
run: build ## Build and run the CLI
./$(BINARY_NAME)
deps: ## Download dependencies
@echo "Downloading dependencies..."
$(GO) mod download
$(GO) mod tidy
@echo "✅ Dependencies updated"
build-all: ## Build for all platforms
@echo "Building for all platforms..."
@mkdir -p $(BUILD_DIR)
GOOS=linux GOARCH=amd64 $(GO) build -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 main.go
GOOS=linux GOARCH=arm64 $(GO) build -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 main.go
GOOS=darwin GOARCH=amd64 $(GO) build -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 main.go
GOOS=darwin GOARCH=arm64 $(GO) build -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 main.go
GOOS=windows GOARCH=amd64 $(GO) build -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe main.go
@echo "✅ All platform builds complete in $(BUILD_DIR)/"