forked from DSiSc/craft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
95 lines (77 loc) · 3.12 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Copyright(c) 2018 DSiSc Group. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
VERSION=$(shell grep "const Version" version/version.go | sed -E 's/.*"(.+)"$$/\1/')
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
BUILD_DATE=$(shell date '+%Y-%m-%d-%H:%M:%S')
.PHONY: default help all build test unit-test devenv gotools clean coverage
default: all
help:
@echo 'Management commands for DSiSc/craft:'
@echo
@echo 'Usage:'
@echo ' make lint Check code style.'
@echo ' make spelling Check code spelling.'
@echo ' make fmt Check code formatting.'
@echo ' make static-check Static code check: style & spelling & formatting.'
@echo ' make build Compile the project.'
@echo ' make vet Examine source code and reports suspicious constructs.'
@echo ' make unit-test Run unit tests with coverage report.'
@echo ' make test Run unit tests with coverage report.'
@echo ' make devenv Prepare devenv for test or build.'
@echo ' make fetch-deps Run govendor fetch for deps.'
@echo ' make gotools Prepare go tools depended.'
@echo ' make clean Clean the directory tree.'
@echo
all: static-check build test
fmt:
gofmt -d -l .
spelling:
bash scripts/check_spelling.sh
lint:
@echo "Check code style..."
golint `go list ./...`
static-check: fmt spelling lint
build:
@echo "building craft ${VERSION}"
@echo "GOPATH=${GOPATH}"
go build -v -ldflags "-X github.com/DSiSc/craft/version.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X github.com/DSiSc/craft/version.BuildDate=${BUILD_DATE}" ./...
vet:
@echo "Examine source code and reports suspicious constructs..."
go vet `go list ./...`
unit-test:
@echo "Run unit tests without coverage report..."
go test -v -count=1 -race ./...
coverage:
@echo "Run unit tests with coverage report..."
bash scripts/unit_test_cov.sh
test: vet unit-test
get-tools:
# official tools
go get -u golang.org/x/lint/golint
@# go get -u golang.org/x/tools/cmd/gotype
@# go get -u golang.org/x/tools/cmd/goimports
@# go get -u golang.org/x/tools/cmd/godoc
@# go get -u golang.org/x/tools/cmd/gorename
@# go get -u golang.org/x/tools/cmd/gomvpkg
# thirdparty tools
go get -u github.com/stretchr/testify
@# go get -u github.com/kardianos/govendor
@# go get -u github.com/axw/gocov/...
@# go get -u github.com/client9/misspell/cmd/misspell
fetch-deps: get-tools
@echo "Run go get to fetch dependencies as described in dependencies.txt ..."
@bash scripts/ensure_deps.sh
## tools & deps
devenv: get-tools fetch-deps