-
-
Notifications
You must be signed in to change notification settings - Fork 320
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (60 loc) · 2.14 KB
/
Makefile
File metadata and controls
79 lines (60 loc) · 2.14 KB
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
.PHONY: build install compile test doc fmt lint vet release bench
export CGO_ENABLED=0
DIR_BIN = ./bin
DIR_PKG = ./pkg
DIR_COMPAT = ./compat
DIR_TEST = ./test
DIR_INTEG = ${DIR_TEST}/integration
DIR_BENCH = ${DIR_TEST}/benchmarks
DIR_SEC = ${DIR_TEST}/security
BENCH_RUN ?= '^$$'
BENCH_FILTER ?= .
BENCH_COUNT ?= 1
BENCH_TIMEOUT ?= 30m
default: build
build: lint generate test compile
install-tools:
go install honnef.co/go/tools/cmd/staticcheck@latest && \
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest && \
go install golang.org/x/tools/cmd/goimports@latest && \
go install golang.org/x/perf/cmd/benchstat@latest && \
go install github.com/mgechev/revive@latest
install:
go get
compile:
go build -v -o ${DIR_BIN}/ferret \
${DIR_TEST}/cli.go
test: test-unit test-integration test-security
test-unit:
CGO_ENABLED=1 go test -race ${DIR_PKG}/... && CGO_ENABLED=1 go test -race ${DIR_COMPAT}/... .
test-integration:
CGO_ENABLED=1 go test -race ${DIR_INTEG}/...
test-security:
go test ${DIR_SEC}/...
clean:
rm -rf ${DIR_BIN}/* && \
rm -rf coverage.txt && \
go clean -testcache
cover:
go test -coverprofile=coverage.txt -covermode=atomic ${DIR_PKG}/... && \
curl -s https://codecov.io/bash | bash
bench-unit:
go test ${DIR_PKG}/... -run ${BENCH_RUN} -bench ${BENCH_FILTER} -benchmem -count=${BENCH_COUNT} -timeout ${BENCH_TIMEOUT}
bench-integration:
go test ${DIR_BENCH}/... -run ${BENCH_RUN} -bench ${BENCH_FILTER} -benchmem -count=${BENCH_COUNT} -timeout ${BENCH_TIMEOUT}
bench: bench-unit bench-integration
generate:
go generate ${DIR_PKG}/... && \
make fmt
doc:
godoc -http=:6060 -index
# http://golang.org/cmd/go/#hdr-Run_gofmt_on_package_sources
fmt:
fieldalignment --fix ./... && \
go fmt ./... && \
goimports -w -local github.com/MontFerret ${DIR_PKG} ${DIR_INTEG} ${DIR_E2E}
# https://github.com/mgechev/revive
# go get github.com/mgechev/revive
lint:
staticcheck -tests=false -checks=all,-U1000,-ST1000,-ST1001,-ST1020,-ST1022,-S1002 $$(go list ./pkg/... | grep -v /fql) && \
revive -config revive.toml -formatter stylish -exclude ./pkg/parser/fql/... -exclude ./vendor/... -exclude ./*_test.go ./...