-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
150 lines (135 loc) · 5.08 KB
/
Copy pathMakefile
File metadata and controls
150 lines (135 loc) · 5.08 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
# Root Makefile - builds all applications
.PHONY: all dev-cache git-cleaner mac-cache-cleaner clean test fmt lint vet build release-dry-run release-snapshot goreleaser-check check-tools help
# Default target - build all applications
all: dev-cache git-cleaner mac-cache-cleaner
# Help target
help:
@echo "Available targets:"
@echo ""
@echo "Setup:"
@echo " check-tools - Verify all required development tools are installed"
@echo ""
@echo "Build targets:"
@echo " all - Build all applications (default)"
@echo " dev-cache - Build dev-cache application"
@echo " git-cleaner - Build git-cleaner application"
@echo " mac-cache-cleaner - Build mac-cache-cleaner application"
@echo " build - Build all applications"
@echo ""
@echo "Quality targets:"
@echo " test - Run tests in all applications"
@echo " fmt - Format code in all applications"
@echo " lint - Lint all applications"
@echo " vet - Run go vet on all applications"
@echo ""
@echo "Release targets:"
@echo " goreleaser-check - Validate GoReleaser configuration"
@echo " release-dry-run - Test GoReleaser without building/publishing"
@echo " release-snapshot - Build snapshot release locally (no git tag required)"
@echo ""
@echo "Cleanup:"
@echo " clean - Clean all applications and build artifacts"
# Build each application
dev-cache:
@echo "Building dev-cache..."
@$(MAKE) -C dev-cache all
git-cleaner:
@echo "Building git-cleaner..."
@$(MAKE) -C git-cleaner all
mac-cache-cleaner:
@echo "Building mac-cache-cleaner..."
@$(MAKE) -C mac-cache-cleaner all
# Convenience targets that run in all directories
test:
@echo "Running tests in all applications..."
@$(MAKE) -C dev-cache test
@$(MAKE) -C git-cleaner test
@$(MAKE) -C mac-cache-cleaner test
fmt:
@echo "Formatting all applications..."
@$(MAKE) -C dev-cache fmt
@$(MAKE) -C git-cleaner fmt
@$(MAKE) -C mac-cache-cleaner fmt
lint:
@echo "Linting all applications..."
@$(MAKE) -C dev-cache lint
@$(MAKE) -C git-cleaner lint
@$(MAKE) -C mac-cache-cleaner lint
vet:
@echo "Running go vet on all applications..."
@$(MAKE) -C dev-cache vet
@$(MAKE) -C git-cleaner vet
@$(MAKE) -C mac-cache-cleaner vet
build:
@echo "Building all applications..."
@$(MAKE) -C dev-cache build
@$(MAKE) -C git-cleaner build
@$(MAKE) -C mac-cache-cleaner build
clean:
@echo "Cleaning all applications..."
@$(MAKE) -C dev-cache clean
@$(MAKE) -C git-cleaner clean
@$(MAKE) -C mac-cache-cleaner clean
# Check required tools are installed
check-tools:
@echo "Checking required development tools..."
@echo ""
@echo "Checking Go..."
@if ! command -v go >/dev/null 2>&1; then \
echo "❌ Go is not installed"; \
echo " Install from: https://go.dev/dl/"; \
exit 1; \
fi
@go_version=$$(go version | awk '{print $$3}' | sed 's/go//'); \
required_version="1.21"; \
if ! printf '%s\n' "$$required_version" "$$go_version" | sort -V -C 2>/dev/null; then \
echo "❌ Go version $$go_version is installed, but version $$required_version or higher is required"; \
echo " Install from: https://go.dev/dl/"; \
exit 1; \
fi
@echo "✅ Go $$(go version | awk '{print $$3}') is installed"
@echo ""
@echo "Checking Make..."
@if ! command -v make >/dev/null 2>&1; then \
echo "❌ Make is not installed"; \
echo " On macOS: xcode-select --install"; \
echo " On Linux: apt-get install build-essential (Ubuntu/Debian) or yum groupinstall 'Development Tools' (RHEL/CentOS)"; \
exit 1; \
fi
@echo "✅ Make $$(make --version | head -n1) is installed"
@echo ""
@echo "Checking optional tools..."
@if command -v goreleaser >/dev/null 2>&1; then \
echo "✅ GoReleaser $$(goreleaser --version | head -n1 | awk '{print $$3}') is installed"; \
else \
echo "⚠️ GoReleaser is not installed (optional, needed for releases)"; \
echo " Install with: brew install goreleaser"; \
fi
@if command -v pre-commit >/dev/null 2>&1; then \
echo "✅ pre-commit $$(pre-commit --version | awk '{print $$2}') is installed"; \
else \
echo "⚠️ pre-commit is not installed (optional, needed for Git hooks)"; \
echo " Install with: pip install pre-commit"; \
fi
@echo ""
@echo "All required tools are installed! 🎉"
# GoReleaser targets
goreleaser-check:
@echo "Checking GoReleaser configuration..."
@if ! command -v goreleaser >/dev/null 2>&1; then \
echo "Error: goreleaser is not installed"; \
echo "Install it with: brew install goreleaser"; \
exit 1; \
fi
@echo "Note: Some deprecation warnings are expected and will be addressed in future versions."
@goreleaser check
release-dry-run: goreleaser-check
@echo "Running GoReleaser in dry-run mode (no release, no build)..."
@goreleaser release --skip=publish --skip=validate --clean
release-snapshot: goreleaser-check
@echo "Building snapshot release (local testing, no tags required)..."
@goreleaser release --snapshot --clean --skip=publish
@echo ""
@echo "Snapshot built successfully!"
@echo "Binaries are in: ./dist/"
@ls -lh ./dist/ | grep -E "dev-cache|git-cleaner|mac-cache-cleaner"