-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add more check rules to Makefile and github action
- Loading branch information
Showing
2 changed files
with
46 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,8 @@ all: generate precommit build | |
|
||
# precommit | ||
.PHONY: precommit precommit_lint | ||
precommit: fmt tidy vet test test_py | ||
precommit_lint: fmt tidy vet lint test test_py | ||
precommit: fmt mod-tidy-check vet test test_py | ||
precommit_lint: fmt mod-tidy-check vet lint test test_py | ||
|
||
|
||
# build | ||
|
@@ -91,7 +91,7 @@ PROTO_SRCS := $(shell find . -name "*.proto" -not -path "./vendor/*") | |
PROTO_PBS := $(PROTO_SRCS:.proto=.pb.go) | ||
PROTO_INCS := -I$(GOPATH)/src -I$(CURDIR)/proto -I$(CURDIR)/vendor | ||
|
||
.PHONY: proto | ||
.PHONY: proto proto-check | ||
proto: $(PROTO_PBS) | ||
$(PROTO_PBS): $(PROTO_SRCS) | ||
@echo $(PROTOC) | ||
|
@@ -100,15 +100,30 @@ $(PROTO_PBS): $(PROTO_SRCS) | |
--gogo_out=plugins=grpc,Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,paths=source_relative:. $$src ; \ | ||
done | ||
|
||
proto-check: | ||
$(MAKE) proto | ||
$(MAKE) fmt | ||
git diff --exit-code $(PROTO_PBS) | ||
|
||
|
||
# go:generate | ||
.PHONY: generate | ||
.PHONY: generate generate-check | ||
generate: | ||
$(GO) generate ./... | ||
|
||
generate-check: | ||
$(MAKE) generate | ||
$(MAKE) fmt | ||
git diff --exit-code | ||
|
||
|
||
# tools: lint, fmt, vet | ||
.PHONY: fmt lint vet | ||
.PHONY: tools fmt lint vet mod-tidy mod-tidy-check mod-vendor mod-vendor-check | ||
tools: | ||
$(GO) install golang.org/x/tools/cmd/goimports@latest | ||
$(GO) install golang.org/x/lint/golint@latest | ||
$(GO) install github.com/golang/mock/[email protected] | ||
|
||
fmt: | ||
@echo goimports | ||
@$(foreach path,$(PKGS),goimports -w -local $(shell $(GO) list -m) ./$(path);) | ||
|
@@ -122,9 +137,20 @@ vet: | |
@echo govet | ||
@$(foreach path,$(PKGS),$(GO) vet ./$(path);) | ||
|
||
tidy: | ||
mod-tidy: | ||
$(GO) mod tidy | ||
|
||
mod-tidy-check: | ||
$(MAKE) mod-tidy | ||
git diff --exit-code go.mod | ||
|
||
mod-vendor: | ||
$(GO) mod vendor | ||
|
||
mod-vendor-check: | ||
$(MAKE) mod-vendor | ||
git diff --exit-code vendor | ||
|
||
|
||
# cleanup | ||
.PHONY: clean clean_mock | ||
|