-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (102 loc) · 4.33 KB
/
Makefile
File metadata and controls
129 lines (102 loc) · 4.33 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
.PHONY: all build clean fmt fmt-check lint test cover vuln e2e install-tools snapshot release help
# =============================================================================
# Variables
# =============================================================================
BINARY := stacktower
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -X github.com/stacktower-io/stacktower/pkg/buildinfo.Version=$(VERSION) \
-X github.com/stacktower-io/stacktower/pkg/buildinfo.Commit=$(COMMIT) \
-X github.com/stacktower-io/stacktower/pkg/buildinfo.Date=$(DATE)
# =============================================================================
# Default Target
# =============================================================================
all: check build
# =============================================================================
# Build Targets
# =============================================================================
build:
@echo "Building CLI (bin/$(BINARY))..."
@go build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) ./cmd/stacktower
install:
@echo "Installing CLI..."
@go install -ldflags "$(LDFLAGS)" ./cmd/stacktower
clean:
@rm -rf bin/ dist/ coverage.out output/ tmp/
# =============================================================================
# Quality Checks
# =============================================================================
check: fmt lint test vuln
fmt:
@gofmt -s -w .
@goimports -w -local github.com/stacktower-io/stacktower .
fmt-check:
@echo "Checking formatting..."
@test -z "$$(gofmt -l .)" || (echo "Files not formatted:"; gofmt -l .; exit 1)
@test -z "$$(goimports -l -local github.com/stacktower-io/stacktower .)" || (echo "Imports not formatted:"; goimports -l -local github.com/stacktower-io/stacktower .; exit 1)
@echo "Formatting OK"
lint:
@golangci-lint run
test:
@go test -race -timeout=2m ./...
cover:
@go test -race -coverprofile=coverage.out ./...
@go tool cover -func=coverage.out
vuln:
@govulncheck ./...
install-tools:
@go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
@go install golang.org/x/tools/cmd/goimports@latest
@go install golang.org/x/vuln/cmd/govulncheck@latest
# =============================================================================
# End-to-End Tests
# =============================================================================
e2e: build
@./scripts/test_cli_e2e.sh all
e2e-test: build
@./scripts/test_cli_e2e.sh test
e2e-real: build
@./scripts/test_cli_e2e.sh real
e2e-parse: build
@./scripts/test_cli_e2e.sh parse
# =============================================================================
# Release
# =============================================================================
snapshot:
@goreleaser release --snapshot --clean --skip=publish
release:
@goreleaser release --clean
# =============================================================================
# Help
# =============================================================================
help:
@echo "Stacktower Makefile"
@echo ""
@echo "BUILDING:"
@echo " make build - Build CLI binary (bin/stacktower)"
@echo " make install - Install CLI to GOPATH"
@echo ""
@echo "QUALITY:"
@echo " make check - Run all checks (fmt, lint, test, vuln)"
@echo " make fmt - Format code"
@echo " make fmt-check - Check formatting (CI-style, no writes)"
@echo " make lint - Run golangci-lint"
@echo " make test - Run tests"
@echo " make cover - Run tests with coverage"
@echo " make vuln - Check for vulnerabilities"
@echo ""
@echo "TESTING:"
@echo " make e2e - Run all CLI end-to-end tests"
@echo " make e2e-test - Run test examples"
@echo " make e2e-real - Run real package examples"
@echo " make e2e-parse - Run parse tests"
@echo ""
@echo "RELEASE:"
@echo " make snapshot - Build release locally (no publish)"
@echo " make release - Build and publish release"
@echo ""
@echo "OTHER:"
@echo " make clean - Remove build artifacts"
@echo " make install-tools - Install development tools"
@echo " make help - Show this help"