Skip to content

Commit

Permalink
Format generated files before diffing in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
toddkazakov committed Aug 16, 2023
1 parent 5ae3f9b commit 62181cf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ generate: esc mockgen
@echo "go generate ./..."
@cd $(ROOT_DIRECTORY) && go generate ./...

ci-generate: generate
ci-generate: generate format-write-changed imports-write-changed
@cd $(ROOT_DIRECTORY) && \
O=`git diff` && [ "$${O}" = "" ] || (echo "$${O}" && exit 1)

Expand All @@ -105,6 +105,10 @@ format-write:
O=`find . -not -path './vendor/*' -name '*.go' -type f -exec gofmt -e -s -w {} \; 2>&1` && \
[ -z "$${O}" ] || (echo "$${O}" && exit 1)

format-write-changed:
@cd $(ROOT_DIRECTORY) && \
git diff --name-only | xargs -I{} gofmt -e -s -w {}

imports: goimports
@echo "goimports -d -e -local 'github.com/tidepool-org/platform'"
@cd $(ROOT_DIRECTORY) && \
Expand All @@ -117,6 +121,10 @@ imports-write: goimports
O=`find . -not -path './vendor/*' -name '*.go' -type f -exec goimports -e -w -local 'github.com/tidepool-org/platform' {} \; 2>&1` && \
[ -z "$${O}" ] || (echo "$${O}" && exit 1)

imports-write-changed: goimports
@cd $(ROOT_DIRECTORY) && \
git diff --name-only | xargs -I{} goimports -e -w -local 'github.com/tidepool-org/platform' {}

vet: tmp
@echo "go vet"
cd $(ROOT_DIRECTORY) && \
Expand Down

0 comments on commit 62181cf

Please sign in to comment.