-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (47 loc) · 2.19 KB
/
Copy pathMakefile
File metadata and controls
63 lines (47 loc) · 2.19 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
BIN := bin/execdb
PKG := ./cmd/execdb
# main.go's banner ("ExecDB v%s") adds its own "v" prefix, so a leading "v"
# is stripped here -- git describe echoes a "v1.0.0"-style tag verbatim,
# which would otherwise print as "ExecDB vv1.0.0" once any tag exists.
VERSION ?= $(shell (git describe --tags --always --dirty 2>/dev/null || echo dev) | sed 's/^v//')
BUILD_FLAGS := -trimpath
LDFLAGS := -s -w -X main.version=$(VERSION)
.DEFAULT_GOAL := help
.PHONY: help build run unit e2e test race fmt fmt-check vet lint check check-deps tidy clean
help: ## Show available targets
@grep -hE '^[a-zA-Z0-9_-]+:.*##' $(MAKEFILE_LIST) | sed 's/:.*##/\t/'
build: ## Build bin/execdb
go build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -o $(BIN) $(PKG)
run: build ## Build and start the REPL
./$(BIN)
unit: ## Run Go unit tests
go test ./...
e2e: build ## Run end-to-end checks in tests/
bash tests/e2e.sh
test: unit e2e ## unit + e2e (this is what .claude/rules/testing.md refers to)
race: ## Run all tests with the race detector (requires cgo; not part of `check`)
CGO_ENABLED=1 go test -race -count=1 ./...
fmt: ## Format sources in place
gofmt -s -w .
fmt-check: ## Fail if sources are unformatted (for CI)
@unformatted="$$(gofmt -s -l .)"; \
if [ -n "$$unformatted" ]; then \
echo "$$unformatted" 1>&2; \
exit 1; \
fi
vet: ## go vet
go vet ./...
lint: ## staticcheck (skipped if not installed)
@command -v staticcheck >/dev/null && staticcheck ./... || echo "staticcheck not installed; skipped"
check-deps: ## Enforce spec §6: engine must not import net/net-http, directly or transitively
@if go list -f '{{join .Imports "\n"}}' ./engine | grep -qx 'net\|net/http'; then \
echo "ERROR: engine must not directly import net (see execdb_spec.md §6)"; exit 1; fi
@if go list -deps ./engine | grep -qx 'net/http'; then \
echo "ERROR: engine must not depend on net/http, even transitively (see execdb_spec.md §6)"; exit 1; fi
tidy: ## go mod tidy and fail if it changed anything
go mod tidy
git diff --exit-code go.mod go.sum
check: fmt-check vet check-deps unit ## Fast pre-commit gate (also used by CI)
clean: ## Remove build artifacts and ExecDB leftovers
rm -rf bin dist
rm -f *.execdb_old