-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
69 lines (57 loc) · 2.11 KB
/
Makefile
File metadata and controls
69 lines (57 loc) · 2.11 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
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
BINARY_NAME=collatz
BINARY_DIR=jfallis/collatz
VERSION?=1.0.0
EXPORT_RESULT?=false
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
.PHONY: all test build vendor
all: help
## Build:
vendor: ## Install the dependencies
$(GOCMD) mod vendor
build: vendor lint test bench ## Build the project and put the output binary
rm $(BINARY_NAME).zip
GOOS=windows GOARCH=amd64 go build -o $(BINARY_DIR)/$(BINARY_NAME)-windows.exe
GOOS=darwin GOARCH=amd64 go build -o $(BINARY_DIR)/$(BINARY_NAME)-amd64-macos
GOOS=darwin GOARCH=arm64 go build -o $(BINARY_DIR)/$(BINARY_NAME)-arm64-macos
GOOS=linux GOARCH=amd64 go build -o $(BINARY_DIR)/$(BINARY_NAME)-linux
zip -r $(BINARY_NAME).zip $(BINARY_DIR)
clean: ## Remove build related files
rm -fr ./bin
rm -fr ./jfallis
rm -f ./junit-report.xml checkstyle-report.xml ./coverage.xml ./profile.cov yamllint-checkstyle.xml
## Test:
lint: ## golang linting
go vet ./...
golangci-lint run --config golangci.yml ./...
test: ## Run the tests
ifeq ($(EXPORT_RESULT), true)
go get -u github.com/jstemmer/go-junit-report
$(eval OUTPUT_OPTIONS = | tee /dev/tty | go-junit-report -set-exit-code > junit-report.xml)
endif
$(GOTEST) -v -race ./... $(OUTPUT_OPTIONS)
fuzz: ## Run the fuzz tests
$(GOTEST) -fuzz Fuzz -fuzztime 30s ./pkg/collatz/extension/bruteforce/extension_test.go
$(GOTEST) -fuzz Fuzz -fuzztime 30s ./pkg/collatz/collatz_test.go
bench: ## Run the benchmarks
$(GOTEST) ./... -bench . -run ^$
coverage: ## Run the tests and export the coverage
$(GOTEST) -cover -coverprofile=profile.cov ./...
$(GOCMD) tool cover -func profile.cov
## Help:
help: ## Show this help.
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST)