Skip to content

Commit

Permalink
build: Rework golangci-lint/makefat rules
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cfergeau authored and anjannath committed Jul 25, 2022
1 parent 7a9c38f commit 39cfc21
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ CRC_VERSION = 2.6.0
COMMIT_SHA=$(shell git rev-parse --short HEAD)
MACOS_INSTALL_PATH = /Applications/Red Hat OpenShift Local.app/Contents/Resources
CONTAINER_RUNTIME ?= podman
GOLANGCI_LINT_VERSION = v1.47.0
TOOLS_BINDIR = $(realpath tools/bin)

ifdef OKD_VERSION
Expand Down Expand Up @@ -238,21 +237,18 @@ e2e-story-registry: install
fmt:
@gofmt -l -w $(SOURCE_DIRS)

$(TOOLS_BINDIR)/makefat:
$(TOOLS_BINDIR)/makefat: tools/go.mod
cd tools && GOBIN=$(TOOLS_BINDIR) go install github.com/randall77/makefat

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

# Run golangci-lint against code
.PHONY: lint cross-lint
lint: golangci-lint
lint: $(TOOLS_BINDIR)/golangci-lint
$(TOOLS_BINDIR)/golangci-lint run

cross-lint: golangci-lint
cross-lint: $(TOOLS_BINDIR)/golangci-lint
GOOS=darwin $(TOOLS_BINDIR)/golangci-lint run
GOOS=linux $(TOOLS_BINDIR)/golangci-lint run
GOARCH=amd64 GOOS=windows $(TOOLS_BINDIR)/golangci-lint run
Expand Down

0 comments on commit 39cfc21

Please sign in to comment.