-
Notifications
You must be signed in to change notification settings - Fork 508
Expand file tree
/
Copy pathMakefile
More file actions
149 lines (118 loc) · 4.88 KB
/
Makefile
File metadata and controls
149 lines (118 loc) · 4.88 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
BIN := $(shell pwd)/bin
TOOLS := $(shell pwd)/_tools
BIN_PATH := PATH="$(abspath $(BIN)):$$PATH"
.PHONY: help
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[A-Za-z0-9_./-]+:.*?## / {printf " %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: all
all: tools-install generate lint test ## Run complete build pipeline (tools, generate, lint, test)
.PHONY: tools-install
tools-install: tools-install/checkmake ## Install development tools
@./scripts/install_tools.sh --tools-dir $(TOOLS) --bin-dir $(BIN)
# checkmake is installed as a pre-built binary for simplicity and speed.
# For platforms without pre-built binaries, we fall back to building from source.
.PHONY: tools-install/checkmake
tools-install/checkmake: ## Install checkmake binary for Makefile linting
@mkdir -p $(BIN)
@if [ ! -f $(BIN)/checkmake ]; then \
echo "Installing checkmake..."; \
CHECKMAKE_VERSION=0.2.2; \
OS=$$(uname -s | tr '[:upper:]' '[:lower:]'); \
ARCH=$$(uname -m); \
if [ "$$ARCH" = "x86_64" ]; then ARCH="amd64"; fi; \
if [ "$$ARCH" = "aarch64" ]; then ARCH="arm64"; fi; \
BINARY="checkmake-$$CHECKMAKE_VERSION.$$OS.$$ARCH"; \
if curl -sSfL -o $(BIN)/checkmake "https://github.com/checkmake/checkmake/releases/download/$$CHECKMAKE_VERSION/$$BINARY" 2>/dev/null; then \
chmod +x $(BIN)/checkmake; \
echo "checkmake $$CHECKMAKE_VERSION installed from pre-built binary"; \
else \
echo "Pre-built binary not available for $$OS/$$ARCH, building from source..."; \
GOBIN=$(abspath $(BIN)) go install github.com/checkmake/checkmake/cmd/checkmake@latest; \
echo "checkmake installed from source"; \
fi; \
fi
.PHONY: clean
clean: ## Clean build artifacts
rm -rvf coverprofile.txt *.out *.test vendor core_coverage.txt gotestsum-*
.PHONY: clean-all
clean-all: clean ## Clean everything including tools and temporary files
rm -rvf $(BIN) tmp
.PHONY: generate
generate: tools-install ## Run code generation
$(BIN_PATH) ./scripts/generate.sh
.PHONY: lint
lint: tools-install ## Run linting checks
$(BIN_PATH) ./scripts/lint.sh --all
.PHONY: lint/go
lint/go: tools-install ## Run Go linting checks
$(BIN_PATH) ./scripts/lint.sh --go
.PHONY: lint/go/fix
lint/go/fix: tools-install ## Fix linting issues automatically
$(BIN_PATH) golangci-lint run --fix ./...
.PHONY: lint/shell
lint/shell: tools-install ## Run shell script linting checks
$(BIN_PATH) ./scripts/lint.sh --shell
.PHONY: lint/misc
lint/misc: tools-install ## Run miscellaneous linting checks (copyright, Makefiles)
$(BIN_PATH) ./scripts/lint.sh --misc
.PHONY: lint/action
lint/action: tools-install ## Lint GitHub Actions workflows
$(BIN_PATH) ./scripts/lint.sh --action
.PHONY: format
format: tools-install ## Format code
$(BIN_PATH) ./scripts/format.sh --all
.PHONY: format/go
format/go: tools-install ## Format Go code
$(BIN_PATH) ./scripts/format.sh --go
.PHONY: format/shell
format/shell: tools-install ## install shfmt
$(BIN_PATH) ./scripts/format.sh --shell
.PHONY: test
test: tools-install test/unit ## Run all tests (core, integration, contrib)
$(BIN_PATH) ./scripts/test.sh --all
.PHONY: test/unit
test/unit: tools-install ## Run unit tests
go test -v -failfast ./...
.PHONY: test/appsec
test/appsec: tools-install ## Run tests with AppSec enabled
$(BIN_PATH) ./scripts/test.sh --appsec
.PHONY: test/contrib
test/contrib: tools-install ## Run contrib package tests
$(BIN_PATH) ./scripts/test.sh --contrib
.PHONY: test/integration
test/integration: tools-install ## Run integration tests
$(BIN_PATH) ./scripts/test.sh --integration
.PHONY: test-deadlock
test-deadlock: tools-install ## Run tests with deadlock detection
BUILD_TAGS=deadlock $(BIN_PATH) ./scripts/test.sh --all
.PHONY: test-debug-deadlock
test-debug-deadlock: tools-install ## Run tests with debug and deadlock detection
BUILD_TAGS=debug,deadlock $(BIN_PATH) ./scripts/test.sh --all
.PHONY: fix-modules
fix-modules: tools-install ## Fix module dependencies and consistency
$(BIN_PATH) ./scripts/fix_modules.sh
.PHONY: fix/go
fix/go: ## Apply go fix modernizations to Go code
go fix ./...
.PHONY: fix/go/diff
fix/go/diff: ## Preview go fix modernizations (dry-run)
go fix -diff ./...
.PHONY: tmp/make-help.txt
tmp/make-help.txt:
@mkdir -p tmp
@make help --no-print-directory > tmp/make-help.txt 2>&1 || true
.PHONY: tmp/test-help.txt
tmp/test-help.txt:
@mkdir -p tmp
@./scripts/test.sh --help > tmp/test-help.txt 2>&1 || true
.PHONY: docs
docs: tools-install tmp/make-help.txt tmp/test-help.txt ## Generate and Update embedded documentation in README files
$(BIN_PATH) embedmd -w README.md scripts/README.md
ORCHESTRION_VERSION := latest
ORCHESTRION_DIRS := internal/orchestrion/_integration orchestrion/all
.PHONY: upgrade/orchestrion
upgrade/orchestrion: ## Upgrade Orchestrion and fix modules
$(BIN_PATH) ORCHESTRION_VERSION=$(ORCHESTRION_VERSION) ORCHESTRION_DIRS="$(ORCHESTRION_DIRS)" ./scripts/upgrade_orchestrion.sh