From 1467fdcf427d0ac3d47d20e6bf7a4db294ddc432 Mon Sep 17 00:00:00 2001 From: carla Date: Tue, 10 Dec 2019 15:12:09 +0200 Subject: [PATCH 1/2] Makefile: Add makefile with linter and build --- Makefile | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..65d2ceb --- /dev/null +++ b/Makefile @@ -0,0 +1,62 @@ +PKG := github.com/lightninglabs/lndmon +ESCPKG := github.com\/lightninglabs\/lndmon + +LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint + +GO_BIN := ${GOPATH}/bin +LINT_BIN := $(GO_BIN)/golangci-lint + +LINT_COMMIT := v1.18.0 + +DEPGET := cd /tmp && GO111MODULE=on go get -v +GOBUILD := GO111MODULE=on go build -v + +GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*") +GOLIST := go list -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/' + +RM := rm -f +CP := cp +MAKE := make + +LINT = $(LINT_BIN) run -v + +default: build + +all: lint build + +# ============ +# DEPENDENCIES +# ============ + +$(LINT_BIN): + @$(call print, "Fetching linter") + $(DEPGET) $(LINT_PKG)@$(LINT_COMMIT) + +# ============ +# INSTALLATION +# ============ + +build: + @$(call print, "Building lndmon.") + $(GOBUILD) $(PKG)/cmd/lndmon + +# ========= +# UTILITIES +# ========= +fmt: + @$(call print, "Formatting source.") + gofmt -l -w -s $(GOFILES_NOVENDOR) + +lint: $(LINT_BIN) + @$(call print, "Linting source.") + $(LINT) + +list: + @$(call print, "Listing commands.") + @$(MAKE) -qp | \ + awk -F':' '/^[a-zA-Z0-9][^$$#\/\t=]*:([^=]|$$)/ {split($$1,A,/ /);for(i in A)print A[i]}' | \ + grep -v Makefile | \ + sort +clean: + @$(call print, "Cleaning source.$(NC)") + $(RM) ./lndmon From 7ce25249b89dad2bb74c304088b8dc6c91b1569f Mon Sep 17 00:00:00 2001 From: carla Date: Tue, 10 Dec 2019 15:12:49 +0200 Subject: [PATCH 2/2] lndmon: Add travis config --- .travis.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..411e6b1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +language: go +cache: + directories: + - $GOCACHE + - $GOPATH/pkg/mod + - $GOPATH/src/github.com/golang + - $GOPATH/src/github.com/prometheus/client_golang/prometheus + +go: + - "1.13.x" + +env: + global: + - GOCACHE=$HOME/.go-build + +sudo: required + +jobs: + include: + - stage: Build + script: + - make lint + - make build