-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (44 loc) · 1.36 KB
/
Makefile
File metadata and controls
56 lines (44 loc) · 1.36 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
.PHONY: build test clean install fmt lint vet deps coverage help
BINARY_NAME := rdsspectre
BUILD_DIR := ./bin
MAIN_PATH := ./cmd/rdsspectre
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
VERSION_NUM = $(patsubst v%,%,$(VERSION))
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -s -w -X main.version=$(VERSION_NUM) -X main.commit=$(COMMIT) -X main.date=$(DATE)
help:
@echo "Available targets:"
@grep -E '^## ' Makefile | sed 's/## / /'
## build: Build the binary
build:
@mkdir -p $(BUILD_DIR)
go build -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME) $(MAIN_PATH)
## test: Run tests with race detection
test:
go test -race ./...
## vet: Run go vet
vet:
go vet ./...
## lint: Run golangci-lint
lint:
golangci-lint run --timeout=5m
## fmt: Format code
fmt:
gofmt -w .
@command -v goimports >/dev/null 2>&1 && goimports -w . || true
## clean: Remove build artifacts
clean:
rm -rf $(BUILD_DIR) dist/
## install: Install the binary to GOPATH
install:
go install -ldflags="$(LDFLAGS)" $(MAIN_PATH)
## deps: Download and tidy dependencies
deps:
go mod download
go mod tidy
## coverage: Run tests with coverage report
coverage:
go test -race -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
.DEFAULT_GOAL := help