-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
96 lines (73 loc) · 3.05 KB
/
Makefile
File metadata and controls
96 lines (73 loc) · 3.05 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
GO ?= go
GOLANGCI_LINT ?= golangci-lint
BINARY ?= abacus
PKG ?= ./cmd/abacus
# Version information
VERSION ?= dev
BUILD ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILDTIME ?= $(shell date -u '+%Y-%m-%d_%H:%M:%S')
# Linker flags for version injection
LDFLAGS := -X main.Version=$(VERSION) -X main.Build=$(BUILD) -X main.BuildTime=$(BUILDTIME)
.PHONY: help build test test-verbose test-integration test-all bench install lint clean check check-verbose check-test
help: ## Display available make targets
@awk 'BEGIN {FS=":.*##"; printf "\nUsage: make <target>\n\nTargets:\n"} /^[a-zA-Z0-9_\-]+:.*##/ {printf " %-12s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
build: ## Compile the abacus CLI into ./abacus
@if [ -n "$$VERBOSE" ]; then \
$(GO) build -ldflags "$(LDFLAGS)" -o $(BINARY) $(PKG); \
else \
. ./hack/run_silent.sh && run_silent "Building $(BINARY)" "$(GO) build -ldflags \"$(LDFLAGS)\" -o $(BINARY) $(PKG)"; \
fi
## Check targets (linting and static analysis)
check: ## Run all checks (quiet output)
@if [ -n "$$VERBOSE" ]; then \
$(GO) fmt ./... && $(GO) vet ./... && $(GOLANGCI_LINT) run ./...; \
else \
$(MAKE) check-quiet; \
fi
check-quiet:
@. ./hack/run_silent.sh && print_main_header "Running Checks"
@. ./hack/run_silent.sh && print_header "abacus" "Static analysis"
@. ./hack/run_silent.sh && run_with_quiet "Format check passed" "$(GO) fmt ./..."
@. ./hack/run_silent.sh && run_with_quiet "Vet check passed" "$(GO) vet ./..."
@. ./hack/run_silent.sh && run_with_quiet "Lint check passed" "$(GOLANGCI_LINT) run ./..."
check-verbose: ## Run checks with verbose output
@VERBOSE=1 $(MAKE) check
## Test targets
test: ## Run unit tests only (quiet output, excludes integration tests)
@if [ -n "$$VERBOSE" ]; then \
$(GO) test -v ./...; \
else \
$(MAKE) test-quiet; \
fi
test-quiet:
@. ./hack/run_silent.sh && print_main_header "Running Tests"
@. ./hack/run_silent.sh && print_header "abacus" "Unit tests"
@. ./hack/run_silent.sh && run_silent_with_test_count "Unit tests passed" "$(GO) test -json ./..." "go"
test-verbose: ## Run unit tests with verbose output
@VERBOSE=1 $(MAKE) test
test-integration: ## Run integration tests only (requires bd/br binaries)
@if [ -n "$$VERBOSE" ]; then \
$(GO) test -tags=integration -v ./...; \
else \
$(MAKE) test-integration-quiet; \
fi
test-integration-quiet:
@. ./hack/run_silent.sh && print_main_header "Running Integration Tests"
@. ./hack/run_silent.sh && print_header "abacus" "Integration tests"
@. ./hack/run_silent.sh && run_silent_with_test_count "Integration tests passed" "$(GO) test -tags=integration -json ./..." "go"
test-all: ## Run all tests (unit + integration)
@$(MAKE) test
@$(MAKE) test-integration
## Combined targets
check-test: ## Run all checks and tests
@$(MAKE) check
@$(MAKE) test
## Other targets
bench: ## Run benchmarks
$(GO) test -run=^$$ -bench=. ./...
install: ## Install the CLI into GOPATH/bin
$(GO) install -ldflags "$(LDFLAGS)" $(PKG)
lint: ## Run golangci-lint (verbose)
$(GOLANGCI_LINT) run ./...
clean: ## Remove build artifacts
rm -f $(BINARY)