-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (67 loc) · 1.7 KB
/
Copy pathMakefile
File metadata and controls
85 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
75
76
77
78
79
80
81
82
83
84
85
.PHONY: all build test test-verbose test-coverage lint fmt clean help
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOFMT=gofmt
GOLINT=golangci-lint
GOMOD=$(GOCMD) mod
GOCLEAN=$(GOCMD) clean
# Build info
BINARY_NAME=go-cxf
COVERAGE_FILE=coverage.out
# Default target
all: fmt lint test
## build: Build the library (compile check)
build:
$(GOBUILD) -v ./...
## test: Run all tests
test:
$(GOTEST) -v ./...
## test-short: Run tests without verbose output
test-short:
$(GOTEST) ./...
## test-race: Run tests with race detector
test-race:
$(GOTEST) -race -v ./...
## test-coverage: Run tests with coverage report
test-coverage:
$(GOTEST) -coverprofile=$(COVERAGE_FILE) -covermode=atomic ./...
$(GOCMD) tool cover -func=$(COVERAGE_FILE)
## test-coverage-html: Generate HTML coverage report
test-coverage-html: test-coverage
$(GOCMD) tool cover -html=$(COVERAGE_FILE) -o coverage.html
@echo "Coverage report generated: coverage.html"
## lint: Run golangci-lint
lint:
$(GOLINT) run ./...
## fmt: Format code
fmt:
$(GOFMT) -w .
## fmt-check: Check if code is formatted (for CI)
fmt-check:
@fmt_out=$$($(GOFMT) -l .); \
if [ -n "$$fmt_out" ]; then \
echo "The following files are not gofmt formatted:"; \
echo "$$fmt_out"; \
exit 1; \
fi
## tidy: Tidy go.mod
tidy:
$(GOMOD) tidy
## verify: Verify dependencies
verify:
$(GOMOD) verify
## download: Download dependencies
download:
$(GOMOD) download
## clean: Clean build artifacts
clean:
$(GOCLEAN)
rm -f $(COVERAGE_FILE) coverage.html
## ci: Run all CI checks (format, lint, test)
ci: fmt-check lint test-short
## help: Show this help
help:
@echo "Available targets:"
@sed -n 's/^##//p' $(MAKEFILE_LIST) | column -t -s ':' | sed 's/^/ /'