-
Notifications
You must be signed in to change notification settings - Fork 40
/
Makefile
69 lines (50 loc) · 1.69 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
SHELL := /bin/bash
NAME ?= terrahelp
BIN := $(CURDIR)/bin
go_files := $(shell find . -path '*/testdata' -prune -o -type f -name '*.go' -not -path "./vendor/*" -print)
.DEFAULT_GOAL := all
.PHONY := all vet fmt fmtcheck test install uninstall clean dependencies vendor-dependencies tidy-dependencies clean-dependencies
vet: $(go_files)
go vet ./...
fmt:
@go run golang.org/x/tools/cmd/goimports -w $(go_files)
fmtcheck: $(go_files)
# Checking format of Go files...
@GOIMPORTS=$$(go run golang.org/x/tools/cmd/goimports -l $(go_files)) && \
if [ "$$GOIMPORTS" != "" ]; then \
go run golang.org/x/tools/cmd/goimports -d $(go_files); \
exit 1; \
fi
bin/.coverage.out: $(go_files)
@mkdir -p bin/
RS_API_URL=$(TEST_DB_URL) RS_USERNAME=$(TEST_USERNAME) RS_PASSWORD=$(TEST_PASSWORD) RS_DB=$(TEST_DB_NAME) go test -v ./... -coverpkg=$(shell go list ./... | xargs | sed -e 's/ /,/g') -coverprofile bin/.coverage.tmp
@mv bin/.coverage.tmp bin/.coverage.out
test: bin/.coverage.out
coverage: bin/.coverage.out
@go tool cover -html=bin/.coverage.out
bin/terrahelp: $(go_files)
go build -trimpath -o ./bin/$(NAME)
build: vet fmtcheck bin/terrahelp
install: build
cp -f bin/$(NAME) ${GOPATH}/bin/$(NAME)
uninstall:
@ echo "==> Uninstalling $(NAME)"
rm -f $$(which ${NAME})
clean:
@ echo "==> Cleaning output files."
ifneq ($(BIN),)
rm -rf $(BIN)
endif
dependencies:
@ echo "==> Downloading dependencies for $(NAME)"
@ go mod download
vendor-dependencies:
@ echo "==> Downloading dependencies for $(NAME)"
@ go mod vendor
tidy-dependencies:
@ echo "==> Tidying dependencies for $(NAME)"
@ go mod tidy
clean-dependencies:
@ echo "==> Cleaning dependencies for $(NAME)"
@ rm -rf $(VENDOR)
all: test build