-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
106 lines (89 loc) · 2.86 KB
/
Makefile
File metadata and controls
106 lines (89 loc) · 2.86 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
.PHONY: build install test clean fmt lint help
# Binary name
BINARY_NAME=sc
# Build directory
BUILD_DIR=bin
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
GOFMT=$(GOCMD) fmt
GOVET=$(GOCMD) vet
# Main package path
MAIN_PATH=./cmd/sc
# Build the project
build:
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) -v $(MAIN_PATH)
@echo "Build complete: $(BUILD_DIR)/$(BINARY_NAME)"
# Install to $GOPATH/bin
install:
@echo "Installing $(BINARY_NAME) to $$GOPATH/bin..."
$(GOCMD) install $(MAIN_PATH)
@echo "Installation complete. Run '$(BINARY_NAME)' to use."
# Run tests
test:
@echo "Running tests..."
$(GOTEST) -v -race -coverprofile=coverage.out ./...
# Run tests with coverage report
coverage: test
@echo "Generating coverage report..."
$(GOCMD) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
# Clean build artifacts
clean:
@echo "Cleaning..."
@rm -rf $(BUILD_DIR)
@rm -f coverage.out coverage.html
@echo "Clean complete"
# Format code
fmt:
@echo "Formatting code..."
$(GOFMT) ./...
# Run linters
lint:
@echo "Running linters..."
@which golangci-lint > /dev/null || (echo "golangci-lint not installed. Install: https://golangci-lint.run/usage/install/" && exit 1)
golangci-lint run ./...
# Tidy dependencies
tidy:
@echo "Tidying dependencies..."
$(GOMOD) tidy
# Download dependencies
deps:
@echo "Downloading dependencies..."
$(GOMOD) download
# Run the application (for development)
run:
$(GOCMD) run $(MAIN_PATH)
# Build for multiple platforms
build-all:
@echo "Building for multiple platforms..."
@mkdir -p $(BUILD_DIR)
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 $(MAIN_PATH)
GOOS=darwin GOARCH=arm64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 $(MAIN_PATH)
GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 $(MAIN_PATH)
GOOS=linux GOARCH=arm64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 $(MAIN_PATH)
GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe $(MAIN_PATH)
@echo "Multi-platform build complete"
# Help command
help:
@echo "StoreConnect CLI - Makefile commands:"
@echo ""
@echo " make build - Build the binary"
@echo " make install - Install to \$$GOPATH/bin"
@echo " make test - Run tests"
@echo " make coverage - Generate coverage report"
@echo " make clean - Remove build artifacts"
@echo " make fmt - Format code"
@echo " make lint - Run linters"
@echo " make tidy - Tidy dependencies"
@echo " make deps - Download dependencies"
@echo " make run - Run the application"
@echo " make build-all - Build for multiple platforms"
@echo " make help - Show this help message"
# Default target
.DEFAULT_GOAL := build