From 09406f613aa863ba01e506d6afac803296c607e7 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 10 Feb 2022 16:01:59 +0100 Subject: [PATCH] make+tools: dockerize linting --- Makefile | 16 +++++++--------- tools/Dockerfile | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 tools/Dockerfile diff --git a/Makefile b/Makefile index a4b581e42..143ea7444 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ MOBILE_PKG := $(PKG)/mobile TOOLS_DIR := tools BTCD_PKG := github.com/btcsuite/btcd -LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint GOACC_PKG := github.com/ory/go-acc GOIMPORTS_PKG := github.com/rinchsan/gosimports/cmd/gosimports GOFUZZ_BUILD_PKG := github.com/dvyukov/go-fuzz/go-fuzz-build @@ -15,7 +14,6 @@ GO_BIN := ${GOPATH}/bin BTCD_BIN := $(GO_BIN)/btcd GOIMPORTS_BIN := $(GO_BIN)/gosimports GOMOBILE_BIN := GO111MODULE=off $(GO_BIN)/gomobile -LINT_BIN := $(GO_BIN)/golangci-lint GOACC_BIN := $(GO_BIN)/go-acc GOFUZZ_BUILD_BIN := $(GO_BIN)/go-fuzz-build GOFUZZ_BIN := $(GO_BIN)/go-fuzz @@ -70,7 +68,7 @@ ifneq ($(workers),) LINT_WORKERS = --concurrency=$(workers) endif -LINT = $(LINT_BIN) run -v $(LINT_WORKERS) +DOCKER_TOOLS = docker run -v $$(pwd):/build lnd-tools GREEN := "\\033[0;32m" NC := "\\033[0m" @@ -85,10 +83,6 @@ all: scratch check install # ============ # DEPENDENCIES # ============ -$(LINT_BIN): - @$(call print, "Installing linter.") - cd $(TOOLS_DIR); go install -trimpath -tags=tools $(LINT_PKG) - $(GOACC_BIN): @$(call print, "Installing go-acc.") cd $(TOOLS_DIR); go install -trimpath -tags=tools $(GOACC_PKG) @@ -165,6 +159,10 @@ docker-release: # that we might want to overwrite in manual tests. $(DOCKER_RELEASE_HELPER) make release tag="$(tag)" sys="$(sys)" COMMIT="$(COMMIT)" COMMIT_HASH="$(COMMIT_HASH)" +docker-tools: + @$(call print, "Building tools docker image.") + docker build -q -t lnd-tools $(TOOLS_DIR) + scratch: build @@ -260,9 +258,9 @@ fmt: $(GOIMPORTS_BIN) @$(call print, "Formatting source.") gofmt -l -w -s $(GOFILES_NOVENDOR) -lint: $(LINT_BIN) +lint: docker-tools @$(call print, "Linting source.") - $(LINT) + $(DOCKER_TOOLS) golangci-lint run -v $(LINT_WORKERS) list: @$(call print, "Listing commands.") diff --git a/tools/Dockerfile b/tools/Dockerfile new file mode 100644 index 000000000..9df610994 --- /dev/null +++ b/tools/Dockerfile @@ -0,0 +1,16 @@ +FROM golang:1.17.3-buster + +RUN apt-get update && apt-get install -y git +ENV GOCACHE=/tmp/build/.cache +ENV GOMODCACHE=/tmp/build/.modcache + +COPY . /tmp/tools + +RUN cd /tmp \ + && mkdir -p /tmp/build/.cache \ + && mkdir -p /tmp/build/.modcache \ + && cd /tmp/tools \ + && go install -trimpath -tags=tools github.com/golangci/golangci-lint/cmd/golangci-lint \ + && chmod -R 777 /tmp/build/ + +WORKDIR /build