From 98073c7dca97a8e660efef9a831d496d7aa84595 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Mon, 4 Nov 2024 11:25:30 +0100 Subject: [PATCH] build: simplify `make format`, remove `make formatcheck` (#843) --- .circleci/config.yml | 1 - .golangci.yml | 3 +++ Makefile | 12 +++--------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 53fbba5..3a32445 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -198,7 +198,6 @@ jobs: fi # other checks - - run: make formatcheck - run: make zrepl-bin test-platform-bin - run: make vet - run: make lint diff --git a/.golangci.yml b/.golangci.yml index 4246ead..355fa67 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,9 +4,12 @@ linters: - revive linters-settings: + goimports: + local-prefixes: github.com/zrepl/zrepl revive: rules: - name: time-equal + issues: exclude-rules: - path: _test\.go diff --git a/Makefile b/Makefile index ab82a86..25d9fcd 100644 --- a/Makefile +++ b/Makefile @@ -320,7 +320,7 @@ cover-full: ##################### DEV TARGETS ##################### # not part of the build, must do that manually -.PHONY: generate formatcheck format +.PHONY: generate format build/install: rm -rf build/install.tmp @@ -345,15 +345,9 @@ generate: build/install true GOIMPORTS := goimports -srcdir . -local 'github.com/zrepl/zrepl' -FINDSRCFILES := find . -type f -name '*.go' -not -path "./vendor/*" -not -name '*.pb.go' -not -name '*_enumer.go' -formatcheck: - @# goimports doesn't have a knob to exit with non-zero status code if formatting is needed - @# see https://go-review.googlesource.com/c/tools/+/237378 - @ affectedfiles=$$($(GOIMPORTS) -l $(shell $(FINDSRCFILES)) | tee /dev/stderr | wc -l); test "$$affectedfiles" = 0 - -format: - @ $(GOIMPORTS) -w -d $(shell $(FINDSRCFILES)) +format: build/install + @ build/install/gobin/goimports -w -local 'github.com/zrepl/zrepl' $$(find . -type f -name '*.go' -not -path "./vendor/*" -not -name '*.pb.go' -not -name '*_enumer.go') ##################### NOARCH ##################### .PHONY: noarch $(ARTIFACTDIR)/bash_completion $(ARTIFACTDIR)/_zrepl.zsh_completion $(ARTIFACTDIR)/go_env.txt docs docs-clean