-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (69 loc) · 2.17 KB
/
Copy pathMakefile
File metadata and controls
84 lines (69 loc) · 2.17 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
.PHONY: help test test-verbose test-race test-cover codecov bench fmt lint clean check-fmt vet
# Build variables
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
BUILD_HASH := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
GO := go
GOFLAGS ?=
GOBIN := $(shell go env GOPATH)/bin
## help: Display this help message
help:
@echo "Mattermost Logr - Makefile Commands"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Available targets:"
@grep -E '^## ' Makefile | sed 's/##/ /'
## test: Run all tests
test:
$(GO) test $(GOFLAGS) ./...
## test-verbose: Run all tests with verbose output
test-verbose:
$(GO) test $(GOFLAGS) -v ./...
## test-race: Run tests with race detector
test-race:
$(GO) test $(GOFLAGS) -race ./...
## test-cover: Run tests with coverage report
test-cover:
$(GO) test $(GOFLAGS) -coverprofile=coverage.out ./...
$(GO) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
## codecov: Run tests with coverage and display summary
codecov:
$(GO) test $(GOFLAGS) -coverprofile=coverage.out -covermode=atomic ./...
@echo ""
@echo "Coverage Summary:"
@$(GO) tool cover -func=coverage.out
@echo ""
@echo "Generating HTML report..."
$(GO) tool cover -html=coverage.out -o coverage.html
@echo "HTML coverage report: coverage.html"
## bench: Run benchmarks
bench:
$(GO) test $(GOFLAGS) -bench=. ./test
## fmt: Format all Go files
fmt:
$(GO) fmt ./...
## check-fmt: Check if Go files are formatted
check-fmt:
@if [ -n "$$(gofmt -l .)" ]; then \
echo "The following files are not formatted:"; \
gofmt -l .; \
exit 1; \
fi
## vet: Run go vet on all packages
vet:
$(GO) vet ./...
## lint: Run golangci-lint
lint:
@test -f $(GOBIN)/golangci-lint || { echo "golangci-lint not installed. Installing..."; $(GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.5.0; }
$(GOBIN)/golangci-lint run ./...
## check: Run format check, vet, lint, and tests
check: check-fmt vet lint test
## clean: Remove generated files
clean:
$(GO) clean
rm -f coverage.out coverage.html
## version: Display version information
version:
@echo "Build Date: $(BUILD_DATE)"
@echo "Build Hash: $(BUILD_HASH)"