-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (67 loc) · 1.7 KB
/
Makefile
File metadata and controls
74 lines (67 loc) · 1.7 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
.PHONY: help test fmt vet lint ci clean
# Default target
help:
@echo "Rigging - Development Makefile"
@echo ""
@echo " make ci Run all CI checks (fmt, vet, test, lint)"
@echo " make test Run tests"
@echo " make fmt Format code"
@echo " make vet Run go vet"
@echo " make lint Run golangci-lint"
@echo " make clean Clean artifacts"
# Run tests
test:
@go test -race ./...
# Format code
fmt:
@gofmt -s -w .
# Run go vet
vet:
@go vet ./...
# Run linter
lint:
@if [ -f $(HOME)/go/bin/golangci-lint ]; then \
$(HOME)/go/bin/golangci-lint run --timeout=5m; \
elif command -v golangci-lint > /dev/null; then \
golangci-lint run --timeout=5m; \
else \
echo "golangci-lint not installed. Install: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
exit 1; \
fi
# Run all CI checks
ci:
@echo "=== Formatting ==="
@if [ -n "$$(gofmt -l .)" ]; then \
echo "Code not formatted. Run: make fmt"; \
exit 1; \
fi
@echo "PASS: Formatted"
@echo ""
@echo "=== Vetting ==="
@go vet ./...
@echo "PASS: Vet"
@echo ""
@echo "=== Testing ==="
@go test -race ./...
@echo "PASS: Tests"
@echo ""
@echo "=== Linting ==="
@$(MAKE) lint
@echo "PASS: Lint"
@echo ""
@echo "=== Coverage ==="
@go test -coverprofile=coverage.out ./... > /dev/null 2>&1
@COVERAGE=$$(go tool cover -func=coverage.out | grep total | awk '{print $$3}' | sed 's/%//'); \
echo "Coverage: $$COVERAGE%"; \
if [ $$(echo "$$COVERAGE < 70" | bc -l) -eq 1 ]; then \
echo "FAIL: Coverage below 70%"; \
exit 1; \
fi
@echo ""
@echo "============================"
@echo "All CI checks passed"
@echo "============================"
# Clean artifacts
clean:
@rm -f coverage.out
@go clean ./...