mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
make+tools: tidy makefile, add gosimports
This commit is contained in:
parent
a1271fee40
commit
4ed3197985
4 changed files with 56 additions and 28 deletions
76
Makefile
76
Makefile
|
|
@ -5,7 +5,12 @@ TOOLS_DIR := tools
|
|||
|
||||
GOTEST := GO111MODULE=on go test -v
|
||||
|
||||
|
||||
GOIMPORTS_PKG := github.com/rinchsan/gosimports/cmd/gosimports
|
||||
|
||||
GO_BIN := ${GOPATH}/bin
|
||||
GOIMPORTS_BIN := $(GO_BIN)/gosimports
|
||||
|
||||
GOBUILD := GO111MODULE=on go build -v
|
||||
GOINSTALL := GO111MODULE=on go install -v
|
||||
GOMOD := GO111MODULE=on go mod
|
||||
|
|
@ -14,7 +19,7 @@ COMMIT := $(shell git describe --abbrev=40 --dirty)
|
|||
LDFLAGS := -ldflags "-X $(PKG).Commit=$(COMMIT)"
|
||||
DEV_TAGS = dev
|
||||
|
||||
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
||||
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")
|
||||
GOLIST := go list $(PKG)/... | grep -v '/vendor/'
|
||||
|
||||
XARGS := xargs -L 1
|
||||
|
|
@ -37,34 +42,14 @@ define print
|
|||
echo $(GREEN)$1$(NC)
|
||||
endef
|
||||
|
||||
$(LINT_BIN):
|
||||
@$(call print, "Fetching linter")
|
||||
$(DEPGET) $(LINT_PKG)@$(LINT_COMMIT)
|
||||
# ============
|
||||
# DEPENDENCIES
|
||||
# ============
|
||||
|
||||
unit:
|
||||
@$(call print, "Running unit tests.")
|
||||
$(UNIT)
|
||||
$(GOIMPORTS_BIN):
|
||||
@$(call print, "Installing goimports.")
|
||||
cd $(TOOLS_DIR); go install -trimpath $(GOIMPORTS_PKG)
|
||||
|
||||
fmt:
|
||||
@$(call print, "Formatting source.")
|
||||
gofmt -l -w -s $(GOFILES_NOVENDOR)
|
||||
|
||||
lint: docker-tools
|
||||
@$(call print, "Linting source.")
|
||||
$(DOCKER_TOOLS) golangci-lint run -v $(LINT_WORKERS)
|
||||
|
||||
docker-tools:
|
||||
@$(call print, "Building tools docker image.")
|
||||
docker build -q -t loop-tools $(TOOLS_DIR)
|
||||
|
||||
mod-tidy:
|
||||
@$(call print, "Tidying modules.")
|
||||
$(GOMOD) tidy
|
||||
|
||||
mod-check:
|
||||
@$(call print, "Checking modules.")
|
||||
$(GOMOD) tidy
|
||||
if test -n "$$(git status | grep -e "go.mod\|go.sum")"; then echo "Running go mod tidy changes go.mod/go.sum"; git status; git diff; exit 1; fi
|
||||
|
||||
# ============
|
||||
# INSTALLATION
|
||||
|
|
@ -101,3 +86,40 @@ clean:
|
|||
@$(call print, "Cleaning up.")
|
||||
rm -f ./loop-debug ./loopd-debug
|
||||
rm -rf ./vendor
|
||||
|
||||
# =======
|
||||
# TESTING
|
||||
# =======
|
||||
|
||||
unit:
|
||||
@$(call print, "Running unit tests.")
|
||||
$(UNIT)
|
||||
|
||||
# =========
|
||||
# UTILITIES
|
||||
# =========
|
||||
|
||||
fmt: $(GOIMPORTS_BIN)
|
||||
@$(call print, "Fixing imports.")
|
||||
gosimports -w $(GOFILES_NOVENDOR)
|
||||
@$(call print, "Formatting source.")
|
||||
gofmt -l -w -s $(GOFILES_NOVENDOR)
|
||||
|
||||
lint: docker-tools
|
||||
@$(call print, "Linting source.")
|
||||
$(DOCKER_TOOLS) golangci-lint run -v $(LINT_WORKERS)
|
||||
|
||||
docker-tools:
|
||||
@$(call print, "Building tools docker image.")
|
||||
docker build -q -t loop-tools $(TOOLS_DIR)
|
||||
|
||||
mod-tidy:
|
||||
@$(call print, "Tidying modules.")
|
||||
$(GOMOD) tidy
|
||||
|
||||
mod-check:
|
||||
@$(call print, "Checking modules.")
|
||||
$(GOMOD) tidy
|
||||
if test -n "$$(git status | grep -e "go.mod\|go.sum")"; then echo "Running go mod tidy changes go.mod/go.sum"; git status; git diff; exit 1; fi
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,4 +2,7 @@ module github.com/lightninglabs/loop/tools
|
|||
|
||||
go 1.16
|
||||
|
||||
require github.com/golangci/golangci-lint v1.46.2 // indirect
|
||||
require (
|
||||
github.com/golangci/golangci-lint v1.46.2 // indirect
|
||||
github.com/rinchsan/gosimports v0.1.5 // indirect
|
||||
)
|
||||
|
|
|
|||
|
|
@ -696,6 +696,8 @@ github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8
|
|||
github.com/remyoudompheng/go-dbus v0.0.0-20121104212943-b7232d34b1d5/go.mod h1:+u151txRmLpwxBmpYn9z3d1sdJdjRPQpsXuYeY9jNls=
|
||||
github.com/remyoudompheng/go-liblzma v0.0.0-20190506200333-81bf2d431b96/go.mod h1:90HvCY7+oHHUKkbeMCiHt1WuFR2/hPJ9QrljDG+v6ls=
|
||||
github.com/remyoudompheng/go-misc v0.0.0-20190427085024-2d6ac652a50e/go.mod h1:80FQABjoFzZ2M5uEa6FUaJYEmqU2UOKojlFVak1UAwI=
|
||||
github.com/rinchsan/gosimports v0.1.5 h1:Z/l9lS79z0xgKC6fLJYmDdY44D0LFwo3MzaMtWvMKpY=
|
||||
github.com/rinchsan/gosimports v0.1.5/go.mod h1:102/jU2cwf9fpa/YM9D9o4gSen2Vg8Jl80Sxctgd9N0=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
|
|
|
|||
|
|
@ -5,4 +5,5 @@ package loop
|
|||
|
||||
import (
|
||||
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
|
||||
_ "github.com/rinchsan/gosimports/cmd/gosimports"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue