Skip to content

Commit

Permalink
Some makefile fixes (#442)
Browse files Browse the repository at this point in the history
* Generate and build before linting

Generated files may require some formatting that happens during
linting. Also missing generated files may result in linter failures.

Building can shake out any syntax/semantic errors and report them in a
much nicer way than the linter does. Which is exactly the reason the
build was running before linters before the Makefile simplification.

* Make stringer tool a dep of generate target, not lint

Lint target does not use the stringer utility - it is being used by go
generate.
  • Loading branch information
krnowak authored and lizthegrey committed Jan 24, 2020
1 parent 20bb650 commit 0278559
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $(TOOLS_DIR)/misspell: go.mod go.sum tools.go
$(TOOLS_DIR)/stringer: go.mod go.sum tools.go
go build -o $(TOOLS_DIR)/stringer golang.org/x/tools/cmd/stringer

precommit: lint generate build examples test
precommit: generate build lint examples test

.PHONY: test-with-coverage
test-with-coverage:
Expand Down Expand Up @@ -84,7 +84,7 @@ examples:
done

.PHONY: lint
lint: $(TOOLS_DIR)/golangci-lint $(TOOLS_DIR)/misspell $(TOOLS_DIR)/stringer
lint: $(TOOLS_DIR)/golangci-lint $(TOOLS_DIR)/misspell
set -e; for dir in $(ALL_GO_MOD_DIRS); do \
echo "golangci-lint in $${dir}"; \
(cd "$${dir}" && \
Expand All @@ -98,5 +98,5 @@ lint: $(TOOLS_DIR)/golangci-lint $(TOOLS_DIR)/misspell $(TOOLS_DIR)/stringer
go mod tidy); \
done

generate:
generate: $(TOOLS_DIR)/stringer
PATH="$(abspath $(TOOLS_DIR)):$${PATH}" go generate ./...

0 comments on commit 0278559

Please sign in to comment.