-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (69 loc) · 2.08 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
SHELL := /bin/bash
GIT_SHA=`git rev-parse --short HEAD || echo`
.DEFAULT_GOAL := all
.PHONY: all
all: ## build pipeline
all: mod inst gen seed build #spell
.PHONY: ci
ci: ## CI build pipeline
ci: all lint test diff
.PHONY: release
br: all release
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: clean
clean: ## remove files created during build pipeline
$(call print-target)
rm -rf dist
rm -f coverage.*
rm -f '"$(shell go env GOCACHE)/../golangci-lint"'
go clean -i -cache -testcache -modcache -fuzzcache -x
.PHONY: mod
mod: ## go mod tidy
$(call print-target)
go mod tidy
.PHONY: inst
inst: ## go install tools
$(call print-target)
.PHONY: gen
gen: ## go generate
$(call print-target)
go generate ./...
.PHONY: build
build:
$(call print-target)
mkdir -p build
go build -ldflags "-X cmd.GitSHA=${GIT_SHA}" -o build/vmmanager .
.PHONY: release
## goreleaser build
release:
$(call print-target)
goreleaser build --rm-dist --single-target --snapshot
# .PHONY: spell
# spell: ## misspell
# $(call print-target)
# misspell -error -locale=US -w **.md
.PHONY: lint
lint: ## golangci-lint
$(call print-target)
golangci-lint run --fix
.PHONY: test
test: ## go test
$(call print-target)
go test -race -covermode=atomic -coverprofile=coverage.out -coverpkg=./... ./...
go tool cover -html=coverage.out -o coverage.html
.PHONY: diff
diff: ## git diff
$(call print-target)
git diff --exit-code
RES=$$(git status --porcelain) ; if [ -n "$$RES" ]; then echo $$RES && exit 1 ; fi
.PHONY: seed
seed:
$(call print-target)
echo -e "instance-id: iid-local01\nlocal-hostname: cloudimg\nhostname: cloudimg\npreserve_hostname: true\nmanage_etc_hosts: true" > dist/seed/meta-data
echo -e "#cloud-config\npassword: passw0rd\nchpasswd: { expire: False }\nssh_pwauth: True\n" > dist/seed/user-data
[ -f dist/seed.iso ] || hdiutil makehybrid -o dist/seed.iso -hfs -ov -joliet -iso -default-volume-name cidata dist/seed
define print-target
@printf "Executing target: \033[36m$@\033[0m\n"
endef