-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
117 lines (94 loc) · 3.02 KB
/
Copy pathMakefile
File metadata and controls
117 lines (94 loc) · 3.02 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
# Project variables
BINARY_NAME := extproctor
MODULE := zntr.io/extproctor
GO := go
GOFLAGS := -trimpath
LDFLAGS := -s -w -buildid=$(shell git rev-parse HEAD)
# Tools
GOFMT := gofmt
GOLANGCI_LINT := golangci-lint
NILAWAY := nilaway
BUF := buf
# Directories
BUILD_DIR := .
COVERAGE_FILE := coverage.out
.PHONY: all build clean test test-coverage lint lint-fix nilaway vet fmt proto install help
## Default target
all: lint test build
## Build the binary
build:
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/extproctor
## Install the binary
install:
$(GO) install $(GOFLAGS) -ldflags "$(LDFLAGS)" ./cmd/extproctor
## Clean build artifacts
clean:
rm -f $(BUILD_DIR)/$(BINARY_NAME)
rm -f $(COVERAGE_FILE)
## Run tests
test:
$(GO) test -race ./...
## Run tests with coverage
test-coverage:
$(GO) test -race -coverprofile=$(COVERAGE_FILE) -covermode=atomic ./...
$(GO) tool cover -func=$(COVERAGE_FILE)
## Run tests with coverage and open HTML report
test-coverage-html: test-coverage
$(GO) tool cover -html=$(COVERAGE_FILE)
## Run golangci-lint
lint:
$(GOLANGCI_LINT) run ./...
## Run golangci-lint with auto-fix
lint-fix:
$(GOLANGCI_LINT) run --fix ./...
## Run nilaway for nil safety analysis
nilaway:
$(NILAWAY) ./...
## Run go vet
vet:
$(GO) vet ./...
## Format code
fmt:
$(GOFMT) -l -s -w .
## Run all checks (lint + nilaway + vet + test)
check: lint nilaway vet test
## Generate protobuf code
proto:
$(BUF) generate
## Update dependencies
deps:
$(GO) mod tidy
$(GO) mod verify
## Install development tools
tools:
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
$(GO) install go.uber.org/nilaway/cmd/nilaway@latest
$(GO) install mvdan.cc/gofumpt@latest
## Build sample extproc server
build-sample:
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/extproc-server ./sample/extproc
## Run sample extproc server
run-sample: build-sample
./extproc-server --addr :50051
## Help
help:
@echo "Available targets:"
@echo " all - Run lint, test, and build (default)"
@echo " build - Build the extproctor binary"
@echo " install - Install the extproctor binary"
@echo " clean - Remove build artifacts"
@echo " test - Run tests"
@echo " test-coverage - Run tests with coverage report"
@echo " test-coverage-html - Run tests and open HTML coverage report"
@echo " lint - Run golangci-lint"
@echo " lint-fix - Run golangci-lint with auto-fix"
@echo " nilaway - Run nilaway nil safety analysis"
@echo " vet - Run go vet"
@echo " fmt - Format code"
@echo " check - Run all checks (lint, nilaway, vet, test)"
@echo " proto - Generate protobuf code"
@echo " deps - Update and verify dependencies"
@echo " tools - Install development tools"
@echo " build-sample - Build sample extproc server"
@echo " run-sample - Run sample extproc server"
@echo " help - Show this help message"