Skip to content

Commit 4dfefd0

Browse files
authored
update to tools and Makefile (#965)
1 parent 35630c2 commit 4dfefd0

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

Makefile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ acncli: $(ACNCLI_BUILD_DIR)/acncli$(EXE_EXT) acncli-archive
181181
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
182182
GOCOV := $(TOOLS_BIN_DIR)/gocov
183183
GOCOV_XML := $(TOOLS_BIN_DIR)/gocov-xml
184-
GO_JUNIT_REPORT := $(TOOLS_BIN_DIR)/go-junit-report
184+
GOFUMPT := $(TOOLS_BIN_DIR)/gofumpt
185185
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint
186+
GO_JUNIT_REPORT := $(TOOLS_BIN_DIR)/go-junit-report
186187
MOCKGEN := $(TOOLS_BIN_DIR)/mockgen
187188

188189
# Azure-NPM only supports Linux for now.
@@ -473,11 +474,16 @@ PRETTYGOTEST := $(shell command -v gotest 2> /dev/null)
473474
LINT_PKG ?= .
474475

475476
lint: $(GOLANGCI_LINT) ## Fast lint vs default branch showing only new issues
476-
$(GOLANGCI_LINT) run --new-from-rev=master -v $(LINT_PKG)/...
477+
$(GOLANGCI_LINT) run --new-from-rev master --timeout 10m -v $(LINT_PKG)/...
477478

478479
lint-old: $(GOLANGCI_LINT) ## Fast lint including previous issues
479480
$(GOLANGCI_LINT) run -v $(LINT_PKG)/...
480481

482+
FMT_PKG ?= cni cns npm
483+
484+
fmt format: $(GOFUMPT) ## run gofumpt on $FMT_PKG (default "cni cns npm")
485+
$(GOFUMPT) -s -w $(FMT_PKG)
486+
481487
# run all tests
482488
.PHONY: test-all
483489
test-all:
@@ -519,16 +525,21 @@ $(GOCOV_XML): $(TOOLS_DIR)/go.mod
519525

520526
gocov-xml: $(GOCOV_XML) ## Build gocov-xml
521527

522-
$(GO_JUNIT_REPORT): $(TOOLS_DIR)/go.mod
523-
cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/go-junit-report github.com/jstemmer/go-junit-report
528+
$(GOFUMPT): $(TOOLS_DIR)/go.mod
529+
cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/gofumpt mvdan.cc/gofumpt
524530

525-
go-junit-report: $(GO_JUNIT_REPORT) ## Build go-junit-report
531+
gofmt gofumpt: $(GOFUMPT) ## Build gofumpt
526532

527533
$(GOLANGCI_LINT): $(TOOLS_DIR)/go.mod
528534
cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
529535

530536
golangci-lint: $(GOLANGCI_LINT) ## Build golangci-lint
531537

538+
$(GO_JUNIT_REPORT): $(TOOLS_DIR)/go.mod
539+
cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/go-junit-report github.com/jstemmer/go-junit-report
540+
541+
go-junit-report: $(GO_JUNIT_REPORT) ## Build go-junit-report
542+
532543
$(MOCKGEN): $(TOOLS_DIR)/go.mod
533544
cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/mockgen github.com/golang/mock/mockgen
534545

build/tools/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ require (
88
github.com/golang/mock v1.6.0
99
github.com/golangci/golangci-lint v1.40.1
1010
github.com/jstemmer/go-junit-report v0.9.1
11+
mvdan.cc/gofumpt v0.1.1 // indirect
1112
sigs.k8s.io/controller-tools v0.3.0
1213
)

build/tools/tools.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ import (
88
_ "github.com/golang/mock/mockgen"
99
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
1010
_ "github.com/jstemmer/go-junit-report"
11+
_ "mvdan.cc/gofumpt"
1112
_ "sigs.k8s.io/controller-tools/cmd/controller-gen"
1213
)

0 commit comments

Comments
 (0)