-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (88 loc) · 2.65 KB
/
Copy pathMakefile
File metadata and controls
104 lines (88 loc) · 2.65 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
# rightsizer Makefile
# Variables
BINARY_NAME := rightsizer
DOCKER_IMAGE := nextroll/rightsizer
GO_FILES := $(shell find . -name '*.go' -type f)
# Default target
.PHONY: all
all: build
# Build the binary
.PHONY: build
build:
go build -o $(BINARY_NAME) .
# Generate mocks
.PHONY: generate
generate:
go generate ./...
# Run tests
.PHONY: test
test: generate
go test ./...
# Clean build artifacts
.PHONY: clean
clean:
rm -f $(BINARY_NAME)
# Build Docker image
.PHONY: docker-build
docker-build:
docker build -t $(DOCKER_IMAGE) .
# Run with Docker
.PHONY: docker-run
docker-run:
docker run --rm $(DOCKER_IMAGE) $(BINARY_NAME) $(ARGS)
# Install dependencies
.PHONY: deps
deps:
go mod download
go mod tidy
# Format code
.PHONY: fmt
fmt:
go fmt ./...
# Vet code
.PHONY: vet
vet:
go vet ./...
# Run linter (requires golangci-lint)
.PHONY: lint
lint:
golangci-lint run
# Full check: format, vet, generate, test
.PHONY: check
check: fmt vet generate test
# Bump version
.PHONY: version-bump
version-bump:
@if [ -z "$(VERSION)" ]; then \
echo "Usage: make version-bump VERSION=x.y.z"; \
exit 1; \
fi
@echo "Bumping version to $(VERSION)..."
@sed -i '' 's/Version:.*"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"/Version: "$(VERSION)"/' main.go
@echo "Version updated to $(VERSION) in main.go"
@# Extract major and minor versions for workflow tags
@MAJOR=$$(echo $(VERSION) | cut -d. -f1); \
MINOR=$$(echo $(VERSION) | cut -d. -f2); \
sed -i '' "s/nextroll\/rightsizer:v[0-9][0-9]*/nextroll\/rightsizer:v$$MAJOR/" .github/workflows/ship-version.yml; \
sed -i '' "s/nextroll\/rightsizer:v[0-9][0-9]*\.[0-9][0-9]*/nextroll\/rightsizer:v$$MAJOR.$$MINOR/" .github/workflows/ship-version.yml; \
sed -i '' "s/nextroll\/rightsizer:v[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*/nextroll\/rightsizer:v$(VERSION)/" .github/workflows/ship-version.yml
@echo "Running go fmt..."
go fmt ./...
@echo "Version updated to $(VERSION) in .github/workflows/ship-version.yml"
# Help
.PHONY: help
help:
@echo "Available targets:"
@echo " build - Build the rightsizer binary"
@echo " generate - Generate mocks using go generate"
@echo " test - Run tests (generates mocks first)"
@echo " clean - Remove build artifacts"
@echo " docker-build - Build Docker image"
@echo " docker-run - Run with Docker (use ARGS='cluster service')"
@echo " deps - Download and tidy Go modules"
@echo " fmt - Format Go code"
@echo " vet - Run go vet"
@echo " lint - Run golangci-lint"
@echo " check - Run fmt, vet, generate, and test"
@echo " version-bump - Bump version (use VERSION=x.y.z)"
@echo " help - Show this help message"