This repository has been archived by the owner on Nov 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
89 lines (72 loc) · 1.79 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
# Set default shell to bash
SHELL := /bin/bash -o pipefail -o errexit -o nounset
COVERAGE_REPORT ?= coverage.txt
addlicense=go run github.com/google/[email protected] -ignore **/*.yml
.PHONY: default
default: help
## Format go code
.PHONY: fmt
fmt:
go run golang.org/x/tools/cmd/[email protected] -w .
## lint code
.PHONY: lint
lint:
go run github.com/golangci/golangci-lint/cmd/[email protected] run ./...
## add license to code
.PHONY: license
license:
$(addlicense) -c "Mineiros GmbH" .
## check if code is licensed properly
.PHONY: license/check
license/check:
$(addlicense) --check .
## check go modules are tidy
.PHONY: mod/check
mod/check:
@./hack/mod-check
## tidy up go modules
.PHONY: mod
mod:
go mod tidy
## generates coverage report
.PHONY: coverage
coverage:
go test -count=1 -coverprofile=$(COVERAGE_REPORT) -coverpkg=./... ./...
## generates coverage report and shows it on the browser locally
.PHONY: coverage/show
coverage/show: coverage
go tool cover -html=$(COVERAGE_REPORT)
## test code
.PHONY: test
test:
go test -count=1 -race ./...
## Build terramate-ls into bin directory
.PHONY: build
build:
go build -o bin/terramate-ls ./cmd/terramate-ls
## Install terramate-ls on the host
.PHONY: install
install:
go install ./cmd/terramate-ls
## remove build artifacts
.PHONY: clean
clean:
rm -rf bin/*
## creates a new release tag
.PHONY: release/tag
release/tag: VERSION?=v$(shell cat VERSION)
release/tag:
git tag -a $(VERSION) -m "Release $(VERSION)"
git push origin $(VERSION)
## Display help for all targets
.PHONY: help
help:
@awk '/^.PHONY: / { \
msg = match(lastLine, /^## /); \
if (msg) { \
cmd = substr($$0, 9, 100); \
msg = substr(lastLine, 4, 1000); \
printf " ${GREEN}%-30s${RESET} %s\n", cmd, msg; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)