-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (52 loc) · 1.55 KB
/
Makefile
File metadata and controls
66 lines (52 loc) · 1.55 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
.PHONY: build test lint coverage clean install help
# Build variables
BINARY_NAME := opencligen
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
LDFLAGS := -ldflags "-X main.version=$(VERSION) -X main.buildTime=$(BUILD_TIME)"
# Default target
all: lint test build
## build: Build the binary
build:
go build $(LDFLAGS) -o bin/$(BINARY_NAME) ./cmd/opencligen
## test: Run all tests
test:
go test -race ./...
## lint: Run golangci-lint
lint:
golangci-lint run
## coverage: Run tests with coverage report
coverage:
go test -race -coverprofile=coverage.out -covermode=atomic ./...
go tool cover -func=coverage.out
@echo ""
@echo "To view HTML coverage report, run: go tool cover -html=coverage.out"
## coverage-html: Generate and open HTML coverage report
coverage-html: coverage
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
## clean: Remove build artifacts
clean:
rm -rf bin/
rm -f coverage.out coverage.html
## install: Install the binary to GOPATH/bin
install:
go install $(LDFLAGS) ./cmd/opencligen
## fmt: Format code
fmt:
go fmt ./...
goimports -w -local github.com/crunchloop/opencligen .
## vet: Run go vet
vet:
go vet ./...
## mod-tidy: Tidy go modules
mod-tidy:
go mod tidy
## check: Run all checks (fmt, vet, lint, test)
check: fmt vet lint test
## help: Show this help message
help:
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@sed -n 's/^## //p' $(MAKEFILE_LIST) | column -t -s ':' | sed 's/^/ /'