-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (58 loc) · 2.26 KB
/
Makefile
File metadata and controls
73 lines (58 loc) · 2.26 KB
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
69
70
71
72
73
.DEFAULT_GOAL := help
SHELL := bash
PATH := $(CURDIR)/.dev/go-tools/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: setup
setup: ## Setup development environment
@echo "==> Setting up development environment..."
@mkdir -p $(CURDIR)/.dev/go-tools
@export GOPATH=$(CURDIR)/.dev/go-tools && \
go install github.com/axw/gocov/gocov@latest && \
go install github.com/matm/gocov-html/cmd/gocov-html@latest
@export GOPATH=$(CURDIR)/.dev/go-tools && go clean -modcache && rm -rf $(CURDIR)/.dev/go-tools/pkg
.PHONY: clean
clean: ## Clean up development environment
@rm -rf .dev
# --------------------------------------------------------------------------------------
# Testing, Formatting and etc.
# --------------------------------------------------------------------------------------
.PHONY: format
format: ## Format source code
@go fmt ./...
.PHONY: test
test: ## Run tests
@go test -race -timeout 30m ./...
.PHONY: test-short
test-short: ## Run short tests
@go test -short -race -timeout 30m ./...
.PHONY: test-verbose
test-verbose: ## Run tests with verbose outputting
@go test -race -timeout 30m -v ./...
.PHONY: test-cover
test-cover: ## Run tests with coverage report
@mkdir -p $(CURDIR)/.dev/test
@go test -race -coverpkg=./... -coverprofile=$(CURDIR)/.dev/test/coverage.out ./...
@gocov convert $(CURDIR)/.dev/test/coverage.out | gocov-html > $(CURDIR)/.dev/test/coverage.html
.PHONY: test-cover-open
test-cover-open: ## Open coverage report in browser
@open $(CURDIR)/.dev/test/coverage.html
# --------------------------------------------------------------------------------------
# Demo application
# --------------------------------------------------------------------------------------
.PHONY: demo
demo: ## Run demo application
@npm run clean && npm run build
@go run -C ./demo .