-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
32 lines (27 loc) · 1010 Bytes
/
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
# linting
define get_latest_lint_release
curl -s "https://api.github.com/repos/golangci/golangci-lint/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
endef
LATEST_LINT_VERSION=$(shell $(call get_latest_lint_release))
INSTALLED_LINT_VERSION=$(shell golangci-lint --version 2>/dev/null | awk '{print "v"$$4}')
# targets
.PHONY: install-linter
install-linter:
ifneq "$(INSTALLED_LINT_VERSION)" "$(LATEST_LINT_VERSION)"
@echo "new golangci-lint version found:" $(LATEST_LINT_VERSION)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin latest
endif
.PHONY: install-go-modules
install-go-modules:
go mod vendor
# run static analysis tools, configuration in ./.golangci.yml file
.PHONY: lint
lint: install-linter
golangci-lint run ./...
.PHONY: vulncheck
vulncheck:
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
.PHONY: test
test:
go test -race -covermode=atomic -coverprofile=coverage.out ./...