-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (44 loc) · 1.83 KB
/
Makefile
File metadata and controls
60 lines (44 loc) · 1.83 KB
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
setup-hooks:
@cd .git/hooks; ln -s -f ../../scripts/git-hooks/* ./
.git/hooks/pre-commit: setup
build: .git/hooks/pre-commit
go build .
start:
@./bitcoin-lightclient
clean:
rm ./bitcoin-lightclient
# used as pre-commit
lint-git:
@files=$$(git diff --name-only --cached | grep -E '\.go$$' | xargs -r gofmt -l); if [ -n "$$files" ]; then echo $$files; exit 101; fi
@git diff --name-only --cached | grep -E '\.go$$' | xargs -r revive
@git diff --name-only --cached | grep -E '\.md$$' | xargs -r markdownlint-cli2
# lint changed files
lint:
@files=$$(git diff --name-only | grep -E '\.go$$' | xargs -r gofmt -l); if [ -n "$$files" ]; then echo $$files; exit 101; fi
@git diff --name-only | grep -E '\.go$$' | xargs -r revive
@git diff --name-only | grep -E '\.md$$' | xargs -r markdownlint-cli2
lint-all: lint-fix-go-all
@revive ./...
lint-fix-all: lint-fix-go-all
lint-fix-go-all:
@gofmt -w -s -l .
.PHONY: build start clean setup
.PHONY: lint lint-all lint-fix-all lint-fix-go-all
###############################################################################
## Tests ##
###############################################################################
TEST_COVERAGE_PROFILE=coverage.txt
TEST_TARGETS := test-unit test-unit-cover test-race
test-unit: ARGS=-timeout=10m -tags='$(UNIT_TEST_TAGS)'
test-unit-cover: ARGS=-timeout=10m -tags='$(UNIT_TEST_TAGS)' -coverprofile=$(TEST_COVERAGE_PROFILE) -covermode=atomic
test-race: ARGS=-timeout=10m -race -tags='$(TEST_RACE_TAGS)'
$(TEST_TARGETS): run-tests
run-tests:
ifneq (,$(shell which tparse 2>/dev/null))
@go test -mod=readonly -json $(ARGS) ./... | tparse
else
@go test -mod=readonly $(ARGS) ./...
endif
cover-html: test-unit-cover
@echo "--> Opening in the browser"
@go tool cover -html=$(TEST_COVERAGE_PROFILE)