@@ -5,14 +5,13 @@ LOOP_PKG := github.com/lightninglabs/loop
55POOL_PKG := github.com/lightninglabs/pool
66BTCD_PKG := github.com/btcsuite/btcd
77
8- LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
9- GOVERALLS_PKG := github.com/mattn/goveralls
108GOACC_PKG := github.com/ory/go-acc
9+ GOIMPORTS_PKG := github.com/rinchsan/gosimports/cmd/gosimports
10+ TOOLS_DIR := tools
1111
1212GO_BIN := ${GOPATH}/bin
13- GOVERALLS_BIN := $(GO_BIN ) /goveralls
14- LINT_BIN := $(GO_BIN ) /golangci-lint
1513GOACC_BIN := $(GO_BIN ) /go-acc
14+ GOIMPORTS_BIN := $(GO_BIN ) /gosimports
1615
1716COMMIT := $(shell git describe --abbrev=40 --dirty --tags)
1817COMMIT_HASH := $(shell git rev-parse HEAD)
@@ -30,16 +29,12 @@ POOL_COMMIT := $(shell cat go.mod | \
3029 awk -F " " '{ print $$2 }' | \
3130 awk -F "/" '{ print $$1 }')
3231
33- LINT_COMMIT := v1.18.0
34- GOACC_COMMIT := ddc355013f90fea78d83d3a6c71f1d37ac07ecd5
32+ GOBUILD := go build -v
33+ GOINSTALL := go install -v
34+ GOTEST := go test -v
35+ GOMOD := go mod
3536
36- DEPGET := cd /tmp && GO111MODULE=on go get -v
37- GOBUILD := GO111MODULE=on go build -v
38- GOINSTALL := GO111MODULE=on go install -v
39- GOTEST := GO111MODULE=on go test -v
40- GOMOD := GO111MODULE=on go mod
41-
42- GOFILES_NOVENDOR = $(shell find . -type f -name '* .go' -not -path "./vendor/* ")
37+ GOFILES_NOVENDOR = $(shell find . -type f -name '* .go' -not -path "./vendor/* " -not -name "* pb.go" -not -name "* pb.gw.go" -not -name "* .pb.json.go")
4338GOLIST := go list -deps $(PKG ) /... | grep '$(PKG ) '| grep -v '/vendor/'
4439GOLISTCOVER := $(shell go list -deps -f '{{.ImportPath}}' ./... | grep '$(PKG ) ' | sed -e 's/^$(ESCPKG ) /./')
4540
@@ -54,6 +49,7 @@ UNIT := $(GOLIST) | $(XARGS) env $(GOTEST)
5449UNIT_RACE := $(UNIT ) -race
5550
5651include make/release_flags.mk
52+ include make/testing_flags.mk
5753
5854# We only return the part inside the double quote here to avoid escape issues
5955# when calling the external release script. The second parameter can be used to
@@ -73,6 +69,14 @@ LDFLAGS := $(call make_ldflags, $(LND_RELEASE_TAGS))
7369# and omit the DWARF symbol table (-w). Also we clear the build ID.
7470RELEASE_LDFLAGS := $(call make_ldflags, $(LND_RELEASE_TAGS ) , -s -w -buildid=)
7571
72+ # Linting uses a lot of memory, so keep it under control by limiting the number
73+ # of workers if requested.
74+ ifneq ($(workers ) ,)
75+ LINT_WORKERS = --concurrency=$(workers )
76+ endif
77+
78+ DOCKER_TOOLS = docker run -v $$(pwd ) :/build litd-tools
79+
7680ITEST_TAGS := rpctest itest $(LND_RELEASE_TAGS )
7781ITEST_LDFLAGS := $(call make_ldflags, $(ITEST_TAGS ) )
7882
@@ -90,17 +94,13 @@ all: scratch check install
9094# DEPENDENCIES
9195# ============
9296
93- $(GOVERALLS_BIN ) :
94- @$(call print, "Fetching goveralls.")
95- go get -u $(GOVERALLS_PKG )
96-
97- $(LINT_BIN ) :
98- @$(call print, "Fetching linter")
99- $(DEPGET ) $(LINT_PKG ) @$(LINT_COMMIT )
100-
10197$(GOACC_BIN ) :
102- @$(call print, "Fetching go-acc")
103- $(DEPGET ) $(GOACC_PKG ) @$(GOACC_COMMIT )
98+ @$(call print, "Installing go-acc.")
99+ cd $(TOOLS_DIR ) ; go install -trimpath -tags=tools $(GOACC_PKG )
100+
101+ $(GOIMPORTS_BIN ) :
102+ @$(call print, "Installing goimports.")
103+ cd $(TOOLS_DIR ) ; go install -trimpath $(GOIMPORTS_PKG )
104104
105105yarn-install :
106106 @$(call print, "Installing app dependencies with yarn")
@@ -138,6 +138,10 @@ release: app-build
138138 @$(call print, "Creating release of lightning-terminal.")
139139 ./release.sh build-release " $( VERSION_TAG) " " $( BUILD_SYSTEM) " " $( LND_RELEASE_TAGS) " " $( RELEASE_LDFLAGS) "
140140
141+ docker-tools :
142+ @$(call print, "Building tools docker image.")
143+ docker build -q -t litd-tools $(TOOLS_DIR )
144+
141145scratch : build
142146
143147# =======
@@ -160,16 +164,6 @@ unit-race:
160164 mkdir -p app/build && touch app/build/index.html
161165 env CGO_ENABLED=1 GORACE=" history_size=7 halt_on_errors=1" $(UNIT_RACE ) -tags=" $( LND_RELEASE_TAGS) "
162166
163- goveralls : $(GOVERALLS_BIN )
164- @$(call print, "Sending coverage report.")
165- $(GOVERALLS_BIN ) -coverprofile=coverage.txt -service=travis-ci
166-
167- travis-race : lint unit-race
168-
169- travis-cover : lint unit-cover goveralls
170-
171- travis-itest : lint
172-
173167build-itest : app-build
174168 @$(call print, "Building itest btcd and litd.")
175169 CGO_ENABLED=0 $(GOBUILD ) -tags=" $( ITEST_TAGS) " -o itest/btcd-itest -ldflags " $( ITEST_LDFLAGS) " $(BTCD_PKG )
@@ -196,13 +190,15 @@ flake-unit:
196190# =========
197191# UTILITIES
198192# =========
199- fmt :
193+ fmt : $(GOIMPORTS_BIN )
194+ @$(call print, "Fixing imports.")
195+ gosimports -w $(GOFILES_NOVENDOR )
200196 @$(call print, "Formatting source.")
201197 gofmt -l -w -s $(GOFILES_NOVENDOR )
202198
203- lint : $( LINT_BIN )
199+ lint : docker-tools
204200 @$(call print, "Linting source.")
205- $(LINT )
201+ $(DOCKER_TOOLS ) golangci-lint run -v $( LINT_WORKERS )
206202
207203mod :
208204 @$(call print, "Tidying modules.")
@@ -230,9 +226,10 @@ protos:
230226
231227protos-check : protos
232228 @$(call print, "Verifying compiled protos.")
233- if test -n " $$ (git describe --dirty | grep dirty)" ; then echo " Protos not properly formatted or not compiled with v3.4.0 " ; git status; git diff; exit 1; fi
229+ if test -n " $$ (git describe --dirty | grep dirty)" ; then echo " Protos not properly formatted or not compiled with correct version " ; git status; git diff; exit 1; fi
234230
235231clean :
236232 @$(call print, "Cleaning source.$(NC ) ")
237- $(RM ) ./lightning-terminal-debug
233+ $(RM ) ./litcli-debug
234+ $(RM ) ./litd-debug
238235 $(RM ) coverage.txt
0 commit comments