-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (75 loc) · 2.61 KB
/
Makefile
File metadata and controls
92 lines (75 loc) · 2.61 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
84
85
86
87
88
89
90
91
92
.PHONY: build test clean install run lint fmt help
# Build variables
BINARY_NAME=gq
VERSION?=0.1.0
BUILD_TIME=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
GIT_COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
LDFLAGS=-ldflags "-X github.com/sa001gar/gopherqueue/cli.Version=$(VERSION) -X github.com/sa001gar/gopherqueue/cli.BuildDate=$(BUILD_TIME) -X github.com/sa001gar/gopherqueue/cli.GitCommit=$(GIT_COMMIT)"
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
GOFMT=gofmt
## help: Show this help message
help:
@echo "GopherQueue - Enterprise Background Job Engine"
@echo ""
@echo "Usage:"
@echo " make <target>"
@echo ""
@echo "Targets:"
@sed -n 's/^##//p' $(MAKEFILE_LIST) | column -t -s ':' | sed -e 's/^/ /'
## build: Build the CLI binary
build:
$(GOBUILD) $(LDFLAGS) -o bin/$(BINARY_NAME) ./cmd/gq
## build-all: Build for all platforms
build-all:
GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o bin/$(BINARY_NAME)-linux-amd64 ./cmd/gq
GOOS=linux GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o bin/$(BINARY_NAME)-linux-arm64 ./cmd/gq
GOOS=darwin GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o bin/$(BINARY_NAME)-darwin-amd64 ./cmd/gq
GOOS=darwin GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o bin/$(BINARY_NAME)-darwin-arm64 ./cmd/gq
GOOS=windows GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o bin/$(BINARY_NAME)-windows-amd64.exe ./cmd/gq
## install: Install the CLI to $GOPATH/bin
install:
$(GOBUILD) $(LDFLAGS) -o $(GOPATH)/bin/$(BINARY_NAME) ./cmd/gq
## test: Run all tests
test:
$(GOTEST) -v -race -cover ./...
## test-short: Run short tests only
test-short:
$(GOTEST) -v -short ./...
## test-coverage: Run tests with coverage report
test-coverage:
$(GOTEST) -v -race -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
## benchmark: Run benchmarks
benchmark:
$(GOTEST) -bench=. -benchmem ./...
## lint: Run linter
lint:
@which golangci-lint > /dev/null || (echo "Installing golangci-lint..." && go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest)
golangci-lint run ./...
## fmt: Format code
fmt:
$(GOFMT) -s -w .
## clean: Remove build artifacts
clean:
rm -rf bin/
rm -f coverage.out coverage.html
rm -rf data/
## deps: Download dependencies
deps:
$(GOMOD) download
$(GOMOD) tidy
## run: Run the server locally
run: build
./bin/$(BINARY_NAME) serve --workers 10 --http :8080
## docker-build: Build Docker image
docker-build:
docker build -t gopherqueue:$(VERSION) .
## docker-run: Run in Docker
docker-run:
docker run -p 8080:8080 -v $(PWD)/data:/app/data gopherqueue:$(VERSION)