-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (45 loc) · 1.62 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
projectname?= vops
default: help
.PHONY: help
help: ## list makefile targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: build
build: ## build golang binary
@go build -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags)" -o $(projectname)
.PHONY: install
install: ## install golang binary
@go install -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags)"
.PHONY: run
run: ## run the app
@go run -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags)" main.go
PHONY: test
test: clean vault ## display test coverage
go test --cover -parallel=1 -v -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
PHONY: fmt
fmt: ## format go files
gofumpt -w .
gci write .
PHONY: lint
lint: ## lint go files
golangci-lint run -c .golang-ci.yml
.PHONY: pre-commit
pre-commit: ## run pre-commit hooks
pre-commit run
.PHONY: bootstrap
bootstrap: ## install build deps
go generate -tags tools tools/tools.go
.PHONY: vault
vault: clean ## set up a development vault server and write kv secrets
vault server -config=assets/vault-cfg.hcl 2> /dev/null &
# Vault
.PHONY: token
token: ## copies vault token in clipboard buffer
jq -r '.root_token' cluster-1.json | xclip -sel clip
.PHONY: clean
clean: ## clean the development vault
@rm -rf cluster-1.* cmd/vops.yml cmd/cluster-1* snapshots/ coverage.out dist/ $(projectname) manpages/ dist/ completions/ assets/raft/* || true
@kill -9 $(shell pgrep -x vault) 2> /dev/null || true
.PHONY: vhs
vhs: install vault ## generate demo gif
vhs < assets/demo.tape