-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
60 lines (48 loc) · 1.31 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
PKG_LIST := $(shell go list ./... | grep -v /vendor/)
help:
@echo "+ $@"
@grep -Eh '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m## /[33m/'
.PHONY: help
##
## Build
## ----------------------------------------------------------------------------
build: ## Build binary
@echo "+ $@"
@goreleaser build --snapshot --clean
.PHONY: build
generate: ## Autogenerate code and resources
@echo "+ $@"
@go generate ${PKG_LIST}
.PHONY: generate
clean: ## Cleanup build artifacts
@echo "+ $@"
@rm -rf dist/
.PHONY: clean
##
## Development
## ---------------------------------------------------------------------------
init: ## Initialize development environment
@echo "+ $@"
@pre-commit install --install-hooks --hook-type pre-commit --hook-type commit-msg
.PHONY: init
mod: ## Make sure go.mod is up to date
@echo "+ $@"
@go mod tidy
.PHONY: mod
test: ## Run tests
@echo "+ $@"
@go test ${PKG_LIST} -v
.PHONY: test
coverage: ## Generate test coverage
@echo "+ $@"
@go test ${PKG_LIST} -v -coverprofile=coverage.out
@go tool cover -html=coverage.out
.PHONY: coverage
lint: ## Lint Go code
@echo "+ $@"
@golangci-lint run
.PHONY: lint
format: ## Try to fix linting issues
@echo "+ $@"
@golangci-lint run --fix
.PHONY: format