-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
159 lines (137 loc) · 4.04 KB
/
Makefile
File metadata and controls
159 lines (137 loc) · 4.04 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# FileSync Makefile
# Variables
BINARY_NAME=filesync
VERSION=$(shell git describe --tags --always --dirty)
BUILD_TIME=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.BuildTime=${BUILD_TIME} -s -w"
# Default target
.PHONY: all
all: build
# Build for current platform
.PHONY: build
build:
@echo "Building FileSync..."
go build ${LDFLAGS} -o ${BINARY_NAME} .
# Build for multiple platforms
.PHONY: build-all
build-all: clean
@echo "Building FileSync for all platforms..."
GOOS=windows GOARCH=amd64 go build ${LDFLAGS} -o ${BINARY_NAME}-windows-amd64.exe .
GOOS=linux GOARCH=amd64 go build ${LDFLAGS} -o ${BINARY_NAME}-linux-amd64 .
GOOS=darwin GOARCH=amd64 go build ${LDFLAGS} -o ${BINARY_NAME}-darwin-amd64 .
GOOS=linux GOARCH=arm64 go build ${LDFLAGS} -o ${BINARY_NAME}-linux-arm64 .
GOOS=darwin GOARCH=arm64 go build ${LDFLAGS} -o ${BINARY_NAME}-darwin-arm64 .
# Install dependencies
.PHONY: deps
deps:
@echo "Installing dependencies..."
go mod download
go mod tidy
# Run tests
.PHONY: test
test:
@echo "Running tests..."
go test -v ./...
# Run tests with coverage
.PHONY: test-coverage
test-coverage:
@echo "Running tests with coverage..."
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
# Run benchmarks
.PHONY: benchmark
benchmark:
@echo "Running benchmarks..."
go test -bench=. ./...
# Clean build artifacts
.PHONY: clean
clean:
@echo "Cleaning build artifacts..."
rm -f ${BINARY_NAME}
rm -f ${BINARY_NAME}-*
rm -f coverage.out coverage.html
# Format code
.PHONY: fmt
fmt:
@echo "Formatting code..."
go fmt ./...
# Lint code
.PHONY: lint
lint:
@echo "Linting code..."
golangci-lint run
# Install golangci-lint if not present
.PHONY: install-lint
install-lint:
@echo "Installing golangci-lint..."
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.54.2
# Run security checks
.PHONY: security
security:
@echo "Running security checks..."
gosec ./...
# Install gosec if not present
.PHONY: install-security
install-security:
@echo "Installing gosec..."
go install github.com/securecodewarrior/gosec/v2/cmd/gosec@latest
# Generate documentation
.PHONY: docs
docs:
@echo "Generating documentation..."
godoc -http=:6060
# Install godoc if not present
.PHONY: install-godoc
install-godoc:
@echo "Installing godoc..."
go install golang.org/x/tools/cmd/godoc@latest
# Create release
.PHONY: release
release: build-all
@echo "Creating release..."
mkdir -p release
cp ${BINARY_NAME}-* release/
cd release && sha256sum * > checksums.txt
# Run the application
.PHONY: run
run: build
@echo "Running FileSync..."
./${BINARY_NAME}
# Run with web interface
.PHONY: run-web
run-web: build
@echo "Running FileSync web interface..."
./${BINARY_NAME} web --port 8080
# Run with watch mode
.PHONY: run-watch
run-watch: build
@echo "Running FileSync in watch mode..."
./${BINARY_NAME} watch --config examples/watch.yaml --port 8080
# Development setup
.PHONY: dev-setup
dev-setup: deps install-lint install-security install-godoc
@echo "Development environment setup complete!"
# Show help
.PHONY: help
help:
@echo "FileSync Makefile"
@echo ""
@echo "Available targets:"
@echo " build - Build for current platform"
@echo " build-all - Build for all platforms"
@echo " deps - Install dependencies"
@echo " test - Run tests"
@echo " test-coverage - Run tests with coverage"
@echo " benchmark - Run benchmarks"
@echo " clean - Clean build artifacts"
@echo " fmt - Format code"
@echo " lint - Lint code"
@echo " security - Run security checks"
@echo " docs - Generate documentation"
@echo " release - Create release"
@echo " run - Run the application"
@echo " run-web - Run web interface"
@echo " run-watch - Run in watch mode"
@echo " dev-setup - Setup development environment"
@echo " help - Show this help"