Skip to content

Commit 39cfc21

Browse files
cfergeauanjannath
authored andcommitted
build: Rework golangci-lint/makefat rules
Now that tools/go.mod records the version of golangci-lint/makefat which is being used by CRC, we can use a standard Makefile rule to rebuild these binaries when tools/go.mod changes. There will be some false positive (golangci-lint will be rebuilt even if only makefat was updated), but these changes are not going to happen very frequently, so it's not a big problem.
1 parent 7a9c38f commit 39cfc21

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

Makefile

+5-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ CRC_VERSION = 2.6.0
77
COMMIT_SHA=$(shell git rev-parse --short HEAD)
88
MACOS_INSTALL_PATH = /Applications/Red Hat OpenShift Local.app/Contents/Resources
99
CONTAINER_RUNTIME ?= podman
10-
GOLANGCI_LINT_VERSION = v1.47.0
1110
TOOLS_BINDIR = $(realpath tools/bin)
1211

1312
ifdef OKD_VERSION
@@ -238,21 +237,18 @@ e2e-story-registry: install
238237
fmt:
239238
@gofmt -l -w $(SOURCE_DIRS)
240239

241-
$(TOOLS_BINDIR)/makefat:
240+
$(TOOLS_BINDIR)/makefat: tools/go.mod
242241
cd tools && GOBIN=$(TOOLS_BINDIR) go install github.com/randall77/makefat
243242

244-
.PHONY: golangci-lint
245-
golangci-lint:
246-
if $(TOOLS_BINDIR)/golangci-lint version 2>&1 | grep -vq $(GOLANGCI_LINT_VERSION); then\
247-
cd tools && GOBIN=$(TOOLS_BINDIR) go install github.com/golangci/golangci-lint/cmd/golangci-lint; \
248-
fi
243+
$(TOOLS_BINDIR)/golangci-lint: tools/go.mod
244+
cd tools && GOBIN=$(TOOLS_BINDIR) go install github.com/golangci/golangci-lint/cmd/golangci-lint
249245

250246
# Run golangci-lint against code
251247
.PHONY: lint cross-lint
252-
lint: golangci-lint
248+
lint: $(TOOLS_BINDIR)/golangci-lint
253249
$(TOOLS_BINDIR)/golangci-lint run
254250

255-
cross-lint: golangci-lint
251+
cross-lint: $(TOOLS_BINDIR)/golangci-lint
256252
GOOS=darwin $(TOOLS_BINDIR)/golangci-lint run
257253
GOOS=linux $(TOOLS_BINDIR)/golangci-lint run
258254
GOARCH=amd64 GOOS=windows $(TOOLS_BINDIR)/golangci-lint run

0 commit comments

Comments
 (0)