-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (50 loc) · 1.88 KB
/
Makefile
File metadata and controls
63 lines (50 loc) · 1.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
SHELL := /bin/bash
BINARY_NAME=matecommit
VERSION_PKG=github.com/thomas-vilte/matecommit/internal/version
# Build variables
GIT_COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "dev")
BUILD_DATE=$(shell date +%F)
# LDFLAGS to inject version information
LDFLAGS=-ldflags "\
-X $(VERSION_PKG).GitCommit=$(GIT_COMMIT) \
-X $(VERSION_PKG).BuildDate=$(BUILD_DATE)"
.PHONY: all build build-release test test-race test-grep clean lint help
all: build
build:
@echo "Building $(BINARY_NAME)..."
@echo " Git Commit: $(GIT_COMMIT)"
@echo " Build Date: $(BUILD_DATE)"
@go build $(LDFLAGS) -o $(BINARY_NAME) ./cmd/matecommit/main.go
@echo "Build complete: $(BINARY_NAME)"
build-release:
@echo "Building $(BINARY_NAME) for release..."
@echo " Git Commit: $(GIT_COMMIT)"
@echo " Build Date: $(BUILD_DATE)"
@go build $(LDFLAGS) -trimpath -o $(BINARY_NAME) ./cmd/matecommit/main.go
@echo "Release build complete: $(BINARY_NAME)"
test:
@echo "Running tests..."
@go test -v ./...
test-race:
@echo "Running tests with race detection..."
@go test -v -race ./... 2>&1 | grep -E "^--- FAIL|^FAIL|^panic:|[[:space:]]+Error:" || echo "All tests passed!"
test-grep:
@echo "Running tests (showing failures)..."
@go test -v ./... 2>&1 | grep -E "^--- FAIL|^FAIL|^panic:|[[:space:]]+Error:" || echo "All tests passed!"
clean:
@echo "Cleaning..."
@rm -f $(BINARY_NAME)
@rm -rf dist/
@echo "Clean complete."
lint:
@echo "Linting..."
@go vet ./...
help:
@echo "Available commands:"
@echo " make build - Build the binary with version info"
@echo " make build-release - Build optimized binary for release"
@echo " make test - Run standard tests"
@echo " make test-race - Run tests with race detection (filtered output)"
@echo " make test-grep - Run tests and grep for failures"
@echo " make clean - Remove build artifacts"
@echo " make lint - Run static analysis"