From 562c26c0963dca4bd7159ffeef5d1531fbf6ceb8 Mon Sep 17 00:00:00 2001 From: carla Date: Wed, 9 Sep 2020 09:28:40 +0200 Subject: [PATCH] multi: add check for imports order and add to travis Use external to to verify that imports are in the following groups: - standard packages - external packages - faraday packages --- .travis.yml | 1 + Makefile | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/.travis.yml b/.travis.yml index 81e2d59..a8c7887 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ jobs: - make mod-check - make rpc-check - make build + - make imports name: Build and lint - stage: Tests script: make unit diff --git a/Makefile b/Makefile index 9fbd4f9..7afa938 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,14 @@ LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint GOVERALLS_PKG := github.com/mattn/goveralls GOACC_PKG := github.com/ory/go-acc +IMPORTS_PKG := github.com/pavius/impi/cmd/impi +IMPORTS_COMMIT := 3cdbde3d3cbb0ead2b9491272bccb5c652174656 + GO_BIN := ${GOPATH}/bin GOVERALLS_BIN := $(GO_BIN)/goveralls LINT_BIN := $(GO_BIN)/golangci-lint GOACC_BIN := $(GO_BIN)/go-acc +IMPORTS_BIN := $(GO_BIN)/impi COMMIT := $(shell git describe --abbrev=40 --dirty) LDFLAGS := -ldflags "-X $(PKG).Commit=$(COMMIT)" @@ -55,6 +59,10 @@ $(GOACC_BIN): @$(call print, "Fetching go-acc") $(DEPGET) $(GOACC_PKG)@$(GOACC_COMMIT) +$(IMPORTS_BIN): + @$(call print, "Fetching imports check") + $(DEPGET) $(IMPORTS_PKG)@$(IMPORTS_COMMIT) + # ============ # INSTALLATION # ============ @@ -118,6 +126,11 @@ fmt: @$(call print, "Formatting source.") gofmt -l -w -s $(GOFILES_NOVENDOR) +imports: $(IMPORTS_BIN) + @$(call print, "Checking imports.") + $(IMPORTS_BIN) --local github.com/lightninglabs/faraday/ --scheme stdThirdPartyLocal --ignore-generated=true * + + lint: $(LINT_BIN) @$(call print, "Linting source.") $(LINT)