-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
94 lines (76 loc) · 2.04 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
86
87
88
89
90
91
92
93
94
.DEFAULT_GOAL := dev
.PHONY: dev
dev: ## dev build
dev: clean install generate buildweb vet fmt lint test mod-tidy
.PHONY: ci
ci: ## CI build
ci: dev diff
.PHONY: clean
clean: ## remove files created during build pipeline
$(call print-target)
rm -rf dist
rm -f coverage.*
.PHONY: install
install: ## go install tools
$(call print-target)
cd tools && go install $(shell cd tools && go list -e -f '{{ join .Imports " " }}' -tags=tools)
.PHONY: generate
generate: ## go generate
$(call print-target)
go generate ./...
.PHONY: buildweb
buildweb: ## generate webapp build artifacts
$(call print-target)
cd web/app && yarn && yarn build
.PHONY: vet
vet: ## go vet
$(call print-target)
go vet ./...
.PHONY: fmt
fmt: ## go fmt
$(call print-target)
go fmt ./...
cd web/app && yarn format
.PHONY: lint
lint: ## golangci-lint
$(call print-target)
golangci-lint run
cd web/app && yarn lint
.PHONY: test
test: ## go test with race detector and code covarage
$(call print-target)
go test -race -covermode=atomic -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
.PHONY: mod-tidy
mod-tidy: ## go mod tidy
$(call print-target)
go mod tidy
cd tools && go mod tidy
.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: build
build: ## goreleaser --snapshot --skip-publish --clean
build: install buildweb
$(call print-target)
goreleaser --snapshot --skip-publish --clean
.PHONY: release
release: ## goreleaser --clean
release: install buildweb
$(call print-target)
goreleaser --clean
.PHONY: run
run: ## go run
@go run -race ./cmd/deviceportal
.PHONY: go-clean
go-clean: ## go clean build, test and modules caches
$(call print-target)
go clean -r -i -cache -testcache -modcache
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
define print-target
@printf "Executing target: \033[36m$@\033[0m\n"
endef