-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
164 lines (136 loc) · 4 KB
/
Makefile
File metadata and controls
164 lines (136 loc) · 4 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Makefile for SliceUtil Go package
# Provides targets for building, testing, linting, and development
.PHONY: help build test test-coverage test-benchmark clean lint format check-fmt vet run-example install-deps update-deps
# Default target
help:
@echo "SliceUtil - Go Package for Slice Operations"
@echo ""
@echo "Available targets:"
@echo " build - Build the package"
@echo " test - Run all tests"
@echo " test-coverage - Run tests with coverage report"
@echo " test-benchmark - Run benchmark tests"
@echo " lint - Run golangci-lint"
@echo " format - Format Go code"
@echo " check-fmt - Check if code is formatted"
@echo " vet - Run go vet"
@echo " clean - Clean build artifacts"
@echo " run-example - Run the example program"
@echo " install-deps - Install development dependencies"
@echo " update-deps - Update Go dependencies"
@echo " help - Show this help message"
# Build the package
build:
@echo "Building SliceUtil package..."
go build ./...
# Run all tests
test:
@echo "Running tests..."
go test -v ./...
# Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
# Run benchmark tests
test-benchmark:
@echo "Running benchmark tests..."
go test -bench=. -benchmem ./...
# Run linting
lint:
@echo "Running golangci-lint..."
golangci-lint run
# Format Go code
format:
@echo "Formatting Go code..."
go fmt ./...
gofmt -s -w .
# Check if code is formatted
check-fmt:
@echo "Checking code formatting..."
@if [ -n "$$(gofmt -l .)" ]; then \
echo "Code is not formatted. Run 'make format' to fix."; \
exit 1; \
fi
@echo "Code is properly formatted."
# Run go vet
vet:
@echo "Running go vet..."
go vet ./...
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
go clean
rm -f coverage.out coverage.html
rm -rf dist/
# Run the example program
run-example:
@echo "Running example program..."
go run cmd/example/main.go
# Install development dependencies
install-deps:
@echo "Installing development dependencies..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install golang.org/x/tools/cmd/goimports@latest
# Update Go dependencies
update-deps:
@echo "Updating Go dependencies..."
go get -u ./...
go mod tidy
# Run all checks (format, vet, test)
check: check-fmt vet test
# Build and test
all: build test
# Development workflow
dev: format vet test run-example
# CI/CD pipeline
ci: check-fmt vet test-coverage test-benchmark
# Release preparation
release: clean check-fmt vet test-coverage build
@echo "Release preparation completed successfully!"
# Show package information
info:
@echo "Package: github.com/devrob-go/sliceutil"
@echo "Go version: $(shell go version)"
@echo "Go modules: $(shell go env GOMOD)"
@echo "Go workspace: $(shell go env GOWORK)"
@echo ""
@echo "Dependencies:"
@go list -m all
# Show test coverage summary
coverage-summary:
@echo "Test coverage summary:"
@go test -cover ./... | grep -E "(coverage|PASS|FAIL)"
# Run specific test file
test-file:
@if [ -z "$(FILE)" ]; then \
echo "Usage: make test-file FILE=path/to/test.go"; \
exit 1; \
fi
@echo "Running tests in $(FILE)..."
go test -v $(FILE)
# Run tests with race detection
test-race:
@echo "Running tests with race detection..."
go test -race ./...
# Generate documentation
docs:
@echo "Generating documentation..."
godoc -http=:6060 &
@echo "Documentation server started at http://localhost:6060"
@echo "Press Ctrl+C to stop"
# Install package locally
install:
@echo "Installing package locally..."
go install ./...
# Uninstall package
uninstall:
@echo "Uninstalling package..."
go clean -i ./...
# Show help for specific target
help-%:
@echo "Help for target '$*':"
@make -n $* 2>/dev/null || echo "No help available for target '$*'"
# Default target when no arguments provided
.DEFAULT_GOAL := help