-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (53 loc) · 2.54 KB
/
Makefile
File metadata and controls
72 lines (53 loc) · 2.54 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
COMMIT_SHA_SHORT ?= $(shell git rev-parse --short=12 HEAD)
PWD_DIR := ${CURDIR}
default: help
#==========================================================================================
##@ Testing
#==========================================================================================
test: ## run go tests
@go test ./... -cover
lint: ## run go linter
# depends on https://github.com/golangci/golangci-lint
@golangci-lint run
benchmark: ## run go benchmarks
@go test -run=^$$ -bench=. ./...
license-check: ## check for invalid licenses
# depends on : https://github.com/elastic/go-licence-detector
@go list -m -mod=readonly -json all | go-licence-detector -includeIndirect -validate -rules allowedLicenses.json
.PHONY: verify
verify: test license-check lint benchmark ## run all tests
cover-report: ## generate a coverage report
go test -covermode=count -coverpkg=./... -coverprofile cover.out ./...
go tool cover -html cover.out -o cover.html
open cover.html
.PHONY: demo
run-demo: ## run the demo
go run demo/*.go
#==========================================================================================
##@ Release
#==========================================================================================
.PHONY: check-git-clean
check-git-clean: # check if git repo is clen
@git diff --quiet
.PHONY: check-branch
check-branch:
@current_branch=$$(git symbolic-ref --short HEAD) && \
if [ "$$current_branch" != "main" ]; then \
echo "Error: You are on branch '$$current_branch'. Please switch to 'main'."; \
exit 1; \
fi
check_env: # check for needed envs
@[ "${version}" ] || ( echo ">> version is not set, usage: make release version=\"v1.2.3\" "; exit 1 )
tag: check_env check-branch check-git-clean verify ## create a tag and push to git
@git diff --quiet || ( echo 'git is in dirty state' ; exit 1 )
@[ "${version}" ] || ( echo ">> version is not set, usage: make release version=\"v1.2.3\" "; exit 1 )
@git tag -d $(version) || true
@git tag -a $(version) -m "Release version: $(version)"
@git push --delete origin $(version) || true
@git push origin $(version) || true
#==========================================================================================
# Help
#==========================================================================================
.PHONY: help
help: # Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)