-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (41 loc) · 871 Bytes
/
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
APP = rhtap-installer-cli
BIN_DIR ?= ./bin
BIN ?= $(BIN_DIR)/$(APP)
CMD ?= ./cmd/...
PKG ?= ./pkg/...
GOFLAGS ?= -v
GOFLAGS_TEST ?= -failfast -v -cover
.default: build
#
# Build and Run
#
.PHONY: $(BIN)
$(BIN):
@[ -d $(BIN_DIR) ] || mkdir -p $(BIN_DIR)
go build -o $(BIN) $(CMD) $(ARGS)
.PHONY: build
build: $(BIN)
# Runs the application with arbitrary ARGS.
.PHONY: run
run:
go run $(CMD) $(ARGS)
#
# Tools
#
# Installs golangci-lint.
tool-golangci-lint: GOFLAGS =
tool-golangci-lint:
@which golangci-lint &>/dev/null || \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest &>/dev/null
#
# Test and Lint
#
test: test-unit
# Runs the unit tests.
.PHONY: test-unit
test-unit:
go test $(GOFLAGS_TEST) $(CMD) $(PKG) $(ARGS)
# Uses golangci-lint to inspect the code base.
.PHONY: lint
lint: tool-golangci-lint
golangci-lint run ./...