-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathMakefile
More file actions
137 lines (104 loc) · 4.31 KB
/
Copy pathMakefile
File metadata and controls
137 lines (104 loc) · 4.31 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
GOLANGCI_LINT_VERSION := 2.9.0
# Detect OS and arch for binary download.
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
BIN_DIR := $(shell go env GOPATH)/bin
GOLANGCI_LINT := $(BIN_DIR)/golangci-lint
BINARY := wl
BUILD_DIR := bin
INSTALL_DIR := $(HOME)/.local/bin
# Version metadata injected via ldflags.
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_TIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
# Set to "true" to enable inference UI in CLI and web.
INFER_ENABLED ?= false
INTEGRATION_TIMEOUT ?= 45m
LDFLAGS := -X main.version=$(VERSION) \
-X main.commit=$(COMMIT) \
-X main.date=$(BUILD_TIME) \
-X main.inferEnabled=$(INFER_ENABLED)
.PHONY: build build-go web check check-all lint fmt-check fmt vet test test-integration test-integration-offline test-cover cover install install-tools setup clean web-check web-test audit audit-web railway-sync-vars test-scripts
## web: build web UI (requires bun)
web:
cd web && VITE_INFER_ENABLED=$(INFER_ENABLED) bun install --frozen-lockfile && bun run build
touch web/dist/.gitkeep
## build: compile wl binary with embedded web UI
build: web
go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY) ./cmd/wl
## build-go: compile wl binary without rebuilding web UI
build-go:
go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY) ./cmd/wl
## install: build and install wl to ~/.local/bin
install: build
@mkdir -p $(INSTALL_DIR)
@rm -f $(INSTALL_DIR)/$(BINARY)
@cp $(BUILD_DIR)/$(BINARY) $(INSTALL_DIR)/$(BINARY)
@echo "Installed $(BINARY) to $(INSTALL_DIR)/$(BINARY)"
## clean: remove build artifacts
clean:
rm -f $(BUILD_DIR)/$(BINARY)
## check: run fast quality gates (pre-commit: unit tests only)
check: fmt-check lint vet test
## check-all: run all quality gates including integration tests (CI)
check-all: fmt-check lint vet test-integration
## lint: run golangci-lint
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run ./...
## fmt-check: fail if formatting would change files
fmt-check: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) fmt --diff ./...
## fmt: auto-fix formatting
fmt: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) fmt ./...
## vet: run go vet
vet:
go vet ./...
## test: run unit tests (skip integration tests tagged with //go:build integration)
test:
go test ./...
## test-integration: run all tests including integration
test-integration:
go test -tags integration -timeout $(INTEGRATION_TIMEOUT) ./...
## test-integration-offline: run offline integration tests only (no network, requires dolt)
test-integration-offline:
go test -tags integration -v -timeout $(INTEGRATION_TIMEOUT) ./internal/remote/ ./test/integration/offline/
## test-cover: run tests with coverage output
test-cover:
go test -coverprofile=coverage.txt ./...
## cover: run tests and show coverage report
cover: test-cover
go tool cover -func=coverage.txt
## install-tools: install pinned golangci-lint
install-tools: $(GOLANGCI_LINT)
$(GOLANGCI_LINT):
@echo "Installing golangci-lint v$(GOLANGCI_LINT_VERSION)..."
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | \
sh -s -- -b $(BIN_DIR) v$(GOLANGCI_LINT_VERSION)
## setup: install tools, web deps, and git hooks
setup: install-tools
@command -v bun >/dev/null 2>&1 || { echo "Installing bun..."; curl -fsSL https://bun.sh/install | bash; }
cd web && bun install
git config core.hooksPath .githooks
@echo "Done. Tools installed, pre-commit hook active."
## web-check: typecheck + lint + test web frontend
web-check:
cd web && bun run check
## web-test: run web tests with coverage
web-test:
cd web && bun run test:coverage
## audit: run Go vulnerability check
audit:
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
## audit-web: run web dependency audit
audit-web:
cd web && bun audit
## railway-sync-vars: preview Railway OTLP env sync from .env.production.example
railway-sync-vars:
python3 scripts/railway_sync_vars.py --env-file .env.production.example --service wasteland --environment production --shared-env-var OTLP_SHARED_TOKEN --dry-run
## test-scripts: run repository script unit tests
test-scripts:
python3 -m unittest discover -s scripts -p 'test_*.py'
## help: show this help
help:
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## //' | column -t -s ':'