-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
85 lines (71 loc) · 1.74 KB
/
Makefile
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
# Define the name of the binary
BINARY_NAME := hooky
# Define the default target
.PHONY: all
all: build
# Build the application
.PHONY: build
build:
CGO_ENABLED=0 go build -ldflags="-s -w" -o bin/$(BINARY_NAME)
# Run tests
.PHONY: test
test:
go test -v ./...
# Clean build artifacts
.PHONY: clean
clean:
rm -f bin/$(BINARY_NAME)
rm -rf bin/
# Run the application
.PHONY: run
run: build
./bin/$(BINARY_NAME) $(RUN_ARGS)
# Format code
.PHONY: fmt
fmt:
go fmt ./...
go mod tidy
# Lint code
.PHONY: lint
lint:
golangci-lint run
# Generate documentation
.PHONY: doc
doc:
godoc -http :8080
# Run security checks
.PHONY: security
security:
gosec ./...
# Run static analysis
.PHONY: static-analysis
static-analysis: lint vet
# Vet code
.PHONY: vet
vet:
go vet ./...
# Tidy go.mod and go.sum
.PHONY: tidy
tidy:
go mod tidy
# Pre commit hook
# todo: need to add security later and fix the issues
.PHONY: pre-commit
pre-commit: fmt lint vet build test
# Show help
.PHONY: help
help:
@echo "Available targets:"
@echo " all - Default target, builds the application"
@echo " build - Build the application"
@echo " test - Run tests"
@echo " clean - Remove build artifacts"
@echo " run - Build and run the application"
@echo " fmt - Format code and tidy modules"
@echo " lint - Lint code"
@echo " doc - Generate documentation"
@echo " static-analysis - Run static analysis (lint and vet)"
@echo " vet - Vet code"
@echo " tidy - Tidy go.mod and go.sum"
@echo " pre-commit - Run pre-commit checks (fmt, lint, vet, build, test, security)"
@echo " help - Show this help message"