-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
72 lines (56 loc) · 1.99 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
# Run 'make help' for a list of targets.
.DEFAULT_GOAL := help
PKG_PATH := readme
.PHONY: help
help: ## Shows this help
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
## Linting ##
.PHONY: modverify
modverify: ## Runs 'go mod verify'
@go mod verify
.PHONY: vet
vet: ## Runs 'go vet'
@go vet ./...
.PHONY: gofumpt
gofumpt: vet ## Check linting with 'gofumpt'
@go run mvdan.cc/gofumpt -l -d .
.PHONY: lines
lines: ## Check long lines.
@go run github.com/segmentio/golines -m 120 --dry-run $(PKG_PATH)/
.PHONY: lines-fix
lines-fix: lines ## Fix long lines
@go run github.com/segmentio/golines -m 120 -w $(PKG_PATH)/
.PHONY: golangci-lint
golangci-lint: ## Lint using 'golangci-lint'
@go run github.com/golangci/golangci-lint/cmd/golangci-lint \
run --deadline=300s --timeout=300s --out-format checkstyle ./... 2>&1 | tee checkstyle-report.xml
.PHONY: lint
lint: modverify vet gofumpt lines golangci-lint ## Run all linters
## Testing ##
.PHONY: test
test: ## Run unit and race tests with 'go test'
go test -v -count=1 -parallel=4 -coverprofile=coverage.txt -covermode count ./$(PKG_PATH)/...
go test -race -short ./$(PKG_PATH)/...
## Coverage ##
.PHONY: coverage
coverage: test ## Generate a code test coverage report using 'gocover-cobertura'
go run github.com/boumenot/gocover-cobertura < coverage.txt > coverage.xml
rm -f coverage.txt
.PHONY: test-coverage
test-coverage: test ## Open the HTML test coverage report
@go tool cover -html=coverage.txt
## Vulnerability checks ##
.PHONY: check-vuln
check-vuln: ## Check for vulnerabilities using 'govulncheck'
@echo "Checking for vulnerabilities..."
go run golang.org/x/vuln/cmd/govulncheck ./...
.PHONY: clean
clean: ## Clean test files
rm -f dist/*
rm -f coverage.txt coverage.xml coverage.html checkstyle-report.xml
.PHONY: docs
docs: ## Run 'go generate' to create documentation
go generate ./...
.PHONY: install
install: ## Run 'go install' to install package
go install .