-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
69 lines (55 loc) · 2.26 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
65
66
67
68
.DEFAULT_GOAL := help
SHELL := bash
PATH := $(CURDIR)/.dev/gopath/bin:$(PATH)
# Load .env file if it exists.
ifneq (,$(wildcard ./.env))
include .env
export
endif
.PHONY: help
help: ## Show help
@echo "Usage: make [target]"
@echo ""
@echo "Available targets:"
@grep -E '^[/0-9a-zA-Z_-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
# --------------------------------------------------------------------------------------
# Development environment
# --------------------------------------------------------------------------------------
.PHONY: seup
setup: ## Setup development environment
@echo "==> Setting Go tools up..."
@mkdir -p .dev/gopath
@export GOPATH=$(CURDIR)/.dev/gopath && \
go install honnef.co/go/tools/cmd/staticcheck@latest && \
go install github.com/axw/gocov/gocov@latest && \
go install github.com/matm/gocov-html/cmd/gocov-html@latest
@export GOPATH=$(CURDIR)/.dev/gopath && go clean -modcache && rm -rf $(CURDIR)/.dev/gopath/pkg
.PHONY: clean
clean: ## Clean up development environment
@export GOPATH=$(CURDIR)/.dev/gopath && go clean -modcache
@rm -rf .dev
# --------------------------------------------------------------------------------------
# Testing, Formatting and etc.
# --------------------------------------------------------------------------------------
.PHONY: format
format: ## Format source code
@go fmt ./...
.PHONY: lint
lint: ## Lint source code
@go vet ./... ; staticcheck ./...
.PHONY: test
test: ## Test go code
@go test -race -timeout 30m $$(go list ./... | grep -v /examples)
.PHONY: test/verbose
test/verbose: ## Run all tests with verbose outputting.
@go test -race -timeout 30m -v $$(go list ./... | grep -v /examples)
.PHONY: test/cover
test/cover: ## Run tests with coverage
@echo "==> Run tests with coverage report..."
@mkdir -p $(CURDIR)/.dev/coverage
@go test -coverpkg=./... -coverprofile=$(CURDIR)/.dev/coverage/coverage.out $$(go list ./... | grep -v /examples)
@gocov convert $(CURDIR)/.dev/coverage/coverage.out | gocov-html > $(CURDIR)/.dev/coverage/coverage.html
@echo "==> Open $(CURDIR)/.dev/coverage/coverage.html to see the coverage report."
.PHONY: open/coverage
open/coverage: ## Open coverage report
@open $(CURDIR)/.dev/coverage/coverage.html