-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
44 lines (33 loc) · 802 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
OUTPUT?=gitstrap
BUILD_VERSION?=0.0
BUILD_HASH?=stub
BUILD_DATE?=2019.01.01
all: clean build test lint
.PHONY: build
build: $(OUTPUT)
$(OUTPUT):
go build \
-ldflags "-X main.buildVersion=$(BUILD_VERSION) -X main.buildCommit=$(BUILD_HASH) -X main.buildDate=$(BUILD_DATE)" \
-o $(OUTPUT) ./cmd/gitstrap
.PHONY: clean
clean:
rm -f $(OUTPUT)
# run_tests_dir - run all tests in provided directory
define _run_tests_dir
go test -v ${TEST_OPTS} "./$(1)/..."
endef
.PHONY: test
test: $(OUTPUT)
$(call _run_tests_dir,internal)
.PHONY: test-race
test-race: TEST_OPTS := ${TEST_OPTS} -race
test-race: test
.PHONY: bench
bench: TEST_OPTS := ${TEST_OPTS} -bench=. -run=^$
bench: test
.PHONY: lint
lint: $(OUTPUT)
golangci-lint run
.PHONY: install
install: $(OUTPUT)
install $(OUTPUT) /usr/bin