-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (77 loc) · 2.51 KB
/
Makefile
File metadata and controls
89 lines (77 loc) · 2.51 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
# Makefile for labelarr
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
BINARY_NAME=labelarr
BINARY_PATH=./cmd/labelarr
# Build the application
.PHONY: build
build:
$(GOBUILD) -o $(BINARY_NAME) $(BINARY_PATH)
# Run tests
.PHONY: test
test:
$(GOTEST) -v ./...
# Run tests with coverage
.PHONY: test-coverage
test-coverage:
$(GOTEST) -v -cover ./...
# Run tests with coverage report
.PHONY: test-coverage-html
test-coverage-html:
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
# Run benchmarks
.PHONY: benchmark
benchmark:
$(GOTEST) -bench=. -benchmem ./...
# Clean build artifacts
.PHONY: clean
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f $(BINARY_NAME)-linux-amd64 $(BINARY_NAME)-linux-arm64
rm -f $(BINARY_NAME)-windows-amd64.exe
rm -f $(BINARY_NAME)-darwin-amd64 $(BINARY_NAME)-darwin-arm64
rm -f coverage.out coverage.html
# Download dependencies
.PHONY: deps
deps:
$(GOMOD) download
$(GOMOD) tidy
# Run linter (requires golangci-lint to be installed)
.PHONY: lint
lint:
golangci-lint run
# Run the application
.PHONY: run
run: build
./$(BINARY_NAME)
# Build for multiple platforms
.PHONY: build-all
build-all:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -ldflags="-s -w" -o $(BINARY_NAME)-linux-amd64 $(BINARY_PATH)
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GOBUILD) -ldflags="-s -w" -o $(BINARY_NAME)-linux-arm64 $(BINARY_PATH)
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) -ldflags="-s -w" -o $(BINARY_NAME)-windows-amd64.exe $(BINARY_PATH)
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GOBUILD) -ldflags="-s -w" -o $(BINARY_NAME)-darwin-amd64 $(BINARY_PATH)
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 $(GOBUILD) -ldflags="-s -w" -o $(BINARY_NAME)-darwin-arm64 $(BINARY_PATH)
# Help target
.PHONY: help
help:
@echo "Available targets:"
@echo " build - Build the application"
@echo " test - Run all tests"
@echo " test-coverage - Run tests with coverage"
@echo " test-coverage-html - Generate HTML coverage report"
@echo " benchmark - Run benchmark tests"
@echo " clean - Clean build artifacts"
@echo " deps - Download and tidy dependencies"
@echo " lint - Run linter"
@echo " run - Build and run the application"
@echo " build-all - Build for all platforms (linux, windows, darwin; amd64, arm64)"
@echo " help - Show this help message"