-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
64 lines (54 loc) · 2.38 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
61
62
63
64
help: ## Show help messages.
@grep -E '^[0-9a-zA-Z_-]+:(.*?## .*)?$$' $(MAKEFILE_LIST) | sed 's/^Makefile://' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
run="."
dir="./..."
short="-short"
flags=""
timeout=1m
.PHONY: unit_test
unit_test: ## Run unit tests. You can set: [run, timeout, short, dir, flags]. Example: make unit_test flags="-race".
@go mod tidy; go test -trimpath --timeout=$(timeout) $(short) $(dir) -run $(run) $(flags)
.PHONY: unit_test_watch
unit_test_watch: ## Run unit tests in watch mode. You can set: [run, timeout, short, dir, flags]. Example: make unit_test flags="-race".
@echo "running tests on $(run). waiting for changes..."
@-zsh -c "go mod tidy; go test -trimpath --timeout=$(timeout) $(short) $(dir) -run $(run) $(flags); repeat 100 printf '#'; echo"
@reflex -d none -r "(\.go$$)|(go.mod)|(\.sql$$)" -- zsh -c "go mod tidy; go test -trimpath --timeout=$(timeout) $(short) $(dir) -run $(run) $(flags); repeat 100 printf '#'"
.PHONY: lint
lint: ## list the code
go fmt ./...
go vet ./...
golangci-lint run ./...
.PHONY: ci_tests
ci_tests: ## Run tests for CI.
go test -trimpath --timeout=10m -failfast -v -race -covermode=atomic -coverprofile=coverage.out ./...
.PHONY: dependencies
dependencies: ## Install dependencies requried for development operations.
@go install github.com/cespare/reflex@latest
@go get github.com/stretchr/testify/mock
@go get github.com/vektra/mockery/.../
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@go install github.com/psampaz/go-mod-outdated@latest
@go install github.com/jondot/goweight@latest
@go install golang.org/x/vuln/cmd/govulncheck@latest
@go get -t -u golang.org/x/tools/cmd/cover
@go get -t -u github.com/sonatype-nexus-community/nancy@latest
@go get -u ./...
@go mod tidy
.PHONY: clean
clean: ## Clean test caches and tidy up modules.
@go clean -testcache
@go mod tidy
.PHONY: mocks
mocks: ## Generate mocks in all packages.
@go generate ./...
.PHONY: coverage
coverage: ## Show the test coverage on browser.
go test -covermode=count -coverprofile=coverage.out ./...
go tool cover -func=coverage.out | tail -n 1
go tool cover -html=coverage.out
.PHONY: audit
audit: ## Audit the code for updates, vulnerabilities and binary weight.
govulncheck ./...
go list -u -m -json all | go-mod-outdated -update -direct
go list -json -deps | nancy sleuth
goweight | head -n 20