forked from bobziuchkovski/digest
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
58 lines (47 loc) · 1.39 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
# A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
GOLANGCI_VERSION=v1.56.1
COVERAGE=coverage.out
.PHONY: setup
setup: ## Install dev tools
@echo "==> Installing dependencies..."
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_VERSION)
.PHONY: fmt
fmt: ## Format the code
@echo "==>"
@echo "==> Formatting the code..."
@gofmt -w -s .
@goimports -w .
@echo "==>"
@echo "==> Running go mod tidy..."
@go mod tidy
.PHONY: lint
lint: ## Lint the code
@echo "==>"
@echo "==> Linting all packages..."
@./bin/golangci-lint run
.PHONY: fix-lint
fix-lint: ## Fix linting errors
@echo "==>"
@echo "==> Fixing lint errors"
@./bin/golangci-lint run --fix
.PHONY: test
test: ## Run the tests
@echo "==>"
@echo "==> Running tests"
@go test -race -cover -count=1 -coverprofile ${COVERAGE} ./...
.PHONY: check
check: test fix-lint
.PHONY: all
all: fmt test lint ## Run all targets
.PHONY: link-git-hooks
link-git-hooks: ## Install git hooks
@echo "==>"
@echo "==> Installing all git hooks..."
@find .git/hooks -type l -exec rm {} \;
@find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \;
.PHONY: help
.DEFAULT_GOAL := help
help:
@echo
@echo "Makefile targets:"
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'