-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (54 loc) · 1.84 KB
/
Copy pathMakefile
File metadata and controls
72 lines (54 loc) · 1.84 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
GO_CONTENT := ./main.go ./cmd ./internal
BINARY_NAME := agbx
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
RELEASE_DATE ?= $(shell git log -1 --format=%cI 2>/dev/null || echo unknown)
VERSION_PKG := github.com/pixel365/agbx/cmd/internal/version
LDFLAGS := -s -w \
-X $(VERSION_PKG).version=$(VERSION) \
-X $(VERSION_PKG).commit=$(COMMIT) \
-X $(VERSION_PKG).releaseDate=$(RELEASE_DATE)
.PHONY: build test integration vet lint tidy fieldalignment goimports golines gofmt fix formatters check help
## all: Synchronize dependencies and format source code
all: tidy fieldalignment formatters
## formatters: Run all source code formatters
formatters: goimports gofmt golines fix
## check: Run linting, static checks, and tests
check: lint vet test
## build: Build the agbx binary
build:
go $@ -trimpath -ldflags "$(LDFLAGS)" -o ./bin/$(BINARY_NAME) ./main.go
## test: Run tests with the race detector
test:
go $@ -race ./...
## integration: Run Docker-backed integration tests
integration:
go test -tags=$@ ./internal/docker
## vet: Run go vet
vet:
@go $@ ./...
## lint: Run golangci-lint
lint:
@golangci-lint run
## tidy: Synchronize Go module dependencies
tidy:
@go mod $@
## fieldalignment: Optimize struct field alignment
fieldalignment:
@$@ -fix ./...
## goimports: Format imports
goimports:
@$@ -w -local github.com/pixel365/agbx $(GO_CONTENT)
## golines: Wrap long Go source lines
golines:
@$@ -w $(GO_CONTENT)
## gofmt: Format Go source code
gofmt:
@$@ -w $(GO_CONTENT)
## fix: Apply go fix
fix:
@go $@ ./...
## help: Show this help message with available commands
help:
@echo "Available commands:"
@sed -n 's/^## //p' $(MAKEFILE_LIST) | awk '{ i = index($$0, ": "); printf " %-16s %s\n", substr($$0, 1, i - 1), substr($$0, i + 2) }'