-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (108 loc) · 5.68 KB
/
Makefile
File metadata and controls
133 lines (108 loc) · 5.68 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
.DEFAULT_GOAL := test
.PHONY: test test-unit test-integration test-coverage \
build build-dev build-release \
lint fmt deadcode ci clean \
change change-new change-preview \
deps-tools
# CI detection
ifdef CI
LINT_FIX :=
RACE := -race
else
LINT_FIX := --fix
RACE :=
endif
# GH_TOKEN auto-detection for integration tests
GH_TOKEN ?= $(shell gh auth token 2>/dev/null)
export GH_TOKEN
# Platforms for release builds
PLATFORMS := linux-amd64 linux-arm64 darwin-amd64 darwin-arm64
# ──────────────────────────────────────────────────────────────────────────────
# Test targets
# ──────────────────────────────────────────────────────────────────────────────
test: test-unit
test-unit:
@echo "Running unit tests..."
@gotestsum -- -tags=!integration -short ./...
test-integration:
@echo "Running integration tests..."
@echo "→ Installing grove binary..."
@go install ./cmd/grove
@[ -z "$(GH_TOKEN)" ] || echo "→ Using gh CLI authentication for PR tests"
@gotestsum -- -tags=integration -timeout=600s ./cmd/grove/...
test-coverage:
@echo "Running unit tests with coverage..."
@mkdir -p coverage
@go test -v -tags=!integration -short -coverprofile=coverage/coverage.out -covermode=atomic $(RACE) ./...
@go tool cover -func=coverage/coverage.out
# ──────────────────────────────────────────────────────────────────────────────
# Build targets
# ──────────────────────────────────────────────────────────────────────────────
build: build-dev
build-dev:
@echo "Building Grove..."
@mkdir -p bin
@go build -o bin/grove ./cmd/grove
build-release:
@echo "Building release binaries..."
@mkdir -p bin
@for platform in $(PLATFORMS); do \
os=$${platform%%-*}; \
arch=$${platform#*-}; \
echo "Building bin/grove-$$platform..."; \
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build -ldflags="-s -w" -o bin/grove-$$platform ./cmd/grove; \
done
# ──────────────────────────────────────────────────────────────────────────────
# Code quality
# ──────────────────────────────────────────────────────────────────────────────
lint:
@echo "Running golangci-lint..."
@golangci-lint run $(LINT_FIX)
fmt:
@echo "Formatting code..."
@gofmt -w -s .
@echo "Formatting Markdown/JSON/YAML..."
@npx prettier --write .
deadcode:
@echo "Checking for dead code..."
@go run golang.org/x/tools/cmd/deadcode@latest ./...
# ──────────────────────────────────────────────────────────────────────────────
# CI pipeline
# ──────────────────────────────────────────────────────────────────────────────
ci: clean lint test-coverage test-integration build-dev
@echo "CI pipeline completed successfully!"
clean:
@echo "Cleaning all artifacts..."
@rm -rf coverage bin
@go clean -testcache
# ──────────────────────────────────────────────────────────────────────────────
# Changelog management
# ──────────────────────────────────────────────────────────────────────────────
change: change-new
change-new:
@command -v changie >/dev/null 2>&1 || go install github.com/miniscruff/changie@latest
@echo "Creating change entry..."
@changie new
change-preview:
@command -v changie >/dev/null 2>&1 || go install github.com/miniscruff/changie@latest
@echo "Unreleased changes:"
@entries=$$(ls -1 .changes/unreleased/*.yaml 2>/dev/null | wc -l); \
if [ "$$entries" -eq 0 ]; then \
echo " (none)"; \
else \
for f in .changes/unreleased/*.yaml; do \
echo " • $$(basename $$f)"; \
done; \
echo ""; \
echo "Next version: $$(changie next auto)"; \
fi
# ──────────────────────────────────────────────────────────────────────────────
# Development tools
# ──────────────────────────────────────────────────────────────────────────────
deps-tools:
@echo "Installing development tools..."
@echo " Installing gotestsum..."
@go install gotest.tools/gotestsum@v1.13.0
@echo " Installing changie..."
@go install github.com/miniscruff/changie@v1.24.0
@echo "✓ All tools installed"