-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (46 loc) · 1.55 KB
/
Copy pathMakefile
File metadata and controls
58 lines (46 loc) · 1.55 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
.PHONY: build run test test-integration lint fmt vet tidy clean help
BINARY_NAME = memorable
BUILD_DIR = bin
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS = -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)
## build: Compile the binary
build:
@mkdir -p $(BUILD_DIR)
go build -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/memorable
## run: Build and run the server
run: build
$(BUILD_DIR)/$(BINARY_NAME)
## test: Run unit tests with race detection
test:
go test -race -count=1 ./...
## test-integration: Run integration tests (requires PostgreSQL)
test-integration:
go test -race -tags=integration -count=1 ./...
## test-cover: Run tests with coverage report
test-cover:
go test -race -coverprofile=coverage.txt -covermode=atomic $$(go list ./... | grep -v '/mcp$$' | grep -v '/store$$' | grep -v '/cmd/')
go tool cover -html=coverage.txt -o coverage.html
@echo "Coverage report: coverage.html"
## lint: Run linters
lint: vet
golangci-lint run
## vet: Run go vet
vet:
go vet ./...
## fmt: Format all Go files
fmt:
gofmt -s -w .
## tidy: Tidy and verify dependencies
tidy:
go mod tidy
go mod verify
## clean: Remove build artifacts
clean:
rm -rf $(BUILD_DIR) coverage.txt coverage.html
## help: Show this help message
help:
@echo "Usage: make [target]"
@echo ""
@sed -n 's/^## //p' $(MAKEFILE_LIST) | column -t -s ':' | sed 's/^/ /'