Skip to content

Commit 5e534da

Browse files
authored
feat: add golangci to build tools (#896)
Signed-off-by: Evan Baker <[email protected]>
1 parent 4168954 commit 5e534da

File tree

4 files changed

+846
-168
lines changed

4 files changed

+846
-168
lines changed

Makefile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,13 @@ azure-cns: $(CNS_BUILD_DIR)/azure-cns$(EXE_EXT) cns-archive
176176
azure-vnet-telemetry: $(CNI_BUILD_DIR)/azure-vnet-telemetry$(EXE_EXT)
177177
acncli: $(ACNCLI_BUILD_DIR)/acncli$(EXE_EXT) acncli-archive
178178

179+
# Tool paths
180+
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
181+
GOCOV := $(TOOLS_BIN_DIR)/gocov
182+
GOCOV_XML := $(TOOLS_BIN_DIR)/gocov-xml
183+
GO_JUNIT_REPORT := $(TOOLS_BIN_DIR)/go-junit-report
184+
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint
185+
179186
# Azure-NPM only supports Linux for now.
180187
ifeq ($(GOOS),linux)
181188
azure-cnms: $(CNMS_BUILD_DIR)/azure-cnms$(EXE_EXT) cnms-archive
@@ -459,6 +466,11 @@ release:
459466

460467
PRETTYGOTEST := $(shell command -v gotest 2> /dev/null)
461468

469+
LINT_PKG ?= .
470+
471+
lint: $(GOLANGCI_LINT) ## Fast lint
472+
$(GOLANGCI_LINT) run -v $(LINT_PKG)/...
473+
462474
# run all tests
463475
.PHONY: test-all
464476
test-all:
@@ -482,28 +494,29 @@ kind:
482494
$(TOOLS_DIR)/go.mod:
483495
cd $(TOOLS_DIR); go mod init && go mod tidy
484496

485-
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
486497
$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod
487498
cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen
488499

489500
controller-gen: $(CONTROLLER_GEN) ## Build controller-gen
490501

491-
GOCOV := $(TOOLS_BIN_DIR)/gocov
492502
$(GOCOV): $(TOOLS_DIR)/go.mod
493503
cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/gocov github.com/axw/gocov/gocov
494504

495505
gocov: $(GOCOV) ## Build gocov
496506

497-
GOCOV_XML := $(TOOLS_BIN_DIR)/gocov-xml
498507
$(GOCOV_XML): $(TOOLS_DIR)/go.mod
499508
cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/gocov-xml github.com/AlekSi/gocov-xml
500509

501510
gocov-xml: $(GOCOV_XML) ## Build gocov-xml
502511

503-
GO_JUNIT_REPORT := $(TOOLS_BIN_DIR)/go-junit-report
504512
$(GO_JUNIT_REPORT): $(TOOLS_DIR)/go.mod
505513
cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/go-junit-report github.com/jstemmer/go-junit-report
506514

507515
go-junit-report: $(GO_JUNIT_REPORT) ## Build go-junit-report
508516

509-
tools: gocov gocov-xml go-junit-report ## Build bins for build tools
517+
$(GOLANGCI_LINT): $(TOOLS_DIR)/go.mod
518+
cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
519+
520+
golangci-lint: $(GOLANGCI_LINT) ## Build golangci-lint
521+
522+
tools: gocov gocov-xml go-junit-report golangci-lint ## Build bins for build tools

build/tools/go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.16
55
require (
66
github.com/AlekSi/gocov-xml v0.0.0-20190121064608-3a14fb1c4737
77
github.com/axw/gocov v1.0.0
8-
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024
8+
github.com/golangci/golangci-lint v1.40.1
9+
github.com/jstemmer/go-junit-report v0.9.1
910
sigs.k8s.io/controller-tools v0.3.0
1011
)

0 commit comments

Comments
 (0)