-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
34 lines (27 loc) · 1.21 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
PACKAGE = github.com/vechain/thor-go-sdk
MAJOR = $(shell go version | cut -d' ' -f3 | cut -b 3- | cut -d. -f1)
MINOR = $(shell go version | cut -d' ' -f3 | cut -b 3- | cut -d. -f2)
PACKAGES = `go list ./... | grep -v '/vendor/'`
help:
@egrep -h '\s#@\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?#@ "}; {printf "\033[36m %-30s\033[0m %s\n", $$1, $$2}'
go_version_check:
@if test $(MAJOR) -lt 1; then \
echo "Go 1.22 or higher required"; \
exit 1; \
else \
if test $(MAJOR) -eq 1 -a $(MINOR) -lt 19; then \
echo "Go 1.22 or higher required"; \
exit 1; \
fi \
fi
test:| go_version_check #@ Run the tests
@go test -cover $(PACKAGES)
test-coverage:| go_version_check #@ Run the tests with coverage
@go test -coverpkg=./... -race -coverprofile=coverage.out -covermode=atomic $(PACKAGES)
@go tool cover -html=coverage.out
lint_command_check:
@command -v golangci-lint || (echo "golangci-lint not found, please install it from https://golangci-lint.run/usage/install/" && exit 1)
lint: | go_version_check lint_command_check #@ Run 'golangci-lint'
@golangci-lint run --config .golangci.yml
lint-fix: | go_version_check lint_command_check #@ Run 'golangci-lint' with fix
@golangci-lint run --config .golangci.yml --fix