Skip to content

Commit 654ad8d

Browse files
committed
Add generate, mod-tidy and diff make targets
1 parent 1ad2679 commit 654ad8d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
.PHONY: all
44
all: ## full build
5-
all: install build fmt lint test release
5+
all: install generate build mod-tidy fmt lint test release diff
66

77
.PHONY: dev
88
dev: ## fast build
@@ -18,15 +18,28 @@ install: ## install build tools
1818
$(call print-target)
1919
./install.sh
2020

21+
.PHONY: generate
22+
generate: ## go generate
23+
$(call print-target)
24+
go generate ./...
25+
2126
.PHONY: build
2227
build: ## go build
2328
$(call print-target)
2429
go build ./...
2530

31+
.PHONY: mod-tidy
32+
mod-tidy: ## go mod tidy
33+
$(call print-target)
34+
go mod tidy
35+
git diff --exit-code -- go.mod go.sum
36+
2637
.PHONY: fmt
2738
fmt: ## goimports
2839
$(call print-target)
29-
goimports -l -w .
40+
@# ignore the goimports exit code as the generated code may be reformated
41+
goimports -l -w . || true
42+
git diff --exit-code
3043

3144
.PHONY: lint
3245
lint: ## golangci-lint
@@ -48,6 +61,11 @@ release: ## goreleaser --snapshot --skip-publish --rm-dist
4861
$(call print-target)
4962
goreleaser --snapshot --skip-publish --rm-dist
5063

64+
.PHONY: diff
65+
diff: ## git diff
66+
$(call print-target)
67+
git diff --exit-code
68+
5169
.PHONY: docker
5270
docker: ## run in golang container, example: make docker run="make all"
5371
docker run --rm -v $(CURDIR):/app $(args) golang:1.14 sh -c "cd /app && $(run)"

0 commit comments

Comments
 (0)