-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (106 loc) · 3.73 KB
/
Copy pathMakefile
File metadata and controls
129 lines (106 loc) · 3.73 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
117
118
119
120
121
122
123
124
125
126
127
128
129
# ===========================================================================
# Garden of the Azazil — DaemonProc Makefile
# ===========================================================================
# Go parameters
GOCMD := go
GOTEST := $(GOCMD) test
GOBUILD := $(GOCMD) build
GOVET := $(GOCMD) vet
GOFMT := gofmt
GOMOD := $(GOCMD) mod
LINT := golangci-lint
# Build parameters
BINARY := daemonproc
BUILD_DIR := ./bin
MAIN_PKG := ./cmd/daemonproc
# Test parameters
TEST_FLAGS := -race -count=1 -v
COVER_FILE := coverage.out
# ===========================================================================
# Development
# ===========================================================================
.PHONY: all
all: fmt lint test build ## Run format, lint, test, and build.
.PHONY: fmt
fmt: ## Format all Go source files.
@echo ">>> Formatting..."
@$(GOFMT) -w -s .
@echo "✓ Done"
.PHONY: lint
lint: ## Run golangci-lint on all packages.
@echo ">>> Linting..."
@$(LINT) run ./...
@echo "✓ Done"
.PHONY: vet
vet: ## Run go vet on all packages.
@echo ">>> Vetting..."
@$(GOVET) ./...
@echo "✓ Done"
.PHONY: test
test: ## Run all tests with race detector.
@echo ">>> Testing..."
@$(GOTEST) ./... $(TEST_FLAGS)
@echo "✓ Done"
.PHONY: test-short
test-short: ## Run tests in short mode (skip long-running tests).
@echo ">>> Testing (short)..."
@$(GOTEST) ./... -short $(TEST_FLAGS)
@echo "✓ Done"
.PHONY: cover
cover: ## Run tests with coverage report.
@echo ">>> Coverage..."
@$(GOTEST) ./... -coverprofile=$(COVER_FILE) -covermode=atomic $(TEST_FLAGS)
@$(GOCMD) tool cover -html=$(COVER_FILE) -o coverage.html
@echo "✓ Coverage report: coverage.html"
.PHONY: build
build: ## Build the daemon binary.
@echo ">>> Building..."
@mkdir -p $(BUILD_DIR)
@$(GOBUILD) -o $(BUILD_DIR)/$(BINARY) $(MAIN_PKG)
@echo "✓ Built: $(BUILD_DIR)/$(BINARY)"
# ===========================================================================
# Dependencies
# ===========================================================================
.PHONY: deps
deps: ## Download and tidy Go module dependencies.
@echo ">>> Downloading dependencies..."
@$(GOMOD) download
@$(GOMOD) tidy
@echo "✓ Done"
.PHONY: deps-upgrade
deps-upgrade: ## Upgrade all dependencies to latest minor/patch versions.
@echo ">>> Upgrading dependencies..."
@$(GOCMD) get -u ./...
@$(GOMOD) tidy
@echo "✓ Done"
# ===========================================================================
# CI / Quality Gates
# ===========================================================================
.PHONY: check
check: fmt lint vet test ## Run all quality checks (CI equivalent).
@echo ""
@echo "═══════════════════════════════════"
@echo " ✓ All checks passed"
@echo "═══════════════════════════════════"
.PHONY: ci
ci: lint test ## Run CI checks only (lint + test, no format).
# ===========================================================================
# Cleanup
# ===========================================================================
.PHONY: clean
clean: ## Remove build artifacts and coverage files.
@echo ">>> Cleaning..."
@rm -rf $(BUILD_DIR)
@rm -f $(COVER_FILE) coverage.html
@echo "✓ Done"
# ===========================================================================
# Help
# ===========================================================================
.PHONY: help
help: ## Show this help message.
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help