-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
53 lines (41 loc) · 1.18 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
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
target := linux
endif
ifeq ($(UNAME), Darwin)
target := darwin
endif
COMMIT_HASH=$$(git rev-list -1 HEAD)
TAG_VERSION=$$(git tag --sort=committerdate | tail -1)
.PHONY: test
test:
go test -count=1 -race -cover -v $(shell go list ./... | grep -v /vendor/)
.PHONY: ci
ci: lint test
.PHONY: go-lint-install
go-lint-install:
go get -u golang.org/x/lint/golint
cp $$(go list -f {{.Target}} golang.org/x/lint/golint) /usr/local/bin
.PHONY: lint
lint:
golint -set_exit_status `go list ./...`
.PHONY: build
build:
GOOS=$(target) go build -o="bin/report" -ldflags="\
-X 'main.commitHash=$(COMMIT_HASH)' \
-X 'main.version=$(TAG_VERSION)' \
-X 'main.date=$$(date)'" \
report/report.go report/config.go report/version.go
GOOS=$(target) go build -o="bin/scan-linux" scan/scan.go scan/config.go
.PHONY: build-linux
build-linux:
GOOS=linux go build -o="bin/report-linux" -ldflags="\
-X 'main.commitHash=$(COMMIT_HASH)' \
-X 'main.version=$(TAG_VERSION)' \
-X 'main.date=$$(date)'" \
report/report.go report/config.go report/version.go
GOOS=linux go build -o="bin/scan-linux" scan/scan.go scan/config.go
vendor:
go mod vendor
tidy:
go mod tidy