-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
81 lines (65 loc) · 1.73 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
# Phony Targets
.PHONY: all build test install-tools lint run run-debug invoke
# Meta Targets
all: install-tools build test lint
# Build Targets
build: go-mod-tidy go-build
# Build and run the application
build-and-run:
@echo ">>>>> Starting app"
@go mod tidy -go=1.21 && go build -o cadre && ./cadre
go-mod-tidy:
@echo "🧹 Running go mod tidy"
@go mod tidy -go=1.21
go-build:
@echo "🔨 Building Go binaries"
@go build -ldflags="-s -w" ./...
# Test Targets
test: test-basic
test-basic:
@echo "🧪 Running tests"
@go test -cover ./...
test-verbose:
@echo "📝 Running tests with verbose output"
@go test -v -cover ./...
test-race:
CGO_ENABLED=1 go test -race -cover ./...
convey:
@echo "🧪 Conveying tests in browser..."
goconvey -excludedDirs=vendor
# Tooling
install-tools:
@echo "🛠️ Installing tools"
@go install mvdan.cc/gofumpt@latest
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Linting
lint: lint-golangci lint-fumpt lint-markdown
lint-fumpt:
@echo "🧹 Running gofumpt linter"
@gofumpt -l -w .
lint-golangci:
@echo "🐳 Running golangci linters"
@golangci-lint run
lint-go:
@echo "🐳 Running Go linters in Docker"
@docker run -t --rm -v $$(pwd):/app -w /app golangci/golangci-lint:v1.54.2 golangci-lint run -v \
-E bodyclose \
-E exportloopref \
-E forcetypeassert \
-E goconst \
-E gocritic \
-E misspell \
-E noctx \
-E nolintlint \
-E prealloc \
-E predeclared \
-E reassign \
-E sqlclosecheck \
-E stylecheck \
-E varnamelen \
-E wastedassign \
-E staticcheck
lint-markdown:
@echo "📚 Running Markdown linters with npm"
@if [ -z $$(which markdownlint) ]; then npm install -g markdownlint-cli; fi
@markdownlint $$(find ./. -name '*.md')