-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
52 lines (40 loc) · 1.68 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
GOLINT_VER = v1.55.2
ifeq (,$(GOLINT_TIMEOUT))
GOLINT_TIMEOUT=2m
endif
## The headers are represented by '##@' like 'General' and the descriptions of given command is text after '##''.
.PHONY: help
help:
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ General
.PHONY: verify
verify: test checks go-lint ## verify simulates same behaviour as 'verify' GitHub Action which run on every PR
.PHONY: checks
checks: check-go-mod-tidy ## run different Go related checks
.PHONY: go-lint
go-lint: go-lint-install ## linter config in file at root of project -> '.golangci.yaml'
golangci-lint run --timeout=$(GOLINT_TIMEOUT)
go-lint-install: ## linter config in file at root of project -> '.golangci.yaml'
@if [ "$(shell command golangci-lint version --format short)" != "$(GOLINT_VER)" ]; then \
echo golangci in version $(GOLINT_VER) not found. will be downloaded; \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLINT_VER); \
echo golangci installed with version: $(shell command golangci-lint version --format short); \
fi;
##@ Tests
.PHONY: test
test: ## run Go tests
go test ./...
##@ Go checks
.PHONY: check-go-mod-tidy
check-go-mod-tidy: ## check if go mod tidy needed
go mod tidy -v
@if [ -n "$$(git status -s go.*)" ]; then \
echo -e "${RED}✗ go mod tidy modified go.mod or go.sum files${NC}"; \
git status -s go.*; \
exit 1; \
fi;
##@ Development support commands
.PHONY: fix
fix: go-lint-install ## try to fix automatically issues
go mod tidy -v
golangci-lint run --fix