-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (80 loc) · 2.29 KB
/
Makefile
File metadata and controls
95 lines (80 loc) · 2.29 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
# Main verify target that runs all checks
.PHONY: verify
verify: clean build license-check format-check mockgen test lint-clean lint-check coverage
# Clean target to remove build artifacts
.PHONY: clean
clean:
@echo "Cleaning build artifacts..."
go clean
# Build target to compile the project
.PHONY: build
build:
@echo "Building the project..."
go build ./...
# License-check target to check that all files contain a license header
.PHONY: license-check
license-check:
@echo "Checking license information..."
sh ./hack/license.sh ./license-code.txt "*.go"
# License-add target to add a license header to each file if not already present
.PHONY: license-add
license-add:
@echo "Adding license information..."
sh ./hack/license.sh ./license-code.txt "*.go" true
# Target to check code formatting
.PHONY: format-check
format-check:
@echo "Checking formatting..."
@out=$$(gofmt -l .); \
if [ -n "$$out" ]; then \
echo "The following files need formatting:"; \
echo "$$out"; \
exit 1; \
else \
echo "All files are properly formatted."; \
fi
# Target to format code automatically
.PHONY: format
format:
@echo "Formatting files..."
gofmt -l -w .
# mockgen target to generate mocks
.PHONY: mockgen
mockgen:
@echo "Generating mocks..."
rm -rf test/mock
mkdir -p test/mock
go generate ./...
# Test target to run unit tests
.PHONY: test
test:
@echo "Running tests..."
go test ./... -v
# Lint-clean cleans the linting cache
.PHONY: lint-clean
lint-clean: installed-linter
@echo "Running linter checks..."
golangci-lint cache clean
# Lint-check target to analyze code with linter
.PHONY: lint-check
lint-check: installed-linter
@echo "Running linter checks..."
golangci-lint run --max-issues-per-linter 0 --max-same-issues 0
# Lint-fix target to fix linting issues automatically
.PHONY: lint-fix
lint-fix: installed-linter
@echo "Fixing linting issues..."
golangci-lint run --fix
# Coverage target to check global project code coverage
.PHONY: coverage
coverage:
@echo "Generating coverage reports..."
sh ./hack/coverage.sh 70
# Installed-mockgen checks that the mockgen package is installed
.PHONY: installed-mockgen
installed-mockgen:
@sh ./hack/installed.sh "mockgen"
# Installed-linter checks that the linter is installed
.PHONY: installed-linter
installed-linter:
@sh ./hack/installed.sh "golangci-lint"