-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (66 loc) · 1.97 KB
/
Makefile
File metadata and controls
77 lines (66 loc) · 1.97 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
.PHONY: build run test clean race lint help
# Build application
build:
@echo "Building server..."
@go build -o websocket-server ./cmd/server
@echo "Build complete: ./websocket-server"
# Run server
run: build
@echo "Starting server..."
@if [ -f .env ]; then \
export $$(grep -v '^#' .env | xargs); \
./websocket-server; \
else \
echo "Warning: .env file not found. Please create one with your DATABASE_URL and JWT_SECRET. See .env.example for reference."; \
./websocket-server; \
fi
# Run tests
test:
@echo "Running tests..."
@go test -v ./...
# Run short tests
test-short:
@echo "Running short tests..."
@go test -short -v ./...
# Run tests with race detector (with timeout)
test-race:
@echo "Running tests with race detector..."
@timeout 60 go test -race -short -v ./... || (echo "Tests timed out or failed" && exit 1)
# Clean build artifacts
clean:
@echo "Cleaning..."
@rm -f websocket-server
@rm -f websocket-server-race
@go clean
@echo "Clean complete"
# Run linter
lint:
@echo "Running linter..."
@golangci-lint run ./... || echo "golangci-lint not installed, skipping..."
# Build with race detector
build-race:
@echo "Building with race detector..."
@go build -race -o websocket-server-race ./cmd/server
@echo "Build complete: ./websocket-server-race"
# Format code
fmt:
@echo "Formatting code..."
@go fmt ./...
# Run go vet
vet:
@echo "Running go vet..."
@go vet ./...
# Help
help:
@echo "Available commands:"
@echo " make build - Build the application"
@echo " make run - Build and run the server"
@echo " make test - Run all tests"
@echo " make test-short - Run short tests"
@echo " make test-race - Run tests with race detector (60s timeout)"
@echo " make clean - Clean build artifacts"
@echo " make lint - Run linter"
@echo " make build-race - Build with race detector"
@echo " make fmt - Format code"
@echo " make vet - Run go vet"
@echo " make help - Show this help message"