-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
67 lines (52 loc) · 2.03 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
GO_LIB_FILES=affs.go context.go const.go ds.go dsconfluence.go dsgerrit.go dsgit.go dsgithub.go dsgroupsio.go dsjira.go dsrocketchat.go dsstub.go email.go es.go error.go exec.go json.go log.go mbox.go redacted.go sql.go threads.go time.go utils.go uuid.go api.go token.go
GO_BIN_FILES=cmd/dads/dads.go
GO_TEST_FILES=context_test.go email_test.go regexp_test.go time_test.go threads_test.go
GO_LIBTEST_FILES=test/time.go
GO_BIN_CMDS=github.com/LF-Engineering/da-ds/cmd/dads
# for race CGO_ENABLED=1
# GO_ENV=CGO_ENABLED=1
GO_ENV=CGO_ENABLED=0
# for race -race
# GO_BUILD=go build -ldflags '-s -w' -race
GO_BUILD=go build -ldflags '-s -w'
GO_INSTALL=go install -ldflags '-s'
GO_FMT=gofmt -s -w
GO_LINT=golint -set_exit_status
GO_VET=go vet
GO_IMPORTS=goimports -w
GO_USEDEXPORTS=usedexports
GO_ERRCHECK=errcheck -asserts -ignoretests -ignoregenerated
GO_TEST=go test
BINARIES=dads
STRIP=strip
PKG_LIST := $(shell go list ./... | grep -v mock)
PRODUCT_NAME?=da-ds
COMMIT=`git rev-parse --short HEAD`
LDFLAGS=-ldflags "-s -w -extldflags '-static' -X build.GitCommit=$(COMMIT)"
all: check build
build: cmd/dads/dads.go ${GO_LIB_FILES}
${GO_ENV} ${GO_BUILD} -o dads ${LDFLAGS} cmd/dads/dads.go
fmt: ${GO_BIN_FILES} ${GO_LIB_FILES} ${GO_TEST_FILES} ${GO_LIBTEST_FILES}
./scripts/for_each_go_file.sh "${GO_FMT}"
lint: ## Lint the files
golint -set_exit_status $(PKG_LIST)
vet: ${GO_BIN_FILES} ${GO_LIB_FILES} ${GO_TEST_FILES} ${GO_LIBTEST_FILES}
go vet $(PKG_LIST)
imports: ${GO_BIN_FILES} ${GO_LIB_FILES} ${GO_TEST_FILES} ${GO_LIBTEST_FILES}
./scripts/for_each_go_file.sh "${GO_IMPORTS}"
usedexports: ${GO_BIN_FILES} ${GO_LIB_FILES} ${GO_TEST_FILES} ${GO_LIBTEST_FILES}
${GO_USEDEXPORTS} ./...
errcheck: ${GO_BIN_FILES} ${GO_LIB_FILES} ${GO_TEST_FILES} ${GO_LIBTEST_FILES}
${GO_ERRCHECK} ./...
test:
go test -v $(PKG_LIST)
test-coverage:
./scripts/coverage.sh
check: fmt lint imports vet usedexports errcheck
install: check ${BINARIES}
${GO_ENV} ${GO_INSTALL} ${GO_BIN_CMDS}
strip: ${BINARIES}
${STRIP} ${BINARIES}
clean:
rm -f ${BINARIES}
.PHONY: test build