-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (70 loc) · 2.18 KB
/
Makefile
File metadata and controls
83 lines (70 loc) · 2.18 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
.PHONY: all build test test-unit lint lint-fix clean coverage check help gameid
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
# Default target
all: lint test build
# Build the project
build:
@echo "Building packages..."
$(GOBUILD) -v ./...
# Build gameid binary
gameid:
@echo "Building gameid..."
$(GOBUILD) -o cmd/gameid/gameid ./cmd/gameid
# Run all tests with race detection
test: test-unit
@echo "All tests completed!"
# Run unit tests with race detection
test-unit:
@echo "Running unit tests..."
$(GOTEST) -v -race -timeout=10m ./...
# Run tests with coverage report
coverage:
@echo "Running tests with coverage..."
$(GOTEST) -v -race -coverprofile=coverage.txt -covermode=atomic ./...
$(GOCMD) tool cover -html=coverage.txt -o coverage.html
@echo "Coverage report generated at coverage.html"
# Run linters
lint:
@echo "Running linters..."
$(GOCMD) mod tidy
golangci-lint run ./...
# Run linters with auto-fix
lint-fix:
@echo "Running linters with auto-fix..."
$(GOCMD) mod tidy
golangci-lint run --fix ./...
# Run benchmarks
bench:
@echo "Running benchmarks..."
$(GOTEST) -bench=. -benchmem ./...
# Clean build artifacts
clean:
@echo "Cleaning..."
$(GOCMD) clean
rm -f coverage.txt coverage.html
rm -rf bin/ dist/ build/
rm -f cmd/gameid/gameid
# Quick check before committing
check: lint test
@echo "All checks passed!"
# Show help
help:
@echo "go-gameid Makefile"
@echo "=================="
@echo ""
@echo "Available targets:"
@echo " all - Lint, test, and build (default)"
@echo " build - Build all packages"
@echo " gameid - Build gameid binary to cmd/gameid/"
@echo " test - Run all tests with race detection"
@echo " test-unit - Run unit tests with race detection"
@echo " bench - Run benchmarks"
@echo " coverage - Run tests and generate HTML coverage report"
@echo " lint - Run linters (golangci-lint)"
@echo " lint-fix - Run linters with auto-fix"
@echo " clean - Remove build artifacts and coverage files"
@echo " check - Run lint and test (pre-commit check)"
@echo " help - Show this help message"